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]

Re: st: svy, stepwise, and xi, with a by(variable) tacked on for good measure


From   Clive Nicholas <[email protected]>
To   [email protected]
Subject   Re: st: svy, stepwise, and xi, with a by(variable) tacked on for good measure
Date   Thu, 29 Jul 2010 20:44:46 +0100

Michael Costello wrote:

> Statalist,
>
> I have a data set that looks like this:
> yvar
> xvar1
> xvar2
> xvar3
> xvar4 where xvar4 is categorical with 6 levels
>
> The data is weighted with the svy command.  I would like to do a backwards selection.
>
>
> What works:
> xi i.var4
> stepwise, pr(.05): regress yvar xvar1 xvar2 xvar3 _Ixvar4_2 _Ixvar4_3 _Ixvar4_4 _Ixvar4_5 _Ixvar4_6 [pw=wt_final]
>
>
> but when I use
> xi i.var4
> by (year), stepwise, pr(.05): regress yvar xvar1 xvar2 xvar3 _Ixvar4_2 _Ixvar4_3 _Ixvar4_4 _Ixvar4_5 _Ixvar4_6 [pw=wt_final]
>
> stata flips out, even though http://www.stata.com/help.cgi?stepwise says it should work (second line under the syntax, options box).
>
> And is this even doing the weights?  I'm used to using the svy functions.
> Lastly, is there a more succinct way of doing categorical variables?  I have several, and this process for including them is annoying.  I cannot get the xi: function to work either.  Wait, is there a limit on the number of parameters BEFORE the colon?
>
> Thanks so much for any guidance you can give.

Seriously, don't bother with -stepwise- and stick to estimating the
full model using -regress-, -svy regress- or whatever it is you're
using: stepwise regression just produces lots of garbage that you
don't need to read. That said, the following code works for me using
the -bysort- command:

webuse nhanes2
svyset psu [pweight=leadwt], strata(strata)
xi: bysort region: stepwise, pr(.05): regress loglead age female black
orace i.hsizgp ///
smsa1 smsa2 [pw=leadwt]

-- 
Clive Nicholas

[Please DO NOT mail me personally here, but at
<[email protected]>. Please respond to contributions I make in
a list thread here. Thanks!]

"My colleagues in the social sciences talk a great deal about
methodology. I prefer to call it style." -- Freeman J. Dyson.

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