Evaluating predictions after arima with handbook computations
A few of our customers have requested about the way in which predictions are computed after becoming their fashions with arima. These customers report that they can’t reproduce the whole set of forecasts manually when the mannequin accommodates MA phrases. They particularly refer that they don’t seem to be capable of get the precise values for the primary few predicted intervals. The explanation for the distinction between their handbook outcomes and the forecasts obtained with predict after arima is the way in which the beginning values and the recursive predictions are computed. Whereas Stata makes use of the Kalman filter to compute the forecasts based mostly on the state area illustration of the mannequin, customers reporting variations compute their forecasts with a unique estimator that’s based mostly on the recursions derived from the ARIMA illustration of the mannequin. Each estimators are constant however they produce barely totally different outcomes for the primary few forecasting intervals.
When utilizing the postestimation command predict after becoming their MA(1) mannequin with arima, some customers declare that they need to be capable of reproduce the predictions with
the place
![]()
Nonetheless, the recursive formulation for the Kalman filter prediction relies on the shrunk error (See part 13.3 in Hamilton (1993) for the whole derivation based mostly on the state area illustration):
![]()
the place
![]()
: is the estimated variance of the white noise disturbance
: corresponds to the unconditional imply for the error time period
Let’s use one of many datasets out there from our web site to suit a MA(1) mannequin and compute the predictions based mostly on the Kalman filter recursions formulated above:
** Predictions with Kalman Filter recursions (obtained with -predict- **
use http://www.stata-press.com/information/r12/lutkepohl, clear
arima dlinvestment, ma(1)
predict double yhat
** Coefficient estimates and sigma^2 from ereturn checklist **
scalar beta = _b[_cons]
scalar theta = [ARMA]_b[L1.ma]
scalar sigma2 = e(sigma)^2
** pt and shrinking issue for the primary two observations**
generate double pt=sigma2 in 1/2
generate double sh_factor=(sigma2)/(sigma2+theta^2*pt) in 2
** Predicted collection and errors for the primary two observations **
generate double my_yhat = beta
generate double myehat = sh_factor*(dlinvestment - my_yhat) in 2
** Predictions with the Kalman filter recursions **
quietly {
forvalues i = 3/91 {
exchange my_yhat = my_yhat + theta*l.myehat in `i'
exchange pt= (sigma2*theta^2*L.pt)/(sigma2+theta^2*L.pt) in `i'
exchange sh_factor=(sigma2)/(sigma2+theta^2*pt) in `i'
exchange myehat=sh_factor*(dlinvestment - my_yhat) in `i'
}
}
Record the primary 10 predictions (yhat from predict and my_yhat from the handbook computations):
. checklist qtr yhat my_yhat pt sh_factor in 1/10
+--------------------------------------------------------+
| qtr yhat my_yhat pt sh_factor |
|--------------------------------------------------------|
1. | 1960q1 .01686688 .01686688 .00192542 . |
2. | 1960q2 .01686688 .01686688 .00192542 .97272668 |
3. | 1960q3 .02052151 .02052151 .00005251 .99923589 |
4. | 1960q4 .01478403 .01478403 1.471e-06 .99997858 |
5. | 1961q1 .01312365 .01312365 4.125e-08 .9999994 |
|--------------------------------------------------------|
6. | 1961q2 .00326376 .00326376 1.157e-09 .99999998 |
7. | 1961q3 .02471242 .02471242 3.243e-11 1 |
8. | 1961q4 .01691061 .01691061 9.092e-13 1 |
9. | 1962q1 .01412974 .01412974 2.549e-14 1 |
10. | 1962q2 .00643301 .00643301 7.147e-16 1 |
+--------------------------------------------------------+
Discover that the shrinking issue (sh_factor) tends to 1 as t will increase, which means that after just a few preliminary intervals the predictions produced with the Kalman filter recursions turn out to be precisely the identical as those produced by the formulation on the high of this entry for the recursions derived from the ARIMA illustration of the mannequin.
Reference:
Hamilton, James. 1994. Time Sequence Evaluation. Princeton College Press.
