correct string form for running regression

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

minson
Posts: 10
Joined: Fri Feb 06, 2009 7:27 am

correct string form for running regression

Postby minson » Fri Feb 06, 2009 8:39 am

Hello...ive been stuck on this for ages it seems...

I have 24 regression estimates for a variable "d". (one for each hour of the day). I have string variables for each estimate:

%est_1 = "d c dd^5 dd^6 dd^7 dd^9 dd^12"
%est_2 = "d te dd^2 dd^7"
%est_3 = "d c te te^2 dd^5 dd^6" ...etc etc

the below regression works for hour 1.

%estimate = %est_1
myequation.ls {%estimate}

but I want be able to choose the hour like so:

%hour = "1"
%estimate = "est_" + %hour
myequation.ls {%estimate}

this gives me an error message. "est_1 is not defined in "DO_myEquation.ls est_1"

Can you please help me solve this problem?

Kind Regards
Minson

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

Re: correct string form for running regression

Postby EViews Gareth » Fri Feb 06, 2009 9:11 am

Unfortunately you can't use a string variable to refer to another string variable like that.

You might have better luck putting the strings into a table. Something like:

Code: Select all

table estimates estimates(1,1) = "d c dd^5 dd^6 dd^7 dd^9 dd^12" estimates(2,1) = "d te dd^2 dd^7" estimates(3,1) = "d c te te^2 dd^5 dd^6" ...etc etc
Then inside the loop you could do something like:

Code: Select all

%estimate = estimates(!i,1) myequation.ls {%estimate}
I think that would work....

j.galimberti
Posts: 26
Joined: Fri Feb 06, 2009 2:53 am

Re: correct string form for running regression

Postby j.galimberti » Fri Feb 06, 2009 1:07 pm

What happens if you try this:

%hour = "1"
%estimate = {"est_"+%hour}
myequation.ls {%estimate}
Galimberti, J. K.
MSc in Economics at Federal University of Santa Catarina (Brazil)
Going to PhD in Economics at University of Manchester (UK)
Website: http://sites.google.com/site/jkgeconoeng/

minson
Posts: 10
Joined: Fri Feb 06, 2009 7:27 am

Re: correct string form for running regression

Postby minson » Sat Feb 07, 2009 9:16 am

Thanks Gareth, the table work really well.

J.Galimberti: I tried your suggestion, but unfortunately it didn't work. I got the error message:

" "est_" + %hour is not a valid string or automatic scalar name in %estimate = {"est_" + %hour} "

Thank you both for your suggestions.
Regards
Minson


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests