| ![](/includes/contimages/spacer.gif) |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: Re: statalist-digest V4 #2488
In answer to a question from Ashwani K Gupta,
Clive Nichols proposed, as an example of ARIMA:
- -----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--------------------------------------------------------------
Unfortunately, the predicted values do not resemble the series, having
means close to zero.
This is not easily fixed by using
arima dowclose l(21/42).ln_dow bob if tin(,4999), arima(1,1,1)
which fails to converge after 85 iterations, with repeated backing up.
(It might work; I just wans't prepared to wait.)
However, the -y- option of -predict- does the job without trouble:
predict y_static if tin(5000,5013) , y
predict y_dynamic if tin(5000,5013), dynamic(5000) y
tsline dowclose static dynamic if tin(5000,5013), scheme(economist) ///
legend(cols(1) stack)
This reveals that the bulk of the prediction is the previous value with
a little linear trend. More complex models might, of course, do better.
------------------------------
Date: Thu, 12 Oct 2006 09:14:40 +0100 (BST)
From: "Clive Nicholas" <[email protected]>
Subject: Re: st: Predict after arima, forecasting how to??
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).
=========================
Paul T Seed, MSc CStat
Lecturer in Medical Statistics
King's College London,
Division of Reproduction and Endocrinology
St Thomas' Hospital,
Lambeth Palace Road,
London SE1 7EH
Funded by the Wellcome Trust & Tommy's the Baby Charity
http://www.mfru.info/lecturenotes.html
([email protected])
tel (+44) (0) 20 7188 3642
fax (+44) (0) 20 7620 1227
*
* 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/