I just tried 7, and I got the same results of zero coefmat.You have 7.
Multi-step ahead forecast
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
Re: Multi-step ahead forecast
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13584
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Multi-step ahead forecast
Works for me.
Re: Multi-step ahead forecast
Thank you Gareth, May you please suggest why I am getting this coefmat for the same file that I uploaded??
Last edited by Nas1 on Wed Jun 25, 2014 7:12 am, edited 1 time in total.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13584
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Multi-step ahead forecast
Hard to say what you're doing wrong.
Re: Multi-step ahead forecast
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?Hard to say what you're doing wrong.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13584
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Multi-step ahead forecast
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
thank you Gareth for your support, i will re-examine everything again, at least the codes are correct :)
Re: Multi-step ahead forecast
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
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
Last edited by Nas1 on Wed Jun 25, 2014 7:11 am, edited 1 time in total.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13584
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Multi-step ahead forecast
That's a bug in EViews. Stay tuned for the next patch.
Re: Multi-step ahead forecast
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
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
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13584
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Multi-step ahead forecast
thank you for your quick answer.
Re: Multi-step ahead forecast
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! :)
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! :)
- Attachments
-
- WTI data with IV (eviews).xlsx
- (195.15 KiB) Downloaded 853 times
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13584
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Multi-step ahead forecast
How did you try to run the program?
There is no way to impose those restrictions.
There is no way to impose those restrictions.
Re: Multi-step ahead forecast
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! :)
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! :)
Who is online
Users browsing this forum: capuchin and 1 guest
