I noticed that there are two types of residuals and predictions calculated:
- Structural Model (first stage OLS to detrend data)
- Total Model (= Structural Model + AR Error Model)
However when examining the predictions and residuals, they don't seem to add up for the first p observations and wanted to clarify how these are calculated
For e.g. in the table below, for obs 1, the total prediction is 0, but the total residuals is -136.85 instead of -243.5 (=DURABLES - predict total)
Obs |
predict_total |
residual_total |
predict_struct |
residual_struct |
DATE |
_TYPE_ |
_LEAD_ |
DURABLES |
1 |
0 |
-136.85 |
0 |
-243.5 |
Jan-80 |
RESIDUAL |
0 |
-243.5 |
2 |
-73.87 |
5033.78 |
0 |
8460.6 |
Feb-80 |
RESIDUAL |
0 |
8460.6 |
3 |
2642.39 |
4439 |
0 |
10165.7 |
Mar-80 |
RESIDUAL |
0 |
10165.7 |
4 |
2282.5 |
708.65 |
0 |
3444.8 |
Apr-80 |
RESIDUAL |
0 |
3444.8 |
5 |
2607.48 |
-1756.04 |
0 |
-233.1 |
May-80 |
RESIDUAL |
0 |
-233.1 |
6 |
519.1 |
1444.32 |
0 |
2801 |
Jun-80 |
RESIDUAL |
0 |
2801 |
7 |
12.12 |
-5722.97 |
0 |
-7971.9 |
Jul-80 |
RESIDUAL |
0 |
-7971.9 |
8 |
906.53 |
-3244.69 |
0 |
-3507.81 |
Aug-80 |
RESIDUAL |
0 |
-3507.81 |
9 |
3172.29 |
3045.45 |
0 |
7314.29 |
Sep-80 |
RESIDUAL |
0 |
7314.29 |
10 |
1505.36 |
5866.55 |
0 |
9482.39 |
Oct-80 |
RESIDUAL |
0 |
9482.39 |
11 |
2800.77 |
1529.45 |
0 |
4860.49 |
Nov-80 |
RESIDUAL |
0 |
4860.49 |
12 |
2967.3 |
-625.37 |
0 |
2138.59 |
Dec-80 |
RESIDUAL |
0 |
2138.59 |
13 |
-3093.05 |
161.77 |
0 |
-2898.31 |
Jan-81 |
RESIDUAL |
0 |
-2898.31 |
Code to generate this was from following:
proc forecast data=sashelp.usecon interval=month
method=stepar nlags = 0 trend=2 lead=0
out=out outresid outfull outest=est;
id date;
var durables;
where date >= '1jan80'd;
run;
proc sql;
CREATE TABLE resid AS
SELECT *, 0 AS zer FROM out
WHERE _TYPE_ = 'RESIDUAL';
run;
proc autoreg data=resid;
model durables = zer/ noint nlag=(1 6 10 12 13) method=yw;
output out = autoreg_res pm = predict_struct p = predict_total rm = residual_struct r = residual_total;
run;