multistep forecast vecm

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

mirror
Posts: 9
Joined: Wed Jan 22, 2014 6:42 am

multistep forecast vecm

Postby mirror » Mon Mar 17, 2014 9:29 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: multistep forecast vecm

Postby EViews Gareth » Mon Mar 17, 2014 9:36 am

Set the sample to be four steps ahead of the estimation sample, then solve the model.

mirror
Posts: 9
Joined: Wed Jan 22, 2014 6:42 am

Re: multistep forecast vecm

Postby mirror » Mon Mar 17, 2014 9:56 am

Oh sorry, I meant dynamic forecast; so that I get 4, 5, 6 and 7 steps out of sample forecasts for a and b.

mirror
Posts: 9
Joined: Wed Jan 22, 2014 6:42 am

Re: multistep forecast vecm

Postby mirror » Tue Mar 18, 2014 5:31 am

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!

NicolasR
Posts: 90
Joined: Mon Nov 04, 2013 6:22 pm
Location: Here

Re: multistep forecast vecm

Postby NicolasR » Tue Mar 18, 2014 7:57 am

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.
Last edited by NicolasR on Sun Mar 23, 2014 2:04 pm, edited 1 time in total.

mirror
Posts: 9
Joined: Wed Jan 22, 2014 6:42 am

Re: multistep forecast vecm

Postby mirror » Wed Mar 19, 2014 2:07 am

Hi! Thanks alot! I will try that later on....

mirror
Posts: 9
Joined: Wed Jan 22, 2014 6:42 am

Re: multistep forecast vecm

Postby mirror » Wed Mar 19, 2014 2:50 am

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.

NicolasR
Posts: 90
Joined: Mon Nov 04, 2013 6:22 pm
Location: Here

Re: multistep forecast vecm

Postby NicolasR » Wed Mar 19, 2014 8:18 am

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?

mirror
Posts: 9
Joined: Wed Jan 22, 2014 6:42 am

Re: multistep forecast vecm

Postby mirror » Wed Mar 19, 2014 9:11 am

Well, somehow I have to rely on it, although it's not that unrealistic in my case. :D

mirror
Posts: 9
Joined: Wed Jan 22, 2014 6:42 am

Re: multistep forecast vecm

Postby mirror » Wed Mar 19, 2014 9:31 am

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!

NicolasR
Posts: 90
Joined: Mon Nov 04, 2013 6:22 pm
Location: Here

Re: multistep forecast vecm

Postby NicolasR » Wed Mar 19, 2014 9:47 am

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.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests