Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
re: st: Adding regression variables one step at a time using a macro
From
Christopher Baum <[email protected]>
To
[email protected]
Subject
re: st: Adding regression variables one step at a time using a macro
Date
Wed, 10 Mar 2010 12:23:04 -0500
<>
Please could you advise me on how to write a macro so that I can add
regression variables one step at a time for only non-missing cases. It
is similar to a forward stepwise except that I want to choose which
variables I add.
At the moment, I am doing the following:
Model 1
reg y x1 if y<. & x1<.
Model 2 - add another var
reg y x1 x2 if y<. & x1<. &x2<.
This is quite unnecessary. Regression, like any multivariate estimation procedure, practices casewise deletion: any missing
value in y or any of the x's will cause that observation to be dropped. If you used the above commands without -if- you would get
exactly the same results.
If you want to retain the sample that has been used in estimation, and apply a different model that might not trigger the same
pattern of missings:
sysuse auto
qui reg price mpg rep78 // this will drop 5 cases
g mysample = e(sample)
reg price mpg turn if mysample
reg price mpg if mysample
This will cause all regressions to be run on the restricted sample.
Kit Baum | Boston College Economics and DIW Berlin | http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming | http://www.stata-press.com/books/isp.html
An Introduction to Modern Econometrics Using Stata | http://www.stata-press.com/books/imeus.html
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/