I'm not sure what I'm doing wrong. Have used the code below. I tried running it via File>New>program. I had already generated the GARCH equation and saved it. Tried modifying the code by entering my own sample dates and GARCH equation, but nothing happened.
To be frank, not sure what to modify, and what to leave out. When I try running the code and setting 5 maximum errors, I get the following errors:
Code: Select all
%END is not defined or is an illegal command in "%END = "@LAST" ".
is not defined or is an illegal command in " ".
Syntax error in control statement in "FOR !I = 1 TO 5219-20+1-1 STEP 1".Code: Select all
'run rolling regression
' set window size
!window = 20
' 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(6) + C(7)*RESID(-1)^2 + C(8)*GARCH(-1)
garcheqn.ARCH RT_ASX200 C AR(1) AR(2) MA(1) MA(2)
' 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