Hi together!
I have the following code for a rolling regression of a VECM; my question is, how can I manipulate this code to create 4-step and 5-step ahead static forecasts for variables a and b and store them in different vectors? Thanks alot for comments :)
'set window size
!window=400
'get size of workfile
!length=@obsrange
'set step size
!step=1
'declare equation for estimation
var vecm
'calculate number of rolls
!nrolls=@round((!length-!window)/!step)
'variable keeping track of how many rolls we have done
!j=0
'move sample !step steps at a time
for !i=1 to !length-!window+1-!step step !step
!j=!j+1
' set sample to estimation period
smpl @first+!i-1 @first+!i+!window-2
' estimate equation
vecm.ec(c,1) 1 5 a b
vecm.makemodel(vecmod)
next
multistep forecast vecm
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: multistep forecast vecm
Set the sample to be four steps ahead of the estimation sample, then solve the model.
Re: multistep forecast vecm
Oh sorry, I meant dynamic forecast; so that I get 4, 5, 6 and 7 steps out of sample forecasts for a and b.
Re: multistep forecast vecm
So if I want to do dynamic multistep ahead out of sample forecasts I just have to enlarge the sample and solve the model? If yes, how can I save my 4-,5-,6- and 7-steps ahead forecasts in a vector? Have tried out different fixes, but somehow it doesn't work out... Any hints? Thx alot!
Re: multistep forecast vecm
Hi mirror,
one easy way to do it is saving the forecasts in a matrix. I do it like this,i think it work, you just have to change the ahead scalar:
I hope I have helped.Regads.
one easy way to do it is saving the forecasts in a matrix. I do it like this,i think it work, you just have to change the ahead scalar:
Code: Select all
'set window size
!window=400
'get size of workfile
!length=@obsrange
'set step size
!step=1
'declare equation for estimation
var vecm
'calculate number of rolls
!nrolls=@round((!length-!window)/!step)
'variable keeping track of how many rolls we have done
!j=0
'move sample !step steps at a time
for !i=1 to !length-!window+1-!step step !step
!j=!j+1
' set sample to estimation period
smpl @first+!i-1 @first+!i+!window-2
' estimate equation
vecm.ec(c,1) 1 5 a b
vecm.makemodel(vecmod)
'our of sample forecast
!ahead=5
'----------------------------------
smpl @first+!i+!window-2 @first+!i+!window-2+!ahead
vecmod.solve
for !h=1 to !ahead
if !h+!i+!window<!length then
matrix(!ahead,!length-!window) forecasts_a(!h,!i)=a_0(!h+!i+!window-1,1)
matrix(!ahead,!length-!window) forecasts_b(!h,!i)=b_0(!h+!i+!window-1,1)
else
smpl @first @last
endif
next
next
I hope I have helped.Regads.
Last edited by NicolasR on Sun Mar 23, 2014 2:04 pm, edited 1 time in total.
Re: multistep forecast vecm
Hi! Thanks alot! I will try that later on....
Re: multistep forecast vecm
Hi again, sorry for that stupid question, but I don't really have to change the !ahead value , right? I just have to put the highest h (in my case 7) in there and get all other forecasts for h=1,2,3,4,5,6,7 in that matrix as well.
Re: multistep forecast vecm
No, you don´t have to change the value, you can keep it in seven, I said it in the case you wanted more forecasting ahead steps than five. I have a question,are you sure that the cointegration relationship remains across the time window?
Re: multistep forecast vecm
Well, somehow I have to rely on it, although it's not that unrealistic in my case. :D
Re: multistep forecast vecm
Another question: When you change the sample here
'out of sample forecast
!ahead=12
smpl @first+!i+!window-2 @first+!i+!window-2+!ahead
vecmod.solve
Does the code really use past values, because for my dynamic forecasts I need past values (5lags) and forecasted values (at least for h>5). Thx!
'out of sample forecast
!ahead=12
smpl @first+!i+!window-2 @first+!i+!window-2+!ahead
vecmod.solve
Does the code really use past values, because for my dynamic forecasts I need past values (5lags) and forecasted values (at least for h>5). Thx!
Re: multistep forecast vecm
It uses the 400 past values in the sense that you estimate the model with this data, but the forecast are out of sample dynamic.
Who is online
Users browsing this forum: No registered users and 1 guest
