Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[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 <clivelists@googlemail.com>
To   statalist@hsphsun2.harvard.edu
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
<clivenicholas@hotmail.com>. 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index