Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Forecasting out of sample values for an autoregressive function....

From   John Ayers <>
Subject   st: Forecasting out of sample values for an autoregressive function....
Date   Mon, 27 Jun 2011 14:24:38 -0400

Kit Baum replied to an earlier post where an autoregressive model was
used to forecast out of sample...i.e. I want to predict an outcomes
were an autoregressive function will likely produce the best forecasts
but need to use the predicted values to produce latter predicted
values (for 52 weeks). I ran the following, but this only gives me the
prediction for one more week and not all 52 weeks. What am I doing
wrong? Thanks very much inadvance for any suggestions. (usually when I
get to the predict command, I get an error but rerun it and then get
the results).

local switch = r(tmax)
arima US L(1/4).US
predict double UShat4 if tin(`switch',), dynamic(`switch')
list date US UShat4

On May 5, 2011, at 2:33 AM, Mike wrote:

> I cannot get out-of-sample forecasting after a regression with lags:
> use
> tsset year, yearly
> regress  unem l(1/6). unem
> tsappend, add(5)
> predict unem_hat
> This gives:
> "(option xb assumed; fitted values)
> (9 missing values generated)"
> According to the manual, "-predict- can be used to make in-sample or
> out-of-sample predictions:
> 6. predict calculates the requested statistic for all possible
> observations, whether they were used in fitting the model or not."
> However from the example above only one out of sample data is predicted.
> Out-of-sample prediction does work when lags are not included:
> use
> tsset year, yearly
> regress  unem
> tsappend, add(4)
> predict unem_hat
> (option xb assumed; fitted values)
> Could anybody explain why this is?

In the latter 'regression' you are predicting a constant, and you can
do that for as many future periods as you want. If the equation is an
autoregression, and you want true ex ante predictions (that is, you do
not know what the depvar is during those periods), you must use a
dynamic forecast:

clear all
tsset year,yearly
loc switch = r(tmax)
arima unem L(1/4).unem
predict double unemhat if tin(`switch',), dynamic(`switch')

When you get far enough out of sample, the RHS values of lagged unem
will be those predicted by the model in earlier periods.

Kit Baum   |   Boston College Economics & DIW Berlin   |
                              An Introduction to Stata Programming  |
   An Introduction to Modern Econometrics Using Stata  |

Please don't forward this message to anyone else and treat all
information as confidential or privileged.
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index