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 on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: generate multi-level dummy


From   Neil Shephard <nshephard@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: generate multi-level dummy
Date   Fri, 22 Oct 2010 15:04:20 +0000

On Fri, Oct 22, 2010 at 2:50 PM, Delahanty, Ryan
<ryan.delahanty@vanderbilt.edu> wrote:
> Hello,
>
> We have a very high dimensional dataset. There are several categorical variables for which we need to get unique ORs for each combination. For example:
>
> Var1=1,2,3...n
> Var2=1,2,3...m
>
> We need to generate all n x m  categories for logistic regression. So our logistic regression can take the form:
>
> Logistic y 11 12 13 ... 1m...21 22 23...2m...nm
>
> This way we can get ORs for all levels from 11 to nm.
>
> What is the easiest way to generate a new dummy variable that has all of these combinations and is still unique?

You don't state which version of Stata you are using (see FAQ), but
providing you're using Stata 11 this is relatively straight-forward
using the syntax for factor variables (see -man fvvarlist- for full
details)...

logistic y i.m#i.n

Of course there are various caveats about primary effect and
interactions and the number of explanatory variables in relation to
the number of observations but that above (should) achieve what you
want to do.

Neil

-- 
"Our civilization would be pitifully immature without the intellectual
revolution led by Darwin" - Motoo Kimura, The Neutral Theory of
Molecular Evolution

Email - nshephard@gmail.com
Website - http://kimura-no-ip.org/
Photos - http://www.flickr.com/photos/slackline/

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