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: Combining factor variable categories


From   Richard Williams <[email protected]>
To   [email protected]
Subject   st: Combining factor variable categories
Date   Fri, 13 Dec 2013 13:36:28 -0500

I have a friend who wants to combine categories in a factor variable, e.g. 1, 2, 3 = 0, 4, 5 = 1. The challenge is that he wants to do different combos within the same model, e.g. use the 5 category version for main effects and a 2 category version for interactions. He wants margins to work correctly so he doesn't want to first compute different variables and then use them in the model, because margins wouldn't know, for example, that the 5 category version was related to the 2 category version.

I think you could do this via constraints, e.g. something like

webuse nhanes2f, clear
constraint 1 1b.health = 2.health
constraint 2 1b.health = 3.health
constraint 3 4.health = 5.health
logit diabetes i.health, constraint (1/ 3)

Is there some simpler way?

-------------------------------------------
Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
HOME:   (574)289-5227
EMAIL:  [email protected]
WWW:    http://www.nd.edu/~rwilliam

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index