Rolling VAR-GARCH

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
jimdimit
Posts: 8
Joined: Thu Jan 30, 2014 2:25 am

Rolling VAR-GARCH

Unread post by jimdimit »

Dear All,

I have set up the following rolling VAR-BEKK GARCH. I want to use the first 600 return data to make some forecasts from observation 601 to 901. Although it runs fine, I am not sure if it restricts my sample to where I want to in every loop. Thank you for your time and help.

Code: Select all

*Loading Data

allocate 1000
open data C:\data\stocks.txt
data(format=free, org=col) / sp500 ftse100
source mvgarchfore.src


*return series

set rsp500 1 1000 = log(sp500)
set rftse100 1 1000 = log(ftse100)
dif rsp500 2 1000 drsp500
dif rftse100 2 1000 drftse100
compute ss = 599


*Loop

do time = 1,300

*VAR
system(model=var)
variables drsp500 drftse100
lags 1 1
end(system)
estimate(noprint, residuals=resvar) time time+ss

*GARCH
garch(noprint,robusterrors,p=1,q=1,mv=bek,variances=spillover,pmethod=simplex,hmatrices=hh,rvectors=rd) / resvar(1) resvar(2)

*SETTING SOME SERIES 
set std1 1 time+ss = hh(t)(1,1)
set std2 1 time+ss = hh(t)(2,2)
set z1 1 time+ss = rd(t) (1)
set z2 1 time+ss = rd(t) (2)
compute xx = z1(time+ss)
@MVGarchFore(steps=1) hh rd
set hfor time time = hh(time+ss+1)(2,2)
set dhh2 time time = hfor(time)-std2(time+ss)
end do 
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Rolling VAR-GARCH

Unread post by TomDoan »

You should never run something like this with "NOPRINT" options until you're sure you have everything correct. Start with a smaller range to test it.

There are several rather clear problems with this. For instance, your earliest start period is "1", but you can't run the VAR starting at entry 1 because of the lags. You're also not running a VAR-GARCH, but a VAR with a GARCH on the residuals. You can do a GARCH that does both simultaneously by using the MODEL option. You need to use the MV=BEKK option on @MVGARCHFORE if you did a MV=BEKK on the GARCH instruction.
jimdimit
Posts: 8
Joined: Thu Jan 30, 2014 2:25 am

Re: Rolling VAR-GARCH

Unread post by jimdimit »

Tom thank you for very much your helpful comments,

Return series start from 2 and end to 1000
so the inputs for the VAR(1,1) should start from 3 (i.e. time+2) (since I lose one observation from the lag) and end at the end of the subsample (time+ss)

I think that if I use the garch command with the model option I have to specify a sample or it will use all the available sample (if I don't specify a sample, all GARCH estimations in the loop have identical estimation outputs)

I have modified the code accordingly as follows:

Code: Select all

*Loading Data

allocate 1000
open data C:\data\stocks.txt
data(format=free, org=col) / sp500 ftse100
source mvgarchfore.src


*return series

set rsp500 1 1000 = log(sp500)
set rftse100 1 1000 = log(ftse100)
dif rsp500 2 1000 drsp500
dif rftse100 2 1000 drftse100
compute ss = 599


*Loop

do time = 1,300

*VAR
system(model=var)
variables drsp500 drftse100
lags 1 1
end(system)
estimate time+2 time+ss

*GARCH
garch(robusterrors,p=1,q=1,mv=bek,variances=spillover,pmethod=simplex,hmatrices=hh,rvectors=rd) time+3 time+ss

*SETTING SOME SERIES 
set std1 1 time+ss = hh(t)(1,1)
set std2 1 time+ss = hh(t)(2,2)
set z1 1 time+ss = rd(t) (1)
set z2 1 time+ss = rd(t) (2)
compute xx = z1(time+ss)
@MVGarchFore(MV=BEKK,steps=1) hh rd
set hfor time time = hh(time+ss+1)(2,2)
set dhh2 time time = hfor(time)-std2(time+ss)
end do
I would like to ask, if I just use 1 as start for the VAR when in fact my sample starts from 3, how would rats treat my series? I mean is it different for rats to 'read' Nans instead of specifying for it a sample without the Nans that starts from say the 3-rd observation? or we set a usable sample without Nans so that we don't run into errors in the (garch) estimation?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Rolling VAR-GARCH

Unread post by TomDoan »

Because GARCH can't accept missing values inside the sample (since those would break the recursion), you have to be careful not to give it a range that includes NA's.
Post Reply