Could someone check my Eviews rolling forecast code?

For questions regarding programming in the EViews programming language.

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

chauhan7
Posts: 13
Joined: Sun Aug 05, 2012 5:23 am

Could someone check my Eviews rolling forecast code?

Postby chauhan7 » Sat Jan 19, 2013 4:15 am

Hi,

I am using the returns of a stock market index by examining the returns on given days of the week (monday to friday), and I would like to complete a 1 step rolling forecast (egarch with GED dist) to forecast the volatility for the last year in my sample (2011). I found a code on the eviews forum, and made some adjustments to it and it works, but I was wondering if anyone could check the code's accuracy, as the results shown in fcastvar are almost identical to the actual variances for the last year.

Here is the code:

Code: Select all

' set window size !window = 6262 ' get size of workfile !length = @obsrange ' declare equation for estimation equation eq01 _this.ARCH(egarch, ged=1.5) return 'EDIT: get the equation specification ' set step size !step = 1 'calculate number of rolls !nrolls = @floor((!length-!window)/!step) 'matrix to store coefficient estimates matrix(1,!nrolls) coefmat 'where the number of coefficients is 6. series fcast 'series to store forecast estimates series fcastse series fcastvar %start = "@first" %end = "@last" !j = 0 ' move sample !step obs at a time for !i = 1 to !length-!window+1-!step step !step !j = !j +1 %first = @otod(@dtoo(%start)+!i-1) %last = @otod(@dtoo(%start)+!i+!window-2) smpl {%first} {%last} 'estimate equation - note I'm error catching here, any errors mean we'll keep going. !maxerr = @maxerrcount setmaxerrs !maxerr+1 _this.ARCH(egarch, ged=1.5) return monday tuesday wednesday thursday friday @ monday wednesday thursday friday 'estimate equation if @lasterrnum>0 then clearerrs else ' 1-period-ahead forecast %pers = @otod(@dtoo(%start)+!i+!window-1) 'start point %pere = @otod(@dtoo(%start)+!i+!window-1) 'end point if @dtoo(%end) < @dtoo(%pere) then 'check whether the forecast end point is greater than the workfile end point exitloop endif ' set smpl for forecasting period smpl {%pers} {%pere} eq01.forecast(f=na) audf1 aud_se aud_var ' store forecasts vars fcast = audf1 fcastse = aud_se fcastvar = aud_var endif next smpl @all
I have also attached one of my workfiles for the FTSE All Share index.
Note that I am using Eviews 7 at University, and also note that I have zero knowledge of programming.
Attachments
ftseall_full.wf1
FTSE
(1.07 MiB) Downloaded 294 times

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13600
Joined: Tue Sep 16, 2008 5:38 pm

Re: Could someone check my Eviews rolling forecast code?

Postby EViews Gareth » Mon Jan 21, 2013 9:02 am

Nothing jumps out at me as being wrong.

chauhan7
Posts: 13
Joined: Sun Aug 05, 2012 5:23 am

Re: Could someone check my Eviews rolling forecast code?

Postby chauhan7 » Mon Jan 21, 2013 12:07 pm

Awesome - thanks.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests