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, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Christopher Baum <baum@bc.edu> |

To |
statalist@hsphsun2.harvard.edu |

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/

**Follow-Ups**:**Re: st: Adding regression variables one step at a time using a macro***From:*sara khan <sarakhanum84@googlemail.com>

- Prev by Date:
**RE: st: RE: Interpretation of quadratic terms** - Next by Date:
**st: RE: Adding regression variables one step at a time using a macro** - Previous by thread:
**Re: st: RE: Adding regression variables one step at a time using a macro** - Next by thread:
**Re: st: Adding regression variables one step at a time using a macro** - Index(es):