Dear List
I'm trying (in Stata 7) to automate the estimation of a regression
model on transformed data. I have a dependent variable, the name
of which is stored in $lhs, and some independent variables which
are in $rhs2. I'd like to transform (quasi-difference) each variable
and then run a regression on the transformed data. The code
below represents my attempt at this.
global difreg=""
local i=1
foreach var of varlist $lhs $rhs2 {
gen d`i'=(`var'-`var'[_n-1])/sqrt(2)
global difreg="$difreg"+" "+"d`i'"
local i=`i'+1
}
regress $difreg
This seems to work fine so long as $rhs2 is not too long. If there
are a lot of variables in $rhs2 then Stata stops adding to $difreg
and the program either stops executing because $difreg is not a
valid list of variables or (worse) runs with an incomplete list of
variables.
I'm sure a more elegant solution exists but am not sure where to
look.
Ken
Ken Clark
School of Economic Studies
University of Manchester
Manchester
M13 9PL
Tel:0161-275-3679
Fax:0161-275-4812
email: [email protected]
http://www.ses.man.ac.uk/clark
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/