PROC AUTOREG produces two types of predicted values for the response series — predicted values based on only the structural part of the model, x'β, and predicted values based on both the structural part of the model and the error process, x'β + vt|t-1. For an AR(m) error process, when m previous values of the structural residuals are available, vt|t-1 is computed using the estimated AR parameters and the m previous structural residuals:
vt|t-1 = -φ1vt-1 - φ2vt-2 - ... - φmvt-m
The negative signs in front of the AR parameters in this equation result from the specification of the error process in PROC AUTOREG which has negative signs in front of the AR parameters. See "Regression with Autocorrelated Errors" in the Details section of the PROC AUTOREG documentation.
When the structural residuals from the previous period are not available, then a minimum variance linear predictor of the error term given past values of the structural residuals is used together with the estimated AR parameters to compute vt|t-1. The following example shows how the predicted values can be computed in a DATA step. Note that the predicted values cannot be easily replicated for the first NLAG=n observations in the data set, or for the first NLAG=n observations following a missing dependent value. For these observations computation of predicted values use a Kalman filtering technique.
Sometimes you might want to compute predicted values for a data set when you do not have a sufficient number of observations to obtain reliable parameter estimates for the AR(m) model, or you just want to use predetermined parameters to compute predicted values for your data. In these situations, you can specify the GARCH=(q=1) option in the MODEL statement, and use the RESTRICT statement to restrict the _AH_1 parameter to zero and all the AR model parameters to fixed values. You can use this approach to compute predicted values in the AR model provided that you have at least k+1 observations on both the dependent and independent variables in the beginning of the data set, where k is the total number of parameters in the model in which GARCH=(q=1) is specified. An example is given in this note.
Example:
The following DATA step creates the data to be analyzed. The variable X contains the annual real GNP series from 1901 to 1973. The dependent variable in this analysis is the natural log of real GNP, Y. The independent variable in the model is the time trend variable, T. For the years from 1974 through 1983, no real GNP is observed. To have PROC AUTOREG produce predictions for these years, values of T are provided and the dependent variable, Y, is set to missing.
data gnp;
date = intnx( 'year', '01jan1901'd, _n_-1 );
format date year4.;
input x @@;
y = log(x);
t = _n_;
label y = 'Real GNP'
t = 'Time Trend';
datalines;
137.87 139.13 146.10 144.21 155.04 172.97 175.61 161.22
180.93 185.98 191.90 201.51 203.38 195.96 193.63 208.19
211.43 244.33 228.99 214.22 199.94 229.54 254.09 256.39
276.03 291.81 293.27 296.22 315.69 285.52 263.46 227.04
222.13 239.09 260.04 295.54 310.16 296.75 319.83 344.16
400.40 461.80 531.66 569.13 560.17 478.28 470.39 489.74
492.24 534.57 579.17 600.63 623.46 615.64 657.37 671.72
683.57 680.88 721.72 737.01 756.59 800.29 832.20 875.96
929.00 984.62 1011.38 1058.06 1087.58 1085.58 1122.42 1185.92
1254.20 . . . . . . .
. . .
;
These statements display the data set.
proc print data=gnp noobs;
run;
1901 |
137.87 |
4.92631 |
1 |
1902 |
139.13 |
4.93541 |
2 |
1903 |
146.10 |
4.98429 |
3 |
1904 |
144.21 |
4.97127 |
4 |
1905 |
155.04 |
5.04368 |
5 |
1906 |
172.97 |
5.15312 |
6 |
1907 |
175.61 |
5.16827 |
7 |
1908 |
161.22 |
5.08277 |
8 |
1909 |
180.93 |
5.19811 |
9 |
1910 |
185.98 |
5.22564 |
10 |
1911 |
191.90 |
5.25697 |
11 |
1912 |
201.51 |
5.30584 |
12 |
1913 |
203.38 |
5.31508 |
13 |
1914 |
195.96 |
5.27791 |
14 |
1915 |
193.63 |
5.26595 |
15 |
1916 |
208.19 |
5.33845 |
16 |
1917 |
211.43 |
5.35389 |
17 |
1918 |
244.33 |
5.49852 |
18 |
1919 |
228.99 |
5.43368 |
19 |
1920 |
214.22 |
5.36700 |
20 |
1921 |
199.94 |
5.29802 |
21 |
1922 |
229.54 |
5.43608 |
22 |
1923 |
254.09 |
5.53769 |
23 |
1924 |
256.39 |
5.54670 |
24 |
1925 |
276.03 |
5.62051 |
25 |
1926 |
291.81 |
5.67610 |
26 |
1927 |
293.27 |
5.68109 |
27 |
1928 |
296.22 |
5.69110 |
28 |
1929 |
315.69 |
5.75476 |
29 |
1930 |
285.52 |
5.65431 |
30 |
1931 |
263.46 |
5.57390 |
31 |
1932 |
227.04 |
5.42513 |
32 |
1933 |
222.13 |
5.40326 |
33 |
1934 |
239.09 |
5.47684 |
34 |
1935 |
260.04 |
5.56084 |
35 |
1936 |
295.54 |
5.68880 |
36 |
1937 |
310.16 |
5.73709 |
37 |
1938 |
296.75 |
5.69289 |
38 |
1939 |
319.83 |
5.76779 |
39 |
1940 |
344.16 |
5.84111 |
40 |
1941 |
400.40 |
5.99246 |
41 |
1942 |
461.80 |
6.13513 |
42 |
1943 |
531.66 |
6.27600 |
43 |
1944 |
569.13 |
6.34411 |
44 |
1945 |
560.17 |
6.32824 |
45 |
1946 |
478.28 |
6.17020 |
46 |
1947 |
470.39 |
6.15356 |
47 |
1948 |
489.74 |
6.19387 |
48 |
1949 |
492.24 |
6.19897 |
49 |
1950 |
534.57 |
6.28146 |
50 |
1951 |
579.17 |
6.36160 |
51 |
1952 |
600.63 |
6.39798 |
52 |
1953 |
623.46 |
6.43528 |
53 |
1954 |
615.64 |
6.42266 |
54 |
1955 |
657.37 |
6.48825 |
55 |
1956 |
671.72 |
6.50984 |
56 |
1957 |
683.57 |
6.52733 |
57 |
1958 |
680.88 |
6.52339 |
58 |
1959 |
721.72 |
6.58164 |
59 |
1960 |
737.01 |
6.60260 |
60 |
1961 |
756.59 |
6.62882 |
61 |
1962 |
800.29 |
6.68497 |
62 |
1963 |
832.20 |
6.72407 |
63 |
1964 |
875.96 |
6.77532 |
64 |
1965 |
929.00 |
6.83411 |
65 |
1966 |
984.62 |
6.89226 |
66 |
1967 |
1011.38 |
6.91907 |
67 |
1968 |
1058.06 |
6.96419 |
68 |
1969 |
1087.58 |
6.99171 |
69 |
1970 |
1085.58 |
6.98987 |
70 |
1971 |
1122.42 |
7.02324 |
71 |
1972 |
1185.92 |
7.07827 |
72 |
1973 |
1254.20 |
7.13425 |
73 |
1974 |
. |
. |
74 |
1975 |
. |
. |
75 |
1976 |
. |
. |
76 |
1977 |
. |
. |
77 |
1978 |
. |
. |
78 |
1979 |
. |
. |
79 |
1980 |
. |
. |
80 |
1981 |
. |
. |
81 |
1982 |
. |
. |
82 |
1983 |
. |
. |
83 |
|
The following PROC AUTOREG code specifies a regression model with AR(2) error process. The NLAG=2 option specifies the order of AR error process. The METHOD=ML option specifies that the maximum likelihood estimation method is to be used. The OUTEST=EST option saves the parameter estimates to a data set named EST which will be used in a subsequent DATA step to replicate the predicted values produced by PROC AUTOREG. The OUTPUT statement saves the predicted values and structural residuals to a data set named B. The PM= option names the variable containing the structural predictions. The P= option names the variable containing the predicted values that incorporate both the structural model and the AR error process. The RM= option names the variable containing the structural residuals.
proc autoreg data=gnp outest=est;
model y = t / nlag=2 method=ml;
output out=b p=py rm=r pm=pm;
run;
These statements display the data set containing the parameter estimates.
proc print data=est label noobs;
run;
|
PARM |
0 Converged |
y |
ML |
|
.003369253 |
0.23248 |
4.82694 |
-1 |
0.029974 |
-1.21087 |
0.38254 |
|
The following DATA step computes the predicted values. The RETAIN statement initializes the lagged residuals to be zero. The structural predictions, YHAT, are computed using the estimated intercept and the estimated parameter on the independent variable, T. In order to compute vt|t-1, the lagged residuals, vt-1, vt-2,..., vt-m, are obtained as the observed Y minus the structural predictions, YHAT. When V at a specific lag cannot be obtained due to missing Y, a minimum variance predictor, VHAT, is used which is obtained using the estimated AR parameters and the available lagged residuals. Note the negative signs in front of the AR parameters, _A_1, and _A_2, in the equation for computing VHAT. The final predictions, PREDY, are computed using the structural predictions plus the predictions on the error term vt|t-1. The variable DIFF is created to compare the predicted values computed in the DATA step, PREDY, with those obtained from the OUTPUT statement in PROC AUTOREG, PY.
data predict;
retain vl1 vl2 0;
if _n_ = 1 then set est(rename=(t=beta));
set b;
yhat = intercept + beta * t;
v = y - yhat;
vhat = -_a_1 * vl1 - _a_2 * vl2;
if v = . then v = vhat;
predy = intercept + beta * t - _a_1 * vl1 - _a_2 * vl2;
diff = py - predy;
diff = round(diff , .00000001);
output;
vl2 = vl1;
vl1 = v;
run;
The following statements compare the predicted values computed in the DATA step with those computed by PROC AUTOREG. The values of DIFF show that the DATA step produced predicted values identical to those from PROC AUTOREG except for the first NLAG=2 observations as explained above.
proc print data=predict noobs;
var y py predy diff pm yhat v r vhat;
run;
4.92631 |
4.85691 |
4.85691 |
0.000000 |
4.85691 |
4.85691 |
0.06940 |
0.06940 |
0.00000 |
4.93541 |
4.94767 |
4.97092 |
-0.023252 |
4.88688 |
4.88688 |
0.04853 |
0.04853 |
0.08404 |
4.98429 |
4.94907 |
4.94907 |
0.000000 |
4.91686 |
4.91686 |
0.06743 |
0.06743 |
0.03221 |
4.97127 |
5.00992 |
5.00992 |
0.000000 |
4.94683 |
4.94683 |
0.02444 |
0.02444 |
0.06309 |
5.04368 |
4.98060 |
4.98060 |
0.000000 |
4.97680 |
4.97680 |
0.06688 |
0.06688 |
0.00380 |
5.15312 |
5.07841 |
5.07841 |
0.000000 |
5.00678 |
5.00678 |
0.14634 |
0.14634 |
0.07163 |
5.16827 |
5.18837 |
5.18837 |
0.000000 |
5.03675 |
5.03675 |
0.13151 |
0.13151 |
0.15162 |
5.08277 |
5.16999 |
5.16999 |
0.000000 |
5.06673 |
5.06673 |
0.01604 |
0.01604 |
0.10327 |
5.19811 |
5.06582 |
5.06582 |
0.000000 |
5.09670 |
5.09670 |
0.10141 |
0.10141 |
-0.03088 |
5.22564 |
5.24333 |
5.24333 |
0.000000 |
5.12667 |
5.12667 |
0.09897 |
0.09897 |
0.11666 |
5.25697 |
5.23769 |
5.23769 |
0.000000 |
5.15665 |
5.15665 |
0.10033 |
0.10033 |
0.08104 |
5.30584 |
5.27025 |
5.27025 |
0.000000 |
5.18662 |
5.18662 |
0.11922 |
0.11922 |
0.08363 |
5.31508 |
5.32257 |
5.32257 |
0.000000 |
5.21659 |
5.21659 |
0.09848 |
0.09848 |
0.10598 |
5.27791 |
5.32021 |
5.32021 |
0.000000 |
5.24657 |
5.24657 |
0.03134 |
0.03134 |
0.07364 |
5.26595 |
5.27682 |
5.27682 |
0.000000 |
5.27654 |
5.27654 |
-0.01059 |
-0.01059 |
0.00028 |
5.33845 |
5.28170 |
5.28170 |
0.000000 |
5.30652 |
5.30652 |
0.03194 |
0.03194 |
-0.02482 |
5.35389 |
5.37921 |
5.37921 |
0.000000 |
5.33649 |
5.33649 |
0.01741 |
0.01741 |
0.04272 |
5.49852 |
5.37532 |
5.37532 |
0.000000 |
5.36646 |
5.36646 |
0.13206 |
0.13206 |
0.00886 |
5.43368 |
5.54968 |
5.54968 |
0.000000 |
5.39644 |
5.39644 |
0.03724 |
0.03724 |
0.15325 |
5.36700 |
5.42099 |
5.42099 |
0.000000 |
5.42641 |
5.42641 |
-0.05941 |
-0.05941 |
-0.00542 |
5.29802 |
5.37020 |
5.37020 |
0.000000 |
5.45638 |
5.45638 |
-0.15837 |
-0.15837 |
-0.08618 |
5.43608 |
5.31732 |
5.31732 |
0.000000 |
5.48636 |
5.48636 |
-0.05028 |
-0.05028 |
-0.16904 |
5.53769 |
5.51603 |
5.51603 |
0.000000 |
5.51633 |
5.51633 |
0.02136 |
0.02136 |
-0.00030 |
5.54670 |
5.59140 |
5.59140 |
0.000000 |
5.54631 |
5.54631 |
0.00039 |
0.00039 |
0.04510 |
5.62051 |
5.56859 |
5.56859 |
0.000000 |
5.57628 |
5.57628 |
0.04423 |
0.04423 |
-0.00769 |
5.67610 |
5.65966 |
5.65966 |
0.000000 |
5.60625 |
5.60625 |
0.06985 |
0.06985 |
0.05341 |
5.68109 |
5.70389 |
5.70389 |
0.000000 |
5.63623 |
5.63623 |
0.04487 |
0.04487 |
0.06766 |
5.69110 |
5.69381 |
5.69381 |
0.000000 |
5.66620 |
5.66620 |
0.02490 |
0.02490 |
0.02761 |
5.75476 |
5.70916 |
5.70916 |
0.000000 |
5.69617 |
5.69617 |
0.05859 |
0.05859 |
0.01299 |
5.65431 |
5.78756 |
5.78756 |
0.000000 |
5.72615 |
5.72615 |
-0.07184 |
-0.07184 |
0.06142 |
5.57390 |
5.64673 |
5.64673 |
0.000000 |
5.75612 |
5.75612 |
-0.18222 |
-0.18222 |
-0.10940 |
5.42513 |
5.59293 |
5.59293 |
0.000000 |
5.78609 |
5.78609 |
-0.36097 |
-0.36097 |
-0.19316 |
5.40326 |
5.44869 |
5.44869 |
0.000000 |
5.81607 |
5.81607 |
-0.41281 |
-0.41281 |
-0.36738 |
5.47684 |
5.48427 |
5.48427 |
0.000000 |
5.84604 |
5.84604 |
-0.36920 |
-0.36920 |
-0.36177 |
5.56084 |
5.58688 |
5.58688 |
0.000000 |
5.87602 |
5.87602 |
-0.31518 |
-0.31518 |
-0.28914 |
5.68880 |
5.66558 |
5.66558 |
0.000000 |
5.90599 |
5.90599 |
-0.21719 |
-0.21719 |
-0.24041 |
5.73709 |
5.79355 |
5.79355 |
0.000000 |
5.93596 |
5.93596 |
-0.19888 |
-0.19888 |
-0.14241 |
5.69289 |
5.80821 |
5.80821 |
0.000000 |
5.96594 |
5.96594 |
-0.27305 |
-0.27305 |
-0.15773 |
5.76779 |
5.74136 |
5.74136 |
0.000000 |
5.99591 |
5.99591 |
-0.22812 |
-0.22812 |
-0.25455 |
5.84111 |
5.85411 |
5.85411 |
0.000000 |
6.02588 |
6.02588 |
-0.18478 |
-0.18478 |
-0.17177 |
5.99246 |
5.91938 |
5.91938 |
0.000000 |
6.05586 |
6.05586 |
-0.06339 |
-0.06339 |
-0.13648 |
6.13513 |
6.07975 |
6.07975 |
0.000000 |
6.08583 |
6.08583 |
0.04930 |
0.04930 |
-0.00608 |
6.27600 |
6.19975 |
6.19975 |
0.000000 |
6.11581 |
6.11581 |
0.16020 |
0.16020 |
0.08395 |
6.34411 |
6.32090 |
6.32090 |
0.000000 |
6.14578 |
6.14578 |
0.19833 |
0.19833 |
0.17512 |
6.32824 |
6.35462 |
6.35462 |
0.000000 |
6.17575 |
6.17575 |
0.15249 |
0.15249 |
0.17887 |
6.17020 |
6.31450 |
6.31450 |
0.000000 |
6.20573 |
6.20573 |
-0.03553 |
-0.03553 |
0.10877 |
6.15356 |
6.13435 |
6.13435 |
0.000000 |
6.23570 |
6.23570 |
-0.08214 |
-0.08214 |
-0.10136 |
6.19387 |
6.17981 |
6.17981 |
0.000000 |
6.26567 |
6.26567 |
-0.07180 |
-0.07180 |
-0.08587 |
6.19897 |
6.24013 |
6.24013 |
0.000000 |
6.29565 |
6.29565 |
-0.09668 |
-0.09668 |
-0.05552 |
6.28146 |
6.23602 |
6.23602 |
0.000000 |
6.32562 |
6.32562 |
-0.04416 |
-0.04416 |
-0.08960 |
6.36160 |
6.33911 |
6.33911 |
0.000000 |
6.35560 |
6.35560 |
0.00600 |
0.00600 |
-0.01649 |
6.39798 |
6.40973 |
6.40973 |
0.000000 |
6.38557 |
6.38557 |
0.01241 |
0.01241 |
0.02416 |
6.43528 |
6.42827 |
6.42827 |
0.000000 |
6.41554 |
6.41554 |
0.01974 |
0.01974 |
0.01273 |
6.42266 |
6.46467 |
6.46467 |
0.000000 |
6.44552 |
6.44552 |
-0.02285 |
-0.02285 |
0.01916 |
6.48825 |
6.44026 |
6.44026 |
0.000000 |
6.47549 |
6.47549 |
0.01276 |
0.01276 |
-0.03523 |
6.50984 |
6.52965 |
6.52965 |
0.000000 |
6.50546 |
6.50546 |
0.00438 |
0.00438 |
0.02419 |
6.52733 |
6.53586 |
6.53586 |
0.000000 |
6.53544 |
6.53544 |
-0.00811 |
-0.00811 |
0.00042 |
6.52339 |
6.55392 |
6.55392 |
0.000000 |
6.56541 |
6.56541 |
-0.04203 |
-0.04203 |
-0.01149 |
6.58164 |
6.54760 |
6.54760 |
0.000000 |
6.59539 |
6.59539 |
-0.01375 |
-0.01375 |
-0.04779 |
6.60260 |
6.62479 |
6.62479 |
0.000000 |
6.62536 |
6.62536 |
-0.02276 |
-0.02276 |
-0.00057 |
6.62882 |
6.63304 |
6.63304 |
0.000000 |
6.65533 |
6.65533 |
-0.02651 |
-0.02651 |
-0.02230 |
6.68497 |
6.66191 |
6.66191 |
0.000000 |
6.68531 |
6.68531 |
-0.00033 |
-0.00033 |
-0.02340 |
6.72407 |
6.72502 |
6.72502 |
0.000000 |
6.71528 |
6.71528 |
0.00879 |
0.00879 |
0.00974 |
6.77532 |
6.75603 |
6.75603 |
0.000000 |
6.74525 |
6.74525 |
0.03007 |
0.03007 |
0.01077 |
6.83411 |
6.80827 |
6.80827 |
0.000000 |
6.77523 |
6.77523 |
0.05888 |
0.05888 |
0.03304 |
6.89226 |
6.86500 |
6.86500 |
0.000000 |
6.80520 |
6.80520 |
0.08705 |
0.08705 |
0.05980 |
6.91907 |
6.91806 |
6.91806 |
0.000000 |
6.83518 |
6.83518 |
0.08390 |
0.08390 |
0.08289 |
6.96419 |
6.93343 |
6.93343 |
0.000000 |
6.86515 |
6.86515 |
0.09904 |
0.09904 |
0.06828 |
6.99171 |
6.98296 |
6.98296 |
0.000000 |
6.89512 |
6.89512 |
0.09659 |
0.09659 |
0.08783 |
6.98987 |
7.00416 |
7.00416 |
0.000000 |
6.92510 |
6.92510 |
0.06477 |
0.06477 |
0.07907 |
7.02324 |
6.99655 |
6.99655 |
0.000000 |
6.95507 |
6.95507 |
0.06817 |
0.06817 |
0.04148 |
7.07827 |
7.04281 |
7.04281 |
0.000000 |
6.98504 |
6.98504 |
0.09323 |
0.09323 |
0.05777 |
7.13425 |
7.10183 |
7.10183 |
0.000000 |
7.01502 |
7.01502 |
0.11924 |
0.11924 |
0.08681 |
. |
7.15371 |
7.15371 |
0.000000 |
7.04499 |
7.04499 |
0.10871 |
. |
0.10871 |
. |
7.16099 |
7.16099 |
0.000000 |
7.07497 |
7.07497 |
0.08603 |
. |
0.08603 |
. |
7.16752 |
7.16752 |
0.000000 |
7.10494 |
7.10494 |
0.06258 |
. |
0.06258 |
. |
7.17778 |
7.17778 |
0.000000 |
7.13491 |
7.13491 |
0.04287 |
. |
0.04287 |
. |
7.19285 |
7.19285 |
0.000000 |
7.16489 |
7.16489 |
0.02797 |
. |
0.02797 |
. |
7.21233 |
7.21233 |
0.000000 |
7.19486 |
7.19486 |
0.01747 |
. |
0.01747 |
. |
7.23528 |
7.23528 |
0.000000 |
7.22483 |
7.22483 |
0.01045 |
. |
0.01045 |
. |
7.26078 |
7.26078 |
0.000000 |
7.25481 |
7.25481 |
0.00597 |
. |
0.00597 |
. |
7.28802 |
7.28802 |
0.000000 |
7.28478 |
7.28478 |
0.00323 |
. |
0.00323 |
. |
7.31639 |
7.31639 |
0.000000 |
7.31476 |
7.31476 |
0.00163 |
. |
0.00163 |
|
Operating System and Release Information
SAS System | SAS/ETS | z/OS | | |
OpenVMS VAX | | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | | |
Microsoft Windows XP 64-bit Edition | | |
Microsoft® Windows® for x64 | | |
OS/2 | | |
Microsoft Windows 95/98 | | |
Microsoft Windows 2000 Advanced Server | | |
Microsoft Windows 2000 Datacenter Server | | |
Microsoft Windows 2000 Server | | |
Microsoft Windows 2000 Professional | | |
Microsoft Windows NT Workstation | | |
Microsoft Windows Server 2003 Datacenter Edition | | |
Microsoft Windows Server 2003 Enterprise Edition | | |
Microsoft Windows Server 2003 Standard Edition | | |
Microsoft Windows Server 2003 for x64 | | |
Microsoft Windows Server 2008 | | |
Microsoft Windows Server 2008 for x64 | | |
Microsoft Windows XP Professional | | |
Windows 7 Enterprise 32 bit | | |
Windows 7 Enterprise x64 | | |
Windows 7 Home Premium 32 bit | | |
Windows 7 Home Premium x64 | | |
Windows 7 Professional 32 bit | | |
Windows 7 Professional x64 | | |
Windows 7 Ultimate 32 bit | | |
Windows 7 Ultimate x64 | | |
Windows Millennium Edition (Me) | | |
Windows Vista | | |
Windows Vista for x64 | | |
64-bit Enabled AIX | | |
64-bit Enabled HP-UX | | |
64-bit Enabled Solaris | | |
ABI+ for Intel Architecture | | |
AIX | | |
HP-UX | | |
HP-UX IPF | | |
IRIX | | |
Linux | | |
Linux for x64 | | |
Linux on Itanium | | |
OpenVMS Alpha | | |
OpenVMS on HP Integrity | | |
Solaris | | |
Solaris for x64 | | |
Tru64 UNIX | | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.