Page 1 of 1

Correct usage of the dofor instruction

Posted: Thu Mar 15, 2012 7:26 pm
by PERRY
I need to do a series of regressions by changing only one dependent variable at a time. I read the manual and I think the correct way to do it is by the dofor instruction:

Code: Select all

dofor money = SUMM1 SUMM2M SUMM2 SUMMZM SUMALL
SET y = GDP_N
SET z1 = TB
SET z2 = cpi
SET z3 = money

linreg(noprint) y /RESIDS
#constant z1 z2 z3

end dofor money
Is this the correct way to use the instruction dofor? By this I needed to run 5 regressions where money is substituted in each regression for the five monetary aggregates abobe.

Re: Correct usage of the dofor instruction

Posted: Thu Mar 15, 2012 9:51 pm
by PERRY
I just think I found it. I must use it as in:

Code: Select all

SET z3 = money{0}
So that it declares the series money. Hope it is okay.

Re: Correct usage of the dofor instruction

Posted: Fri Mar 16, 2012 9:57 am
by moderator
Yes, that will work. The lag notation forces RATS to treat MONEY as a series in that context.

You could just do:

linreg(noprint) y /RESIDS
# constant z1 z2 money

But if you want the regression output labelled as "z3" instead of the name of the current DOFOR series, what you have is one way to accomplish that.