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: stepwise - how to get list of names of variables selected?


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: stepwise - how to get list of names of variables selected?
Date   Fri, 31 Aug 2012 10:22:35 +0100

The problem mentioned is no problem:

local list : subinstr local list "_cons " "", all

Nick

On Fri, Aug 31, 2012 at 10:19 AM, Eveline Nuesch
<[email protected]> wrote:
> Thanks, Nick and Phil for suggestions.
>
> Phil's approach gives a list including _cons, which is not suitable if
> I use it as list of predictors subsequent regressions.
> -indeplist- works fine.
>
> Eveline
>
>>>> Phil Clayton <[email protected]> 31/08/2012 10:03 >>>
> Here's one simple option (which should be fine for your simple command,
> otherwise see the much more sophisticated -indeplist- suggested by
> Nick):
>
> stepwise ...
> matrix b=e(b)
> local xlist_`i': colnames b
>
> Phil
>
> On 31/08/2012, at 6:47 PM, Eveline Nuesch wrote:
>
>> I am using "stepwise" to perform variable selection in logistic
>> regression in 200 simulated datasets. I would like to automatically
> get
>> a list of names of the variables selected (potentially different in
> each
>> dataset) to run subsequent regressions.
>>
>> Does "stepwise" save this somewhere? If yes, how can I access it?
>>
>> *My code so far:
>>
>> foreach i in 1/200 {
>> use data_`i', clear
>> stepwise , pr(.05): logistic y x1 x2 x3 x4 x5 // selects predictor
>> variables (e.g. x2 x3 x5)
>> local xlist_`i' ??? // How can I get this list in an automated
>> fashion?
>> logistic y* `xlist'
>> }
>>
*
*   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