Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[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 <>
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   |
An Introduction to Stata Programming   |
An Introduction to Modern Econometrics Using Stata   |

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index