Page 1 of 1
multistep forecast vecm
Posted: Mon Mar 17, 2014 9:29 am
by mirror
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
Re: multistep forecast vecm
Posted: Mon Mar 17, 2014 9:36 am
by EViews Gareth
Set the sample to be four steps ahead of the estimation sample, then solve the model.
Re: multistep forecast vecm
Posted: Mon Mar 17, 2014 9:56 am
by mirror
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
Posted: Tue Mar 18, 2014 5:31 am
by mirror
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
Posted: Tue Mar 18, 2014 7:57 am
by NicolasR
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:
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.
Re: multistep forecast vecm
Posted: Wed Mar 19, 2014 2:07 am
by mirror
Hi! Thanks alot! I will try that later on....
Re: multistep forecast vecm
Posted: Wed Mar 19, 2014 2:50 am
by mirror
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
Posted: Wed Mar 19, 2014 8:18 am
by NicolasR
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
Posted: Wed Mar 19, 2014 9:11 am
by mirror
Well, somehow I have to rely on it, although it's not that unrealistic in my case. :D
Re: multistep forecast vecm
Posted: Wed Mar 19, 2014 9:31 am
by mirror
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!
Re: multistep forecast vecm
Posted: Wed Mar 19, 2014 9:47 am
by NicolasR
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.