Page 1 of 1
EViews doesnt remove quotes when the equation is a str_list
Posted: Mon Apr 04, 2016 10:25 am
by loulouviews
Hi,
I want to do something like
Code: Select all
wfcreate m 1990 2000
series myTS=nrnd
%_myts="myTS"
%_eq="{%_myts} {%_myts}(-1)"
equation myEq.ls {%_eq} c
But EViews does not remove quotes and I got the following error :
{ is not defined in "EQUATION MYEQ.LS {"MYTS"} {"MYTS"}(-1) C".
Does anybody have any clues ?
Thanks
Louis
Re: EViews doesnt remove quotes when the equation is a str_l
Posted: Mon Apr 04, 2016 10:50 am
by EViews Gareth
Code: Select all
%_eq=%_myts + " " + %_myts +"(-1)"
Re: EViews doesnt remove quotes when the equation is a str_l
Posted: Mon Apr 04, 2016 11:50 pm
by loulouviews
Thanks for your prompt reply, I'm always confused with the rules of quotes replacing in EViews.
I still have a question : EViews is going to replace %_myTS by its current value, at assignment
So if I do
Code: Select all
%_eq=%_myTS+" "+%_myTS+"(-1)"
series myTS2=nrnd+1
%_myTS="myTS2"
Then %_eq would still be with myTS and not with myTS2 right ?
I was looking a way to make EViews replacing %_myTS by its current value when the equation is estimated (because I'm declaring a bunch of equations before a for loop on variables names in which each equation is estimated, but the endogenous variable can changed depending on a condition which is evaluated inside the for loop)
with something like :
Re: EViews doesnt remove quotes when the equation is a str_l
Posted: Tue Apr 05, 2016 8:15 am
by EViews Gareth
The answer to your first question is yes. I don't understand the second.
Re: EViews doesnt remove quotes when the equation is a str_l
Posted: Tue Apr 05, 2016 9:41 am
by loulouviews
I was looking for a way to declare an equation with the name of variables that I would declare later on.
That is why I was looking for a way to declare an equation as a string list and then estimate the equation with each variable_as_a_string replace by its current value.
Imagine that you have something like :
Code: Select all
%_eq1=%_myTS+"(-1)"
%_eq2=%_myTS+"(-1)"+%_myTS+"(-2)"
series myTS2=nrnd+1
series myTS1=nrnd
for !i=1 to 2
if condition then %_myTS="myTS1" else %_myTS="myTS2" endif
equation eq{!i}.ls {_myTS} c {%_eq{!i}}
next
It would not work.
But if EViews was replacing quotes inside an equation as in my first post, ie :
Code: Select all
%_eq1="{%_myts}(-1)"
%_eq2="{%_myts}(-1) {%_myts}(-2)"
The loop above would work
Re: EViews doesnt remove quotes when the equation is a str_l
Posted: Tue Apr 05, 2016 9:57 am
by EViews Gareth
I'm still not 100% certain I know what your end goal is. I think you're going about it all the wrong way, but cannot be sure.
In the example you give, I don't see why you don't just do:
Code: Select all
%_eq1=%_myTS+"(-1)"
%_eq2=%_myTS+"(-1)"+%_myTS+"(-2)"
series myTS2=nrnd+1
series myTS1=nrnd
for !i=1 to 2
if condition then %_myTS="myTS1" else %_myTS="myTS2" endif
equation eq{!i}.ls {%_myTS} c {%_myTS}(-1 to -!i)
next
Re: EViews doesnt remove quotes when the equation is a str_l
Posted: Tue Apr 05, 2016 10:50 am
by loulouviews
The purpose of my example was to illustrate the challenge I face.
My actual challenge is a bunch of very similar equations on oil prices (almost only the endogenous variable is varying). I want to do numerous comparable things for each of these equations (estimating, forecasting, doing some econometric analysis, etc.) so I'm doing a for loop on these oil prices variables. These procedure is inside a subroutine which has a boolean argument affecting the endogenous variable (basically taking account or not of some external impacts) -> that why I was willing to have an "if condition" inside my for loop and declare equations before the loop without knowing yet the endogenous variable.
I realize this is not so clear, sorry about it.
I'm going to looking for a different way to achieve that.
Thanks again for your prompt replies.
Re: EViews doesnt remove quotes when the equation is a str_l
Posted: Tue Apr 05, 2016 11:42 am
by EViews Gareth
What you're describing sounds trivial.
Code: Select all
create u 100
for !i=1 to 10
series y{!i}=nrnd
next
series x=nrnd
for !i=1 to 10
!cond = @nrnd>0
if !cond=1 then
%dep = "y" + @str(!i) + "(-1)"
else
%dep = "y" + @str(!i) + "(-2)"
endif
equation eq{!i}.ls {%dep} c x(-1 to -!i)
next
Re: EViews doesnt remove quotes when the equation is a str_l
Posted: Tue Apr 05, 2016 12:43 pm
by loulouviews
The equation could not be defined inside the for loop because the endogenous variable is not the only parameter changing (that's why I wrote "almost").
Re: EViews doesnt remove quotes when the equation is a str_l
Posted: Tue Apr 05, 2016 1:15 pm
by EViews Gareth
Why does that matter? Change any variable/parameter you want inside the loop.