## CHECK GJR-GARCH ROLLING WINDOW CODING

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

sharoneviews16
Posts: 1
Joined: Wed Jul 19, 2017 8:34 am

### CHECK GJR-GARCH ROLLING WINDOW CODING

Good evening all,

I created the following code for forecasting volatility with the GJR-GARCH model:
In total I have 4351 observations on the S&P500 and I use a rolling window of 1000 obs.

'GJR-GARCH
scalar noobs=4351
scalar nw=1000
matrix (4351, 252) gjr_garchforecast
vector(252) forecastresult

for !i=nw to noobs
smpl @first+!i-nw @first+!i-1
equation garch_gjr
garch_gjr.arch(1,1,t,) return_sp500 c
garch_gjr.makegarch garchcondvar

for !j=1 to 252
if !j=1 then
forecastresult(1)=garch_gjr.@coefs(2)+garch_gjr.@coefs(3)*resid(!i)^2+garch_gjr.@coefs(4)*resid(!i)^2*(resid(!i)<0)+garch_gjr.@coefs(5)*garchcondvar(!i)
endif

if !j>1 then
forecastresult(!j)=garch_gjr.@coefs(2)+garch_gjr.@coefs(3)*(forecastresult(!j-1))+garch_gjr.@coefs(4)*(forecastresult(!j-1))*(forecastresult(!j-1)<0)+garch_gjr.@coefs(5)*(forecastresult(!j-1))
endif

next !j
rowplace(gjr_garchforecast, @transpose(forecastresult),!i)

next !i

But I have my doubts about whether this is correct. I'm struggling with when to use 'forecastresult' and 'garchconvar'.
So if someone has improvements please let me know.