Statalist The Stata Listserver


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

st: RE: running regressions on only certain sections of the data


From   "Maarten Buis" <[email protected]>
To   <[email protected]>
Subject   st: RE: running regressions on only certain sections of the data
Date   Mon, 19 Feb 2007 17:45:23 +0100

--- T.J. Volant wrote:
>  I have a big data set and am trying to run regressions
> on various combinations of sections. Is there a way to
> do this w/out having to drop irrelevant observations
> every time?
> Example:
> A y1 x1
> A y2 x2
> B y3 x3
> B y4 x4
> C y5 x5
> C y6 x6
> 
> Running y on x only for the A section without having
> to drop all B and C observations. Then regress y on x
> for AC, for AB, etc.
 
I am assuming that you have a variable called section, 
which contains the strings A, B, or C.
to do the regression you requested you would type:
reg y x if section == "A"
reg y x if section == "A" | section == "C"
reg y x if section == "A" | section == "B"

For more info see: - help if- and -help operator- 

hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology 
Vrije Universiteit Amsterdam 
Boelelaan 1081 
1081 HV Amsterdam 
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434 

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------
 

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