Page 1 of 1
Basic question - Storing Coefficients - Please Help
Posted: Thu Sep 01, 2011 11:46 am
by jason_ll
Hello,
I created a small model with about 10 equations, and I'd like to store the coefficents from each equation into 10 coefficient vecotrs (1 vector for each equation).
How can I do this, in the context of a model? I crreatec a cofficient object called "zzz" and tried to include this as a line in my model:
zzz = eq01.@coefs
But it says "illegal lag or index specification" for coefficient zzz.
I know this can be done by a program, but I really would prefer to stick with the user interface and the model object.
PLEASE help,
Thank you,
Re: Basic question - Storing Coefficients - Please Help
Posted: Tue Sep 06, 2011 9:30 am
by EViews Glenn
vector zzz=eq01.@coefs
or
coef zzz=eq01.@coefs
Re: Basic question - Storing Coefficients - Please Help
Posted: Thu Sep 08, 2011 8:41 am
by jason_ll
H Glenn,
Thanks for the reply. But this isn't really working when I add it as a line in my model. I get "Syntax error in "vector zzz=eq01.@coefs".
The thing is I'm adding it as a line in a "model" object, and not as a line in a program. Is there any other way to do it?
It seems like a really simple thing to do, but I just can't figure it out.
thanks!
Basic question - Storing Coefficients - Please Help
Posted: Thu Sep 08, 2011 10:02 am
by EViews Gareth
Extracting the coefficients of an equation as part of a model specification really makes no sense. Perhaps you should tell us what you're hoping to accomplish.
Re: Basic question - Storing Coefficients - Please Help
Posted: Fri Sep 09, 2011 6:21 am
by jason_ll
Hi Gareth,
I just want to be able to store the coefficients of some equations. Let's say I have only two equations ("equation" objects):
Y = c(1) +c(2)*consumption
X = d(1) + d(2)*moneysupply
And I create a "model" object, and put both these equations in that model. The model object automatically numbers them (eq1 and eq2).
And now I want to use c(2) and d(2) in another equation in my model. For example, let's say that I have a vector V, and I want to write a third equation (not a regression equation) as:
v = c(2)*interestrate + d(2)*investment.
or let's say I simply want to store the c(2) and d(2) to use them in a different model.
I take it from what you're saying that this is not possible because it doesn't make any sense in a model specification. I think I see your point, but what would be the alternative?
Basically, I want to somehow make EViews automatically store my coefficients every time I run the equation or model, if possible.
I don't mind doing this outside a model specification, but then how can I number the equations? How would EViews know which equation is eq01 and which is eq02?
Thanks again for your help.
Re: Basic question - Storing Coefficients - Please Help
Posted: Fri Sep 09, 2011 6:27 am
by startz
If you name all your coefficients c(1), c(2), etc. in the model, you'll find that EViews automatically stores them in the C vector in the workfile without your needing to do anything.
Re: Basic question - Storing Coefficients - Please Help
Posted: Fri Sep 09, 2011 10:45 am
by EViews Glenn
Re: Startz's comment...True, but those coefficients can get overwritten as you do other things. You are best off not counting on them being the same as when you estimated...
Re: the jason_ll's comment...What Gareth is saying is that storing the coefficients inside a model doesn't make sense since the model does no updating of coefficients. You can store your coefficients *outside* of the model using the syntax I gave you earlier and then make your third model refer to the elements of the stored coefficient vectors.
As to numbering the equations. Why does EViews need to number the equations? Once you save the coefficients you are working with the saved coefficient vectors not the equation.
Code: Select all
equation eq01.ls y c x1 x2 x3
coef eq01_coefs = eq01.@coefs
equation eq02.ls y c z1 z2 z3
coef eq02_coefs = eq01.@coefs
model a
a.append :eq01
a.append w = eq02_coefs(1) + eq01_coefs(2)*x1 + eq02_coefs(3)*z2
solve a
or something of the sort.
In fact, thinking about it, you should be able to skip the saving altogether and write in terms of the coefficients of the equations.
Code: Select all
equation eq01.ls y c x1 x2 x3
equation eq02.ls y c z1 z2 z3
model a
a.append :eq01
a.append w = eq02.@coef(1) + eq01.@coef(2)*x1 + eq02.@coef(3)*z2
solve a
Re: Basic question - Storing Coefficients - Please Help
Posted: Sat Sep 10, 2011 8:41 am
by jason_ll
Thanks again for the replies! It works now.
Please ignore my comment on numbering the equations. I thought that "eq01" was referring to some equation's number, as opposed to the actual equation name. Now it makes a lot more sense.
The only minor lingering problem that remains: is there any way to make these coefficients update automatically?
For example, I have an equation called "demand", and I add a couple of variables to it. Instead of having to retype the command "vector zzz = demand.@coefs" to store the new coefficients, is there a way for EViews to do that automatically? It would be ideal if I can get a ceof object to work similarly to an auto-updating series.
Re: Basic question - Storing Coefficients - Please Help
Posted: Mon Sep 12, 2011 9:49 am
by EViews Glenn
There isn't, which is why the method where you don't export to a coef, but rather use the equation and coef directly in the model may make more sense for your particular application.
Re: Basic question - Storing Coefficients - Please Help
Posted: Mon Sep 12, 2011 1:29 pm
by jason_ll
Gotcha!
Thanks a lot for all those who replied.