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]

st: RE: selectvars and factor variables


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: selectvars and factor variables
Date   Wed, 26 Jan 2011 13:08:21 +0000

I think that distinct issues are in danger of being confused here. 

1. In any recent Stata, you can apply -xi:- or any other procedure to create indicator (a.k.a. dummy) variables and then feed those names to -selectvars- (SSC) as part or whole of a varlist. 

2. Stata 11 (only!) introduced factor variables. It is not quite that -selectvars-, which was written for Stata 8, does not allow factor variables: the situation is rather that is ignorant of them and cannot make sense of them. (-xi:- did some of what is now possible in 11, but is in principle quite distinct from this functionality.)  

Your question seems to mix elements of 1 and 2. As far as -selectvars- is concerned, sorry, but I have no impulse to update it. -tuples- (SSC) is nearer my idea of a tool that should be provided, but it's not smart about factor variables either. You're welcome to copy part or all of the code for either, subject to the usual courtesies. 

The deeper question is why you want to do this. I guess it is because you want to generate lots of different models, the models differing on which predictors are offered. It seems to me that such a procedure needs to be especially smart where indicators are concerned, as often (but not always) indicators are best offered together. 

I'd look at -nestreg- and 

SJ-10-4 st0213  . . . . . . . . . . .  Variable selection in linear regression
        (help vselect if installed) . . . . . . . . C. Lindsey and S. Sheather
        Q4/10   SJ 10(4):650--669
        performs variable selection after a linear regression

which, if my guess is right, may help your purpose. 

Nick 
[email protected] 

A Loumiotis

I would like to use the package selectvars written by Nick Cox but my
variable list contains factor variables and selectvars does not allow
factor variables.  So I would like to substitute in my variable list
the factor variables with the dummy variables that "xi:" creates and
then run selectvars on my expanded variable list.  How can I do that?

For example:

local myvarlist var1 var2 i.var3 // where var3 is categorical with
four categories
local myevarlist var1 var2 Ivar3_2-4
selectvars `myevarlist', min(2) max(2)

My question is how to create myevarlist from myvarlist?

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