EViews doesnt remove quotes when the equation is a str_list

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

loulouviews
Posts: 60
Joined: Wed Mar 11, 2015 2:19 am

EViews doesnt remove quotes when the equation is a str_list

Postby loulouviews » Mon Apr 04, 2016 10:25 am

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

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

Re: EViews doesnt remove quotes when the equation is a str_l

Postby EViews Gareth » Mon Apr 04, 2016 10:50 am

Code: Select all

%_eq=%_myts + " " + %_myts +"(-1)"
Follow us on Twitter @IHSEViews

loulouviews
Posts: 60
Joined: Wed Mar 11, 2015 2:19 am

Re: EViews doesnt remove quotes when the equation is a str_l

Postby loulouviews » Mon Apr 04, 2016 11:50 pm

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 :

Code: Select all

equation eq{%_myTS}= {%_eq} c

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

Re: EViews doesnt remove quotes when the equation is a str_l

Postby EViews Gareth » Tue Apr 05, 2016 8:15 am

The answer to your first question is yes. I don't understand the second.
Follow us on Twitter @IHSEViews

loulouviews
Posts: 60
Joined: Wed Mar 11, 2015 2:19 am

Re: EViews doesnt remove quotes when the equation is a str_l

Postby loulouviews » Tue Apr 05, 2016 9:41 am

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

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

Re: EViews doesnt remove quotes when the equation is a str_l

Postby EViews Gareth » Tue Apr 05, 2016 9:57 am

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]
%_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
Follow us on Twitter @IHSEViews

loulouviews
Posts: 60
Joined: Wed Mar 11, 2015 2:19 am

Re: EViews doesnt remove quotes when the equation is a str_l

Postby loulouviews » Tue Apr 05, 2016 10:50 am

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.

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

Re: EViews doesnt remove quotes when the equation is a str_l

Postby EViews Gareth » Tue Apr 05, 2016 11:42 am

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
Follow us on Twitter @IHSEViews

loulouviews
Posts: 60
Joined: Wed Mar 11, 2015 2:19 am

Re: EViews doesnt remove quotes when the equation is a str_l

Postby loulouviews » Tue Apr 05, 2016 12:43 pm

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").

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

Re: EViews doesnt remove quotes when the equation is a str_l

Postby EViews Gareth » Tue Apr 05, 2016 1:15 pm

Why does that matter? Change any variable/parameter you want inside the loop.
Follow us on Twitter @IHSEViews


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 47 guests