Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: saving a sample after a regression


From   Richard Williams <[email protected]>
To   [email protected], [email protected]
Subject   Re: st: saving a sample after a regression
Date   Mon, 12 Mar 2007 15:56:46 -0500

At 02:47 PM 3/12/2007, william.miles wrote:
Hi-
I am running regressions with several variables, and not all observations have
data on all variables. I run a regression of Y on X, and use say 1,000
observations. Then I run a regression of Y on X and Z, and because not all
observations have Z, I only get a sample of 800 observations. Is there any
way to save the sample from the latter regression, so I can then run the
original regression of Y on only X, but using only the 800 observations that
include Z, without having to go throught the data by hand?
Thanks,
Bill
Consider using nestreg, e.g.

nestreg: reg y x z

This will first regress y on x and then y on x and z. It will use listwise deletion, and for an added bonus it will give you incremental f tests at the end testing the vars added at each stage.

Alternatively, consider something like

gen touse = !missing(y, x1, x2, x3, x4)
reg y x1 x2 x3 if touse

Or, yet another trick:

reg y x z
reg y x if e(sample)

-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME: (574)289-5227
EMAIL: [email protected]
WWW: http://www.nd.edu/~rwilliam

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index