Page 2 of 5
Re: Multi-step ahead forecast
Posted: Wed Jan 29, 2014 2:48 pm
by Nas1
You have 7.
I just tried 7, and I got the same results of zero coefmat.
Re: Multi-step ahead forecast
Posted: Wed Jan 29, 2014 3:05 pm
by EViews Gareth
Works for me.
Re: Multi-step ahead forecast
Posted: Wed Jan 29, 2014 3:18 pm
by Nas1
Thank you Gareth, May you please suggest why I am getting this coefmat for the same file that I uploaded??
Re: Multi-step ahead forecast
Posted: Wed Jan 29, 2014 3:20 pm
by EViews Gareth
Hard to say what you're doing wrong.
Re: Multi-step ahead forecast
Posted: Wed Jan 29, 2014 3:27 pm
by Nas1
Hard to say what you're doing wrong.
I tried the codes on my original working file and I got the same zero coefmat. Do you think there is something wrong in the codes?? do you think that this an indication for a bad quality for the results?
Re: Multi-step ahead forecast
Posted: Wed Jan 29, 2014 3:28 pm
by EViews Gareth
The code I have (which is the code you last posted, but changing the number of coefficients to 7) doesn't give zeros, and appears to work fine.
Code: Select all
' set window size
!window = 142
' set step size
' declare equation for estimation
equation eq01
' get size of workfile
!length = @obsrange
%cmnd = _this.@command 'EDIT: get the equation specification stored in eviews
!step = 4
'calculate number of rolls
!nrolls = @floor((!length-!window)/!step)
'matrix to store coefficient estimates
matrix(7,!nrolls) coefmat ' where 3 is the number of coefficients
'series to store forecast estimates
series fcast
'redundant series for 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 -recursive window
%first = @otod(@dtoo(%start))
%last = @otod(@dtoo(%start)+!i+!window-1)
smpl {%first} {%last}
' estimate equation -
!maxerr = @maxerrcount
setmaxerrs !maxerr+1
_this.{%cmnd} 'estimated equation
colplace(coefmat,eq01.@coefs,!j) 'store coefficients
' 4-period-ahead forecast
%4pers = @otod(@dtoo(%start)+!i+!window-1) 'start point
%4pere = @otod(@dtoo(%start)+!i+!window+3) 'end point
if @dtoo(%end) < @dtoo(%4pere) then 'check whether the forecast end point is greater than the workfile end point
exitloop
endif
' set smpl for forecasting period
smpl {%4pers} {%4pere}
' forecast with command *forecast* (see also *fit*)
eq01.forecast(f=na) yf
' set sampl to obtain the 4th period observation
smpl {%4pere} {%4pere}
' store forecasts
fcast = yf
next
smpl @all
show coefmat
show fcast.line
d(noerr) yf
'calculate RMSE
scalar rmse=@rmse(y, fcast)
' plot actual and recursive forecasts
graph graph1.line y fcast
graph1.addtext(t) forecast
show graph1
Re: Multi-step ahead forecast
Posted: Wed Jan 29, 2014 3:50 pm
by Nas1
thank you Gareth for your support, i will re-examine everything again, at least the codes are correct :)
Re: Multi-step ahead forecast
Posted: Mon Feb 03, 2014 3:20 pm
by Nas1
Dear Gareth,
while I am running the same code discussed above, when I identify an AR(p) process, similar to Hamilton Markov switching model, the AR(p) process change automatically from the list of non-switching regressors to switching regressor. why this is happening?
best regards,
'run rolling regression
' set window size
!window = 60
' set step size
' declare equation for estimation
equation eq01
' get size of workfile
!length = @obsrange
%cmnd = _this.@command 'EDIT: get the equation specification stored in eviews
!step = 1
'calculate number of rolls
!nrolls = @floor((!length-!window)/!step)
'matrix to store coefficient estimates
matrix(19,!nrolls) coefmat ' where 9 is the number of coefficients ( for each (variable+ constant)* number of regimes + probability regressor)
'series to store forecast estimates
series fcast
'redundant series for 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 -recursive window
%first = @otod(@dtoo(%start))
%last = @otod(@dtoo(%start)+!i+!window-1)
smpl {%first} {%last}
' estimate equation -
!maxerr = @maxerrcount
setmaxerrs !maxerr+1
_this.{%cmnd} 'estimated equation
colplace(coefmat,eq01.@coefs,!j) 'store coefficients
' 4-period-ahead forecast
%4pers = @otod(@dtoo(%start)+!i+!window-1) 'start point
%4pere = @otod(@dtoo(%start)+!i+!window+3) 'end point
if @dtoo(%end) < @dtoo(%4pere) then 'check whether the forecast end point is greater than the workfile end point
exitloop
endif
' set smpl for forecasting period
smpl {%4pers} {%4pere}
' forecast with command *forecast* (see also *fit*)
eq01.forecast(f=na) yf
' set sampl to obtain the 4th period observation
smpl {%4pere} {%4pere}
' store forecasts
fcast = yf
next
smpl @all
show coefmat
show fcast.line
d(noerr) yf
'calculate RMSE
scalar rmse=@rmse(y, fcast)
' plot actual and recursive forecasts
graph graph1.line y fcast
graph1.addtext(t) forecast
show graph1
Re: Multi-step ahead forecast
Posted: Mon Feb 03, 2014 3:43 pm
by EViews Gareth
That's a bug in EViews. Stay tuned for the next patch.
Re: Multi-step ahead forecast
Posted: Mon Feb 10, 2014 3:14 pm
by Nas1
Dear Gareth,in the previous code I used the following command for calculating the RMSE,
scalar rmse=@rmse(y, fcast)
is this command correctly used ?? I am getting a very low RMSE that prompt me to ask this question.
best regards
Re: Multi-step ahead forecast
Posted: Mon Feb 10, 2014 3:21 pm
by EViews Gareth
Yep.
Re: Multi-step ahead forecast
Posted: Mon Feb 10, 2014 3:32 pm
by Nas1
thank you for your quick answer.
Re: Multi-step ahead forecast
Posted: Thu Jul 17, 2014 12:52 pm
by Nicole
Hi,
I am trying to do a GARCH forecast with a 21-day rolling window, but I am new to eviews and I am constantly getting errors, like "!step not defined" or "!nrolls not defined".
I am immitating the codes posted on this forum, but I seem to be doing something wrong. My codes are given below:
' set window size
!window = 1777
' get size of workfile
!length = @obsrange
' declare equation for estimation
equation eq1
' set step size
!step = 1
'calculate number of rolls
!nrolls = @floor((!length-!window)/!step) (Here I get my errors so I do not proceed any further)
What might I be doing wrong? I have uploaded my workefile as an attachement.
I am also wondering how one can impose restrictions as aplha=0 and beta=0 when estimating GARCH(1.1) in the drop down windows (not using commands)
Appreciate all the help I can get! :)
Re: Multi-step ahead forecast
Posted: Thu Jul 17, 2014 1:14 pm
by EViews Gareth
How did you try to run the program?
There is no way to impose those restrictions.
Re: Multi-step ahead forecast
Posted: Fri Jul 18, 2014 5:42 am
by Nicole
Hi Gareth,
Thank you for the quick reply.
I am relally new to eviews, and do not understand what you mean.. Yesterday I tried simply typing the code (did not load any add-in, just typed in the command field) but got the error "!step not defined". What do you mean when you say "how did you run the progam?"
Today I tried downloading the "roll add-in" and make the rolling window that way. However, when I look at the stored coefficients in "rollcoef_" I it contains only one number while the rest are N/A. What I don't understand when I use this add-in is where i estimate the size of my window. I want to forecast a one-step-ahead 21-day rolling window, but where do I spesify the window size? I have set:
Start date/obs = @first
Last date/obs =@last
Window size=1162 (roughly 2/3 of my data)
Step size=1 (one-step-ahead)
So how do I spesify that I want 21-days rolling?
I also keep getting the following error when using the add-in method; "invalid (or out of range) coefficient or matrix index 3). What does this mean?
Thank you for taking the time to help me! :)