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 |
sara khan <sarakhanum84@googlemail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Adding regression variables one step at a time using a macro |

Date |
Wed, 10 Mar 2010 17:32:26 +0000 |

Dear Kit Many thanks for your advice on the missing values. Leaving aside the missing values, do you have any advice on how to add additional variables one step at a time from a list of independent variables using a loop: list of indep vars x1 x2 x3 x4 x5 Model 1 reg y x1 Model 2 - add another var reg y x1 x2 Model 3 - add another var reg y x1 x2 x3 On Wed, Mar 10, 2010 at 5:23 PM, Christopher Baum <baum@bc.edu> wrote: > <> > 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/ > * * 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**:**AW: st: Adding regression variables one step at a time using a macro***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**References**:**re: st: Adding regression variables one step at a time using a macro***From:*Christopher Baum <baum@bc.edu>

- Prev by Date:
**AW: st: Adding regression variables one step at a time using a macro** - Next by Date:
**Re: st: Sample Wegihts** - Previous by thread:
**re: st: Adding regression variables one step at a time using a macro** - Next by thread:
**AW: st: Adding regression variables one step at a time using a macro** - Index(es):