(* PS10-11, using DATA10-1, for the VAR Example 10.9 *)
lags r M D
(* Set sample range for the estimation *)
smpl 1964.1 1988.4
(* Estimate the model for interest rate *)
ols r const r_1 r_2 r_3 r_4 M_1 M_2 M_3 M_4 D_1 D_2 D_3 D_4
(* Forecast out of sample for 1989,1-1991.2 *)
fcast 1989.1 1991.2 rhat1
(* Omit variables with insignificant coefficients, one at a time *)
omit D_2
omit D_3
omit D_1
omit M_4
omit M_3
omit M_2
(* forecast again for final model and generate mean absolute % errors *)
fcast 1989.1 1991.2 rhat2
smpl 1989.1 1991.2
genr aper1 = 100*abs(r-rhat1)/r
genr aper2 = 100*abs(r-rhat2)/r
genr maper1 = mean(aper1)
genr maper2 = mean(aper2)
print maper1 maper2
(* reset sample range and repeat process for money supply *)
smpl 1964.1 1988.4
ols M const r_1 r_2 r_3 r_4 M_1 M_2 M_3 M_4 D_1 D_2 D_3 D_4
fcast 1989.1 1991.2 Mhat1
omit M_3
omit D_2
omit D_4
omit r_3
omit r_4
fcast 1989.1 1991.2 Mhat2
smpl 1989.1 1991.2
genr apeM1 = 100*abs(M-Mhat1)/M
genr apeM2 = 100*abs(M-Mhat2)/M
genr mapeM1 = mean(apeM1)
genr mapeM2 = mean(apeM2)
print mapeM1 mapeM2
(* reset sample range and repeat process for the deficit *)
smpl 1964.1 1988.4
ols D const r_1 r_2 r_3 r_4 M_1 M_2 M_3 M_4 D_1 D_2 D_3 D_4
fcast 1989.1 1991.2 Dhat1
omit r_2
omit D_4
omit M_2
omit r_4
omit M_4
omit M_1
omit M_3
omit r_1
fcast 1989.1 1991.2 Dhat2
smpl 1989.1 1991.2
genr apeD1 = 100*abs(D-Dhat1)/D
genr apeD2 = 100*abs(D-Dhat2)/D
genr mapeD1 = mean(apeD1)
genr mapeD2 = mean(apeD2)
print mapeD1 mapeD2
