Iterative multistep out-of-sample forecasts using VAR

Questions and discussions on Vector Autoregressions
juffa
Posts: 3
Joined: Sat Feb 23, 2013 9:01 am

Iterative multistep out-of-sample forecasts using VAR

Unread post by juffa »

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?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Iterative multistep out-of-sample forecasts using VAR

Unread post by TomDoan »

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}
end
First of all, in RATS, leads are {-l}, not {l}, so at any rate, you would want {-1}, {-2} and {-3} in the calculation of FORDY4. However, the main problem you have is that the SET is resetting the entire range, when you only want it to do one entry (END??--not sure if you want END or END+1). One way to fix that is to restrict the range on SET, so

set 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)
end
juffa
Posts: 3
Joined: Sat Feb 23, 2013 9:01 am

Re: Iterative multistep out-of-sample forecasts using VAR

Unread post by juffa »

Dear Tom,
Now it works fine. Thank you so very much.
Post Reply