Iterative multistep out-of-sample forecasts using VAR
Iterative multistep out-of-sample forecasts using VAR
I'd like to compare direct out-of-sample forecasts with iterated multistep out-of-sample forecasts when forecasting GDP growth four quarters ahead. More specifically, I want to forecast the annual GDP growth; dy4 = (lnY(t+4)-lnY(t))*100, using financial market variables as forecasting variables (ts, Rr, isr).
The analysis of direct (single equation) forecasts goes well, but I cant conduct correcly iterated multistep forcecasts using VAR.
Enclosed the program for VAR:
--------------------------
set dy =(log(Y/Y{1}))*100
set dy4 =(log(Y/Y{4}))*100
set ts = il - is
set spr = sp/p
set Rr =(log(spr/spr{1}))*100
set inf =(log(P/P{4}))*100
set isr = is - inf
display "VAR lag selection"
@varlagselect(lags=4,crit=sbc,model=varmodel) 1981:01 2000:02
# dy ts rr isr
*VAR forecasts recursive
SYSTEM(MODEL=UKMODEL2)
VARIABLES DY TS RR ISR
LAGS 1
DET Constant
END(SYSTEM)
ESTIMATE 1980:01 2000:01
do end=2000:01,2015:01
forecast(model=ukmodel2, results=forecasts, from=end+1, to=2015:01, steps=4)
set fordy4 = forecasts(1) + forecasts(1){1} + forecasts(1){2} + forecasts(1){3}
end
@uforeerrors dy4 fordy4 2001:01 2015:01
print 2001:1 2015:1 fordy4 dy4
------------------
The problem deals with the annual GDP growth defined in variable fordy4. The program yields a reasonable looking RMSE for fordy4, but it is not correct. During each (four quarters) loop, the forecasted annual GDP growth should be calculated, as far as I understand, as the sum of four subsequent quarterly GDP growth rates (forecasted dy(t) + forecasted dy(t-1) + forecasted dy(t-2) + forecasted dy(t-3), but I can't program this correctly. The problem is that the forecasts are overwritten by the subsequent trips through the loop.
Any ideas how to implement the analysis correctly?
The analysis of direct (single equation) forecasts goes well, but I cant conduct correcly iterated multistep forcecasts using VAR.
Enclosed the program for VAR:
--------------------------
set dy =(log(Y/Y{1}))*100
set dy4 =(log(Y/Y{4}))*100
set ts = il - is
set spr = sp/p
set Rr =(log(spr/spr{1}))*100
set inf =(log(P/P{4}))*100
set isr = is - inf
display "VAR lag selection"
@varlagselect(lags=4,crit=sbc,model=varmodel) 1981:01 2000:02
# dy ts rr isr
*VAR forecasts recursive
SYSTEM(MODEL=UKMODEL2)
VARIABLES DY TS RR ISR
LAGS 1
DET Constant
END(SYSTEM)
ESTIMATE 1980:01 2000:01
do end=2000:01,2015:01
forecast(model=ukmodel2, results=forecasts, from=end+1, to=2015:01, steps=4)
set fordy4 = forecasts(1) + forecasts(1){1} + forecasts(1){2} + forecasts(1){3}
end
@uforeerrors dy4 fordy4 2001:01 2015:01
print 2001:1 2015:1 fordy4 dy4
------------------
The problem deals with the annual GDP growth defined in variable fordy4. The program yields a reasonable looking RMSE for fordy4, but it is not correct. During each (four quarters) loop, the forecasted annual GDP growth should be calculated, as far as I understand, as the sum of four subsequent quarterly GDP growth rates (forecasted dy(t) + forecasted dy(t-1) + forecasted dy(t-2) + forecasted dy(t-3), but I can't program this correctly. The problem is that the forecasts are overwritten by the subsequent trips through the loop.
Any ideas how to implement the analysis correctly?
Re: Iterative multistep out-of-sample forecasts using VAR
Code: Select all
do end=2000:01,2015:01
forecast(model=ukmodel2, results=forecasts, from=end+1, to=2015:01, steps=4)
set fordy4 = forecasts(1) + forecasts(1){1} + forecasts(1){2} + forecasts(1){3}
endset fordy4 end end = forecasts(1) + forecasts(1){-1} + forecasts(1){-2} + forecasts(1){-3}
The other is to use COMPUTE instead since it's just one value. The most flexible way to do that is
Code: Select all
clear(zeros) fordy4
do end=2000:01,2015:01
forecast(model=ukmodel2, results=forecasts, from=end+1, to=2015:01, steps=4)
sstats end+1 end+4 forecasts(1)>>fordy4(end)
endRe: Iterative multistep out-of-sample forecasts using VAR
Dear Tom,
Now it works fine. Thank you so very much.
Now it works fine. Thank you so very much.