Computing predicted values in PROC AUTOREG


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; 

 

 

datexyt
1901137.874.926311
1902139.134.935412
1903146.104.984293
1904144.214.971274
1905155.045.043685
1906172.975.153126
1907175.615.168277
1908161.225.082778
1909180.935.198119
1910185.985.2256410
1911191.905.2569711
1912201.515.3058412
1913203.385.3150813
1914195.965.2779114
1915193.635.2659515
1916208.195.3384516
1917211.435.3538917
1918244.335.4985218
1919228.995.4336819
1920214.225.3670020
1921199.945.2980221
1922229.545.4360822
1923254.095.5376923
1924256.395.5467024
1925276.035.6205125
1926291.815.6761026
1927293.275.6810927
1928296.225.6911028
1929315.695.7547629
1930285.525.6543130
1931263.465.5739031
1932227.045.4251332
1933222.135.4032633
1934239.095.4768434
1935260.045.5608435
1936295.545.6888036
1937310.165.7370937
1938296.755.6928938
1939319.835.7677939
1940344.165.8411140
1941400.405.9924641
1942461.806.1351342
1943531.666.2760043
1944569.136.3441144
1945560.176.3282445
1946478.286.1702046
1947470.396.1535647
1948489.746.1938748
1949492.246.1989749
1950534.576.2814650
1951579.176.3616051
1952600.636.3979852
1953623.466.4352853
1954615.646.4226654
1955657.376.4882555
1956671.726.5098456
1957683.576.5273357
1958680.886.5233958
1959721.726.5816459
1960737.016.6026060
1961756.596.6288261
1962800.296.6849762
1963832.206.7240763
1964875.966.7753264
1965929.006.8341165
1966984.626.8922666
19671011.386.9190767
19681058.066.9641968
19691087.586.9917169
19701085.586.9898770
19711122.427.0232471
19721185.927.0782772
19731254.207.1342573
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; 

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;

 

 

ypypredydiffpmyhatvrvhat
4.926314.856914.856910.0000004.856914.856910.069400.069400.00000
4.935414.947674.97092-0.0232524.886884.886880.048530.048530.08404
4.984294.949074.949070.0000004.916864.916860.067430.067430.03221
4.971275.009925.009920.0000004.946834.946830.024440.024440.06309
5.043684.980604.980600.0000004.976804.976800.066880.066880.00380
5.153125.078415.078410.0000005.006785.006780.146340.146340.07163
5.168275.188375.188370.0000005.036755.036750.131510.131510.15162
5.082775.169995.169990.0000005.066735.066730.016040.016040.10327
5.198115.065825.065820.0000005.096705.096700.101410.10141-0.03088
5.225645.243335.243330.0000005.126675.126670.098970.098970.11666
5.256975.237695.237690.0000005.156655.156650.100330.100330.08104
5.305845.270255.270250.0000005.186625.186620.119220.119220.08363
5.315085.322575.322570.0000005.216595.216590.098480.098480.10598
5.277915.320215.320210.0000005.246575.246570.031340.031340.07364
5.265955.276825.276820.0000005.276545.27654-0.01059-0.010590.00028
5.338455.281705.281700.0000005.306525.306520.031940.03194-0.02482
5.353895.379215.379210.0000005.336495.336490.017410.017410.04272
5.498525.375325.375320.0000005.366465.366460.132060.132060.00886
5.433685.549685.549680.0000005.396445.396440.037240.037240.15325
5.367005.420995.420990.0000005.426415.42641-0.05941-0.05941-0.00542
5.298025.370205.370200.0000005.456385.45638-0.15837-0.15837-0.08618
5.436085.317325.317320.0000005.486365.48636-0.05028-0.05028-0.16904
5.537695.516035.516030.0000005.516335.516330.021360.02136-0.00030
5.546705.591405.591400.0000005.546315.546310.000390.000390.04510
5.620515.568595.568590.0000005.576285.576280.044230.04423-0.00769
5.676105.659665.659660.0000005.606255.606250.069850.069850.05341
5.681095.703895.703890.0000005.636235.636230.044870.044870.06766
5.691105.693815.693810.0000005.666205.666200.024900.024900.02761
5.754765.709165.709160.0000005.696175.696170.058590.058590.01299
5.654315.787565.787560.0000005.726155.72615-0.07184-0.071840.06142
5.573905.646735.646730.0000005.756125.75612-0.18222-0.18222-0.10940
5.425135.592935.592930.0000005.786095.7