Page 1 of 1

string for model specification in equation environment

Posted: Wed Mar 26, 2014 9:49 am
by pekaype
Hi

is it possible to use a string instead of manually writing down the model specification in and equation environment?`

Easy example, suppose this is the regression I want to run

Code: Select all

equation equ1.ls y c @movav(x1(0),3) x2
can I replace the model specification ie everything after "equ1.ls" with a string?
I have extracted the optimal model specification and lag structure for multitude of dependent variables, and the way it's set up is that the explanatory variables are enlisted in a string object. Most efficiently I would be able to incorporate this string into a loop, but I don't know if the equation environment lets me do so.

Easy example, let "_equ_y" be the string containing the optimal model specification eg.: "y c @movav(x1(0),3) x2"

Code: Select all

for %bestvar {_equ_y} equation _equ1_y.ls %bestvar show equ1_y_ next
obviously only returns the alpha values in the string. Ideas?

Re: string for model specification in equation environment

Posted: Wed Mar 26, 2014 9:55 am
by EViews Gareth
replace %bestvar with {%bestvar}

Re: string for model specification in equation environment

Posted: Wed Mar 26, 2014 10:03 am
by pekaype
Thanks Gareth, tried that before but gets me following error message:

"No coefficients specified in "euation equ1_y.ls y"

Re: string for model specification in equation environment

Posted: Wed Mar 26, 2014 10:08 am
by EViews Gareth
try putting an extra set of braces. {{%bestvar}}

Re: string for model specification in equation environment

Posted: Wed Mar 26, 2014 10:13 am
by pekaype
That gives me following error message "y is not a valid string or scalar name in "Equation..." "

Interestingly it always only refers to the first varaible specfied in that string, which would explain why it cannot execute the regression.

Re: string for model specification in equation environment

Posted: Wed Mar 26, 2014 10:23 am
by EViews Gareth
ok, I think we need more information on exactly what you're doing. The following program shows examples of how to do it in a variety of ways:

Code: Select all

create u 100 series y=nrnd series x1=nrnd series x2=nrnd string _equ_y = "y c @movav(x1(0),3) x2" equation eq1.ls {_equ_y} %bestvar = _equ_y equation eq2.ls {%bestvar} %bestvar = "_equ_y" equation eq3.ls {{%bestvar}} for %bestvar _equ_y equation _equ1_y.ls {{%bestvar}} next