My problem:

I have 964 return observations of a stock. By a windows size=200, I want to make rolling one a head forecasts for conditional variance using GARCH(1,1) model. And I also want to estimate the model coefficients at every 25 step.

For example,

- using observations from 1 to 200, first estimate the model coefficients, then using the estimated model, I want to forecast 201'th conditional variance,

- using observations from 1 to 200, first estimate the model coefficients, then using the estimated model, I want to forecast 202'th conditional variance,

......

- using observations from 26 to 225, first estimate the model coefficients, then using the estimated model, I want to forecast 226'th conditional variance,

......

-and so on.

I wrote such a code combining pieces from other topics. However, since I couldn't still gain the insight of the Eviews programming, I could not manage to solve the problem. My not working half code is as below:

Code: Select all

`' set window size`

!window = 200

' set step size

!step = 25

' get size of workfile

!length = 964

'calculate number of rolls

!nrolls = @round((!length-!window)/!step)

' declare equation for estimation

equation eq1

'matrix to store coefficient estimates

matrix(3,!nrolls) coefmat ' where 3 is the number of coefficients

matrix(1,964) results

'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 to estimation period

smpl !i !i+!window-1

' estimate equation

equation eq1.ARCH(1,1) returnx

eq1.forecast var

rowplace(results, garch_n@ARCH(1,1), !j)

'store coefficients

colplace(coefmat,eq1.@coefs,!j)

next

I loaded the workfile as a attachment.

I will be very glad for any help. Thanks a lot.