Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: Combining factor variable categories

From   Richard Williams <>
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 =
constraint 2 =
constraint 3 =
logit diabetes, 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:  Richard.A.Williams.5@ND.Edu

*   For searches and help try:

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