/usr/share/gretl/scripts/ps10-11.inp is in gretl-common 2017d-3build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | # PS10-11 for the VAR Example 10.9
open data10-1
lags r M D
# define sample ranges for estimation and out-of-sample forecast
string est_range = "1964:1 1988:4"
string fc_range = "1989:1 1991:2"
# Set sample range for the estimation
smpl @est_range
# 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
smpl @fc_range
fcast --quiet
series rhat1 = $fcast
# reset estimation range
smpl @est_range
# 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
smpl @fc_range
fcast --quiet
series rhat2 = $fcast
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 @est_range
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
smpl @fc_range
fcast --quiet
series Mhat1 = $fcast
# reset estimation range
smpl @est_range
omit M_3
omit D_2
omit D_4
omit r_3
omit r_4
smpl @fc_range
fcast --quiet
series Mhat2 = $fcast
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 @est_range
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
smpl @fc_range
fcast --quiet
series Dhat1 = $fcast
# reset estimation range
smpl @est_range
omit r_2
omit D_4
omit M_2
omit r_4
omit M_4
omit M_1
omit M_3
omit r_1
smpl @fc_range
fcast --quiet
series Dhat2 = $fcast
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
|