Hi,
I want to recursively estimate a VAR model on 3 variables and use in each loop the results to predict the one-day-ahead variables.
my idea was the following
for !j =1 to 50
smpl 1/01/2001 +!j 01/07/2001 +!j
var mvar.ls 1 2 f1 f2 f3
series newf1 = mvar.@coefs(1,1)*f1(-1) + C(1,2)*f1(-2) + C(1,3)*f2(-1) + C(1,4)*f2(-2) + C(1,5)*f3(-1) + C(1,6)*f3(-2) + C(1,7)
series newf2 = C(2,1)*F1(-1) + C(2,2)*F1(-2) + C(2,3)*F2(-1) + C(2,4)*F2(-2) + C(2,5)*F3(-1) + C(2,6)*F3(-2) + C(2,7)
series newf3 = C(3,1)*F1(-1) + C(3,2)*F1(-2) + C(3,3)*F2(-1) + C(3,4)*F2(-2) + C(3,5)*F3(-1) + C(3,6)*F3(-2) + C(3,7)
next
stop
and I wanted to specify the several (C1,2) etc (as found in "Representations" under estimation output) as the first one mvar.@coefs(1,1). However it gives me an error here and I don't know why, since I think it is the correct syntax to write it, isn't it?
Moreover, is there a way in which I do not have to input the number of lags (in this case 1 and 2) but that in every loop it decides, based on SIC, up to which lag to use?
Thanks in advance for the help!
VAR estimation output --> building forecasting model - help!
Moderators: EViews Gareth, EViews Moderator
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: VAR estimation output --> building forecasting model - help!
I think the data member you are after is @coefmat, not @coefs.
Re: VAR estimation output --> building forecasting model - help!
Perfect, that is right!
However, I still have some problems with this program and don't understand how to solve it...
In particular, if I write
for !j =1 to 2065-175
smpl 1/01/2001+!j 01/09/2001 +!j
var mvar.ls 1 2 f1 f2 f3
scalar kkz=mvar.@coefmat(4,1)
scalar kkz2=mvar.@coefmat(5,1)
scalar kkz3=mvar.@coefmat(6,1)
scalar kkz4=mvar.@coefmat(7,1)
series newf1 = mvar.@coefmat(1,1)*f1(-1) + mvar.@coefmat(2,1)*f1(-2) + mvar.@coefmat(3,1)*f2(-1) + kkz*f2(-2) + kkz2*f3(-1) + kkz3*f3(-2) + kkz4
next
stop
the series newf1 seems to overwrite itself with lots of values...
Is it possible to attach the workspace with the three vectors f1 f2 and f3 i am using?
I actually want that for each loop only one value (the value predicted for f1 at time t+1, constructed through the VAR mechanism)) enters the series and then basically put all values all one after the other...
However, I still have some problems with this program and don't understand how to solve it...
In particular, if I write
for !j =1 to 2065-175
smpl 1/01/2001+!j 01/09/2001 +!j
var mvar.ls 1 2 f1 f2 f3
scalar kkz=mvar.@coefmat(4,1)
scalar kkz2=mvar.@coefmat(5,1)
scalar kkz3=mvar.@coefmat(6,1)
scalar kkz4=mvar.@coefmat(7,1)
series newf1 = mvar.@coefmat(1,1)*f1(-1) + mvar.@coefmat(2,1)*f1(-2) + mvar.@coefmat(3,1)*f2(-1) + kkz*f2(-2) + kkz2*f3(-1) + kkz3*f3(-2) + kkz4
next
stop
the series newf1 seems to overwrite itself with lots of values...
Is it possible to attach the workspace with the three vectors f1 f2 and f3 i am using?
I actually want that for each loop only one value (the value predicted for f1 at time t+1, constructed through the VAR mechanism)) enters the series and then basically put all values all one after the other...
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: VAR estimation output --> building forecasting model - help!
The series is only over-writing itself for the current sample, which is changing each time through the loop. Therefore, it should be ok (I think).
Re: VAR estimation output --> building forecasting model - help!
but which value is it taking for the fs(-1) and fs(-2)?? cause the resulting series I get seems to be totally wrong...
because actually what I want is basically that
given
smpl 1/01/2001 01/09/2001
what I need is that the f's(-1) ate the ones of the 01/09/2001 and the fs(-2) are the ones of the day before that.
And the result should be just one value for f1 at date 01/09/2001+1 and written in there...
because actually what I want is basically that
given
smpl 1/01/2001 01/09/2001
what I need is that the f's(-1) ate the ones of the 01/09/2001 and the fs(-2) are the ones of the day before that.
And the result should be just one value for f1 at date 01/09/2001+1 and written in there...
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: VAR estimation output --> building forecasting model - help!
You're performing a series operation. Thus every value of f(-1) and f(-2) for the current sample are used.
Re: VAR estimation output --> building forecasting model - help!
so how should I write if I want just the scalar numbers for f1(-1) f1(-2) f2(-1) f2(-2) f3(-1) f3(-2) to be put in the equation and thus have an output which is a scalar, but which then is put in a series where every row corresponds to the output scalar of the equation done in every loop??
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13600
- Joined: Tue Sep 16, 2008 5:38 pm
Re: VAR estimation output --> building forecasting model - help!
f1 is a series, right?
Therefore f1(-1) is a series.
I don't understand what you mean by "scalar numbers for f1(-1)..."
Therefore f1(-1) is a series.
I don't understand what you mean by "scalar numbers for f1(-1)..."
Re: VAR estimation output --> building forecasting model - help!
yes f1, f2 and f3 are series that go from time t-n to t-1.
However, when I want to make my prediction with a VAR(2) model like the one posted above, I just need the values for f1, f2 and f3 at time t-1 and t-2 so that as a result I will get the prediction for t which will be a scalar number since it's a multiplication and sum of scalars. I do not want to use the entire series for that sample! So either I change the sample within the loop (which however lead to an error) or I don't know what to do...
basically if i have that (imagine it as a vertical series where you have time on the y axis):
f1= [0.1 0.2 0.3 ...... 0.4 0.45 0.5]
f2=[-0.1 -0.2 -0.3.....-0.18 -0.19 -0.2]
f3=[0.03 0.04 0.05... 0.02 0.01 0.015]
what I need is basically that after I make the VAR on these three series (where I change the estimation sample for every loop by taking a rolling sample) I take the coefficients of the VAR in that loop and multiply and sum just with the last and penultimate value.
In this case f1(-1) should be 0.5 f1(-2)=0.45 f2(-1)=-0.2 f2(-2)=-0.19 f3(-1)=0.015 f3(-2)=0.01
That is what I mean.. hope it is more clear now..
thanks!
However, when I want to make my prediction with a VAR(2) model like the one posted above, I just need the values for f1, f2 and f3 at time t-1 and t-2 so that as a result I will get the prediction for t which will be a scalar number since it's a multiplication and sum of scalars. I do not want to use the entire series for that sample! So either I change the sample within the loop (which however lead to an error) or I don't know what to do...
basically if i have that (imagine it as a vertical series where you have time on the y axis):
f1= [0.1 0.2 0.3 ...... 0.4 0.45 0.5]
f2=[-0.1 -0.2 -0.3.....-0.18 -0.19 -0.2]
f3=[0.03 0.04 0.05... 0.02 0.01 0.015]
what I need is basically that after I make the VAR on these three series (where I change the estimation sample for every loop by taking a rolling sample) I take the coefficients of the VAR in that loop and multiply and sum just with the last and penultimate value.
In this case f1(-1) should be 0.5 f1(-2)=0.45 f2(-1)=-0.2 f2(-2)=-0.19 f3(-1)=0.015 f3(-2)=0.01
That is what I mean.. hope it is more clear now..
thanks!
Who is online
Users browsing this forum: No registered users and 2 guests
