Deperately seeking rolling forecast help
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
Deperately seeking rolling forecast help
Hi,
I am having some trouble with rolling volatility forecasts.
I have a file containing 5053 observations and I have estimated volatility using the EGARCH module included in eviews over the first half of the data. Then I am trying to use that equation (eq01) to do rolling forecasts of varying lengths to the end of the data. I have attached the code I have peaced together from the forum and the sample files. I runs but the output does not appear correct. If anyone can help I would be very grateful
Thanks
E
I am having some trouble with rolling volatility forecasts.
I have a file containing 5053 observations and I have estimated volatility using the EGARCH module included in eviews over the first half of the data. Then I am trying to use that equation (eq01) to do rolling forecasts of varying lengths to the end of the data. I have attached the code I have peaced together from the forum and the sample files. I runs but the output does not appear correct. If anyone can help I would be very grateful
Thanks
E
- Attachments
-
- ukrangebase.WF1
- (332.2 KiB) Downloaded 604 times
-
- workingprognew.prg
- (724 Bytes) Downloaded 1116 times
-
EViews Esther
- EViews Developer
- Posts: 149
- Joined: Fri Sep 03, 2010 7:57 am
Re: Deperately seeking rolling forecast help
From your program, I could not clearly figure out what you are trying to do. Can you answer the following questions: do you want to obtain 1-period-ahead forecast values? Or, do you want to store coefficient estimates? The following code will do 1-period ahead forecast and save the forecast values in the series fcast and store the coefficient estimates in coefmat.
Code: Select all
' set window size
!window = 2500
' get size of workfile
!length = @obsrange
' declare equation for estimation
equation eq01
%cmnd = _this.@command 'EDIT: get the equation specification
' set step size
!step = 5
'calculate number of rolls
!nrolls = @floor((!length-!window)/!step)
'matrix to store coefficient estimates
matrix(6,!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.{%cmnd} 'estimate equation
if @lasterrnum>0 then
clearerrs
else
colplace(coefmat,eq01.@coefs,!j) 'store coefficients
' 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
Re: Deperately seeking rolling forecast help
Hi Esther,
Thanks a million for your response. I'm trying to get the forecasts and the coefficients.
Also, in the code where it says get the equation specification what should I be writing here?
Thanks
Eoin
Thanks a million for your response. I'm trying to get the forecasts and the coefficients.
Also, in the code where it says get the equation specification what should I be writing here?
Thanks
Eoin
-
EViews Esther
- EViews Developer
- Posts: 149
- Joined: Fri Sep 03, 2010 7:57 am
Re: Deperately seeking rolling forecast help
The 4th line lets you specify your equation specification, i.e.,
Please note that when you open your equation, "_this" command will recognize that you are interested in the "equation" object.
Code: Select all
%cmnd = _this.@command 'EDIT: get the equation specificationRe: Deperately seeking rolling forecast help
Thanks Esther,
I am away from my PC with eviews on it at the moment but I will try this within the hour or two
Just to clarify, if I want to specify the equation EQ01, I merely open the equation and this command will run the forecasts based on the equation or do I need to edit the line. Apologies I'm a complete novice at programming and probably asking stupid questions. Again, I greatly appreciate your help
%cmnd = _this.@command 'EDIT: get the equation specification
I am away from my PC with eviews on it at the moment but I will try this within the hour or two
Just to clarify, if I want to specify the equation EQ01, I merely open the equation and this command will run the forecasts based on the equation or do I need to edit the line. Apologies I'm a complete novice at programming and probably asking stupid questions. Again, I greatly appreciate your help
%cmnd = _this.@command 'EDIT: get the equation specification
-
EViews Esther
- EViews Developer
- Posts: 149
- Joined: Fri Sep 03, 2010 7:57 am
Re: Deperately seeking rolling forecast help
Yes, all you need to do is to open the equation of interest.
Re: Deperately seeking rolling forecast help
Esther,
You are a lifesaver. Thank you for all your help!! It's working perfectly
Eoin
You are a lifesaver. Thank you for all your help!! It's working perfectly
Eoin
Re: Deperately seeking rolling forecast help
Hello Esther,
First of all, I want to thank everyone at the Eviews team helping out on this forum.
To the main problem, I am trying to follow the posts and your suggestions in a bid to reproduce Eoin's results but I find that even after opening the eq01 on the workfile before running he code you provided, I get an error message saying :
%CMND is not defined or is an illegal command in ''CMND = _THIS.@COMMAND''
Perhaps, I'm not getting something right.
Also, I'd like to find out if this code can work for other GARCH-type models on Eviews, I am interested especially in TGARCH and GARCH-M models.
Any suggestions would be very much appreciated.
Mo'
First of all, I want to thank everyone at the Eviews team helping out on this forum.
To the main problem, I am trying to follow the posts and your suggestions in a bid to reproduce Eoin's results but I find that even after opening the eq01 on the workfile before running he code you provided, I get an error message saying :
%CMND is not defined or is an illegal command in ''CMND = _THIS.@COMMAND''
Perhaps, I'm not getting something right.
Also, I'd like to find out if this code can work for other GARCH-type models on Eviews, I am interested especially in TGARCH and GARCH-M models.
Any suggestions would be very much appreciated.
Mo'
-
EViews Esther
- EViews Developer
- Posts: 149
- Joined: Fri Sep 03, 2010 7:57 am
Re: Deperately seeking rolling forecast help
Which version of EViews are you using? If you do not have EViews7, the program will not work.
If you have EViews7, then please upload your workfile and program.
If you have EViews7, then please upload your workfile and program.
Re: Deperately seeking rolling forecast help
Dear Esther,
I have been able to confirm that the code works for Eoin's data using Eviews7. Thank you.
I would like to find out if this code can work the same way(by opening the equation on Eviews7) for a different equation, say a GARCH,TGARCH or GARCH-M?
Regards,
Mo'
I have been able to confirm that the code works for Eoin's data using Eviews7. Thank you.
I would like to find out if this code can work the same way(by opening the equation on Eviews7) for a different equation, say a GARCH,TGARCH or GARCH-M?
Regards,
Mo'
-
EViews Esther
- EViews Developer
- Posts: 149
- Joined: Fri Sep 03, 2010 7:57 am
Re: Deperately seeking rolling forecast help
Yes, it will work.
Re: Deperately seeking rolling forecast help
Thank you. I'd get on with it.
Re: Deperately seeking rolling forecast help
Esther,
thanks for your assitance thus far, I have been able to confirm that this code works, as I have compared it with simpler codes and obtained (almost) the same results for the one-period ahead static forecasts(changing to .fit,even though results look the same).
I'm a bit confused as to how to do the 5-period and 10-period ahead forecasts (i.e., forecasts for the 5-day and 10-day horizons as I am using a set of daily data). I am pretty sure it has to do with editing this part of the code(pasted below) but I am not sure about what do do. Please help.
Thanks.
thanks for your assitance thus far, I have been able to confirm that this code works, as I have compared it with simpler codes and obtained (almost) the same results for the one-period ahead static forecasts(changing to .fit,even though results look the same).
I'm a bit confused as to how to do the 5-period and 10-period ahead forecasts (i.e., forecasts for the 5-day and 10-day horizons as I am using a set of daily data). I am pretty sure it has to do with editing this part of the code(pasted below) but I am not sure about what do do. Please help.
Code: Select all
' 1-period-ahead forecast
%pers = @otod(@dtoo(%start)+!i+!window-1) 'start point
%pere = @otod(@dtoo(%start)+!i+!window-1) 'end point
-
EViews Esther
- EViews Developer
- Posts: 149
- Joined: Fri Sep 03, 2010 7:57 am
Re: Deperately seeking rolling forecast help
...how to do the 5-period and 10-period ahead forecasts
Code: Select all
' 5-period-ahead forecast
%pers = @otod(@dtoo(%start)+!i+!window-1) 'start point
%pere = @otod(@dtoo(%start)+!i+!window+4) 'end point
' 10-period-ahead forecast
%pers = @otod(@dtoo(%start)+!i+!window-1) 'start point
%pere = @otod(@dtoo(%start)+!i+!window+9) 'end point
Re: Deperately seeking rolling forecast help
Dear Eviews Esther,
I have tried to run a 5_step ahead forecast using the hint you provided and some further adjustments. But each time I try to run the code, I get an error message: Syntax error ''IF @ LAST < THEN''...I really have no idea why this keeps coming up, you've been extremely helpful, thanks in advance.
I have tried to run a 5_step ahead forecast using the hint you provided and some further adjustments. But each time I try to run the code, I get an error message: Syntax error ''IF @ LAST < THEN''...I really have no idea why this keeps coming up, you've been extremely helpful, thanks in advance.
Code: Select all
' set window size
!window =800
' get size of workfile
!length = @obsrange
' declare equation for estimation
equation eq01
%cmnd = _this.@command '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(4,!nrolls) coefmat 'where the number of coefficients is 4.
series fcast 'series to store forecast estimates
series fcastse '
series fcastvar
%start = "@first"
%end = "@last"
'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
%first = @otod(@dtoo(%start)+!i-1)
%last = @otod(@dtoo(%start)+!i+!window-2)
smpl {%first} {%last}
'estimate equation - Error catching , any errors mean we'll keep going.
!maxerr = @maxerrcount
setmaxerrs !maxerr+1
_this.{%cmnd} 'estimate equation
if @lasterrnum>0 then
clearerrs
else
colplace(coefmat,eq01.@coefs,!j) 'store coefficients
if {%end} < {%5pere} then 'check whether the forecast end point is greater than the workfile end point
return
endif
' set smpl for forecasting period
smpl {%5pers} {%5pere}
eq01.fit(f=na) r_f1 r_se r_var
' store forecasts vars
fcast = r_f1
fcastse = r_se
fcastvar = r_var
endif
next
smpl @allWho is online
Users browsing this forum: No registered users and 2 guests
