Bookmark and Share

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]

AW: st: Adding regression variables one step at a time using a macro


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   AW: st: Adding regression variables one step at a time using a macro
Date   Wed, 10 Mar 2010 18:35:51 +0100

<> 

You may like -nestreg-:


*************
sysuse auto, clear
nestreg : regress price (weight) (length) (mpg) (turn)
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von sara khan
Gesendet: Mittwoch, 10. März 2010 18:32
An: [email protected]
Betreff: Re: st: Adding regression variables one step at a time using a
macro

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 <[email protected]> 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/


*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index