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
|
set echo off
set messages off
/* ADL-MIDAS test examples from Eric Ghysels' MIDAS
Toolbox, using the midasreg command with high-frequency
lags predefined
*/
open gdp_midas.gdt --quiet
# form list of high-frequency log differences
list dX = ld_payems*
# and a list of their lags
list dXL = hflags(3, 11, dX)
# to collect forecasts
matrix FC = {}
# to inflect the "fcast" command
setopt fcast persist --out-of-sample --static --quiet
# estimation sample
smpl 1985:1 2009:1
print "=== U-MIDAS ==="
midasreg ld_qgdp 0 ld_qgdp(-1) ; mdsl(dXL, 0)
printf "midas coefficients:\n%10.5f\n", $model.midas_coeffs[,1]
fcast
FC ~= $fcast
print "=== beta (zero last lag) ==="
matrix theta = {1,5}
midasreg ld_qgdp 0 ld_qgdp(-1) ; mdsl(dXL, 2, theta)
printf "midas coefficients:\n%10.5f\n", $model.midas_coeffs[,1]
fcast
FC ~= $fcast
print "=== beta (non-zero last lag) ==="
theta = {1,1,0}
midasreg ld_qgdp 0 ld_qgdp(-1) ; mdsl(dXL, 3, theta)
printf "midas coefficients:\n%10.5f\n", $model.midas_coeffs[,1]
fcast
FC ~= $fcast
print "=== normalized exponential Almon ==="
theta = {0,0}
midasreg ld_qgdp 0 ld_qgdp(-1) ; mdsl(dXL, 1, theta)
printf "midas coefficients:\n%10.5f\n", $model.midas_coeffs[,1]
fcast
FC ~= $fcast
print "=== Almon polynomial ==="
theta = {0,0,0,0}
midasreg ld_qgdp 0 ld_qgdp(-1) ; mdsl(dXL, 4, theta)
printf "midas coefficients:\n%10.5f\n", $model.midas_coeffs[,1]
fcast --out-of-sample --static --quiet
FC ~= $fcast
# forecast range
smpl 2009:2 2011:2
matrix my = {ld_qgdp}
print "Forecast RMSEs:"
printf " U-MIDAS %.4f\n", fcstats(my, FC[,1])[2]
printf " Beta0 %.4f\n", fcstats(my, FC[,2])[2]
printf " BetaNZ %.4f\n", fcstats(my, FC[,3])[2]
printf " neAlmon %.4f\n", fcstats(my, FC[,4])[2]
printf " Almonp %.4f\n", fcstats(my, FC[,5])[2]
# revert to estimation sample
smpl 1985:1 2009:1
|