I am trying to forecast the volatility as conditional standard deviation via the TGARCH model and want to use the extended window to obtain the in-sample forecast. I have data from Jan1960 till Mar2012, and I want to use a sample from Jan1960 - Dec1993 for estimating TGARCH model and being making one month ahead predictions for Jan1994, and then expand the sample one month i.e., Jan1960-Jan1994 to get the one month ahead prediction for Feb1994 and repeat this until the sample exhausted Mar2012. this will generate the volatility forecasting for Jan1994-Mar2012.
I saw this post for out of sample recursive one step ahead volatility forecasting via GARCH. and I used it but I am getting only the forecast mean and not the conditional variance/se.
Please can you advise - if this is the right code to follow for my case and how I cant get the conditional variance forecast?
viewtopic.php?f=5&t=17937&p=56704&hilit=recursive+volatility+forecasting#p56704
Code: Select all
'run rolling regression
' set window size
!window = 360
' set step size
!step = 1
' get size of workfile
!length = @obsrange
' declare equation for estimation
equation garcheqn
'calculate number of rolls
!nrolls = @floor((!length-!window)/!step)
'series to store forecast estimates
series fcast
'*EDITED: catching start and end points
%start = "@FIRST" '@otod(@ifirst(ser))
%end = "@LAST" '@otod(@ilast(ser))
'variable keeping track of how many rolls we've done
!j=0
' move sample !step obs at a time
for !i = 1 to !length-!window+1-!step step !step
!j=!j+1
' set sample for estimation period
%first = @otod(@dtoo(%start))
%last = @otod(@dtoo(%start)+!i+!window-2)
smpl {%first} {%last}
' estimate equation - where the equation is 'GARCH = C(4) + C(5)*RESID(-1)^2 + C(6)*GARCH(-1) + C(7)*GARCH(-2)
garcheqn.ARCH defsprd_var1 c ar(1) ma(1)
' 1-period-ahead forecast
%1pers = @otod(@dtoo(%start)+!i+!window-1) 'start point
%1pere = @otod(@dtoo(%start)+!i+!window-1) 'end point
'*EDITED
if @dtoo(%end) < @dtoo(%1pere) then 'check whether the forecast end point is greater than the workfile end point
exitloop
endif
' set smpl for forecasting period
smpl {%1pers} {%1pere}
' forecast with command *forecast* (see also *fit*)
garcheqn.forecast(f=na) yf
' set sampl to obtain the 4th period observation
smpl {%1pere} {%1pere}
' store forecasts
fcast = yf
next
smpl @all
show fcast.line
d(noerr) yf