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   Phil Clayton <[email protected]>
To   [email protected]
Subject   Re: st: stepwise - how to get list of names of variables selected?
Date   Fri, 31 Aug 2012 19:03:37 +1000

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'
> }
> 
> Any ideas or suggestions are very much appreciated.
> Many thanks. 
> Eveline Nüesch
> *
> *   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/


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