I need to do a rolling estimation of a GARCH(1,1) and TGARCH(1,1,1), outputting 1-day ahead forecast for the conditional variance and then calculate 1-day ahead forecast for the Value at Risk.
I have 1254 observations a need a rolling window of 500. Therefor the first estimated GARCH should be based on observation 1 through 500, outputting a forecasted conditional variance for observation 501. Hereafter a new estimation based on 2 through 501, forecasting a conditional variance for observation 503 etc etc.
For the Value at Risk without GARCH/TGARCH Model I use the following code:
Code: Select all
smpl 06/12/2007 26/11/2010
matrix Portfoliowert_oos=@convert(PORTFOLIO)
smpl 06/12/2007 25/11/2010
matrix Portfoliowert_oos_1=@convert(PORTFOLIO)
smpl 07/12/2007 26/11/2010
matrix Portfoliowert_oos_2=@convert(PORTFOLIO)
matrix verlust=-1*(Portfoliowert_oos_2-Portfoliowert_oos_1)
!window=500
!length=@obsrange
matrix(!length-!window+1,1) movstd
for !i=1 to !length-!window
smpl @first+!i-1 @first+!i+!window-2
movstd(!i,1)=@stdev(portfolio_rendite)
vector(!i) t
t=@qnorm(0.01)
vector(!i) s
s=1
matrix(!length-!window,1) v_a_r
v_a_r(!i,1)=Portfoliowert_oos(!i,1)*(s(!i)-exp(movstd(!i,1)*t(!i)))
matrix(!length-!window,2) hh
hh(!i,1)=v_a_r(!i,1)
hh(!i,2)=verlust(!i,1)
next
In the next step I want make just the same, but now I want to use the condition variance estimated with GARCH and later with TGARCH model.
For the estimation conditional variance GARCH(1,1) Model, I wrote following code, but it doesn't work
Code: Select all
!window=500
!length=@obsrange
for !i=1 to !length-!window+1
smpl @first+!i-1 @first+!i+!window-2
equation arch!i.arch(1,1) portfolio_rendite
arch!i.makegarch garchvar
next