how to write forecast code?

For questions regarding programming in the EViews programming language.

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

wangjiangjiang
Posts: 5
Joined: Wed Aug 14, 2013 8:58 pm

how to write forecast code?

Postby wangjiangjiang » Wed Aug 14, 2013 11:04 pm

Hi guys :D

I am doing rolling GARCH to forecast the conditional variance.

I have 2000 observations and the window is 1000, roll is 100.

And I will estimate 11 windows. they are 1 1000, 101 1100, 201 1200 and so on.

each window will forecast the following 100 observations.

But I am very very new to the programming. I can only write the code to estimate the rolling GARCH model

[' set window size
!window=1000

' set step size
!step=100

' get the size of workfile
!length=@obsrange

' calculate number of rolls
!nrolls = @round((!length-!window+!step)/!step)

' variable keeping track of how many rolls we've done
!j=0

for !i = 1 to !length-!window+1 step !step
!j=!j+1

' set sample of estimation period
smpl @first+!i-1 @first+!i+!window-2

' estimate equation
equation garch_n_{!j}
garch_n_{!j}.ARCH(1,1) return c

next][/code].

I don't know how to write the forecast code into the above code. Could anybody help me or give me some information about forecasting? :D :D :D :D :D

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

Re: how to write forecast code?

Postby EViews Gareth » Thu Aug 15, 2013 6:45 am

Follow the example given by Esther in the following post:
http://forums.eviews.com/viewtopic.php?f=15&t=878

Although she is estimating using LS rather than ARCH, the forecasting bit is the same.

wangjiangjiang
Posts: 5
Joined: Wed Aug 14, 2013 8:58 pm

Re: how to write forecast code?

Postby wangjiangjiang » Fri Aug 16, 2013 10:53 pm

Follow the example given by Esther in the following post:
http://forums.eviews.com/viewtopic.php?f=15&t=878

Although she is estimating using LS rather than ARCH, the forecasting bit is the same.

Hi EViews Gareth

Could you please help me to check what the problem is with my code ?The estimation code works well but the forecast code seems to have some problems. Forecast results generated by this code are not the same as those generated by menu.

Code: Select all

' set window size !window=1000 ' set step size !step=100 ' get the size of workfile !length=@obsrange ' calculate number of rolls !nrolls = @round((!length-!window+!step)/!step) ' variable keeping track of how many rolls we've done !j=0 for !i = 1 to !length-!window+1 step !step !j=!j+1 ' set sample of estimation period smpl @first+!i-1 @first+!i+!window-2 ' estimate equation equation garch_n_{!j} garch_n_{!j}.ARCH(1,1) return c ' set forecasting period smpl @first+!i+!window-2 @first+!i+!window-2+100 garch_n_{!j}.forecast se var series forecastvar forecastvar=var next
Attachments
workfile.wf1
(92.46 KiB) Downloaded 254 times

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

Re: how to write forecast code?

Postby EViews Gareth » Sat Aug 17, 2013 1:48 pm

Code: Select all

garch_n_{!j}.forecast se var
should probably be

Code: Select all

garch_n_{!j}.forecast mean se var


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests