Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Predict after arima, forecasting how to??


From   "Clive Nicholas" <Clive.Nicholas@newcastle.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Predict after arima, forecasting how to??
Date   Thu, 12 Oct 2006 09:14:40 +0100 (BST)

Ashwani K Gupta wrote:

> I am working with 2 time series X and Y.  I have smoothed both series
> and this has automatically filled in time series gaps.
>
> After exploratory analysis I have found D.X and D.Y to be stationary.
>
> Also my hypothesis is that Y lags behind X by a variable time period
> most often 21 to  42 days.  I have found this to be true by visual
> inspection of L(21/42).X vs. Y.  Also the cross-correlelograms comfirm
> this.
>
> I am now experimenting with fitting arima(1,0,1) models to D.Y and D.X.

Why, when you could type

. arima y l(21/42).x, arima(1,1,1)

if you want Stata to automatically fit a first-differenced ARIMA model? Or
have I missed something?

> I am using predict, y to get predictions for the non diffrenced series.

You're confusing me now. First, you say that you want to use -arima- to
regress D.y on D.x, then you say you're obtaining _non_-differenced
predicted values from it. Again, I may have misunderstood, but in any
case, I apply a differenced model throughout my demonstrations (shown
below), which answer your key question.

> Can someone tell me how I can obtain forecasts for 14 day intervals, not
> one step forecasts?

Assuming you mean forecasts covering whole 14-day windows, there are two
main ways. The first way is to produce 'static' forecasts: in other words,
producing forecasts over some time horizon (in your case: T+1 ... T+14),
but where the observations for this horizon have been included in the
model. Thus you are, in effect, comparing predicted values from your model
with the actual values from your dataset.

The second way is to produce 'dynamic' forecasts: in other words,
producing forecasts over some time horizon (in your case: T+1 ... T+14),
but where the observations for this horizon have _not_ been included in
the model. Thus, you're letting your model predict future values for that
period without it knowing what the actual values for that period are (or
were). Again, predicted and actual values can be compared.

> IS there any other flaw in the methodology used above.

None other than I've been able to point out, I think. See the example code
below, where I've included an extra variable to make it a multivariate
model. Also, notice that you can use -tsline- to create some very useful
graphs for visual model comparison (if doesn't produce a very memorable or
meaningful graph in this example, but it has in my datasets, so you'll get
the idea).

-----Starts here------------------------------------------------------------
clear

webuse dow1

g bob=invnorm(uniform())*10

tsset t /*Notice that -date- isn't used here since it has gaps*/

arima dowclose l(21/42).ln_dow bob if tin(,4999), arima(1,1,1) /*This will
only take 8 iterations to fit*/

predict static if tin(5000,5013)

predict dynamic if tin(5000,5013), dynamic(5000)

tsline dowclose static dynamic if tin(5000,5013), scheme(economist) ///
     legend(cols(1) stack)
-----Ends here--------------------------------------------------------------

Hope all that helps.

CLIVE NICHOLAS        |t: 0(044)7903 397793
Politics              |e: clive.nicholas@ncl.ac.uk
Newcastle University  |http://www.ncl.ac.uk/geps

Whereever you go and whatever you do, just remember this. No matter how
many like you, admire you, love you or adore you, the number of people
turning up to your funeral will be largely determined by local weather
conditions.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index