Page 1 of 1

correct string form for running regression

Posted: Fri Feb 06, 2009 8:39 am
by minson
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

Re: correct string form for running regression

Posted: Fri Feb 06, 2009 9:11 am
by EViews Gareth
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....

Re: correct string form for running regression

Posted: Fri Feb 06, 2009 1:07 pm
by j.galimberti
What happens if you try this:

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

Re: correct string form for running regression

Posted: Sat Feb 07, 2009 9:16 am
by minson
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