# Categorical variables in multinomial logistic regression end up converted into binary variables

When I run multinomial logistic regression with some of the explanatory variables as categorical, my algo (glm) turns them in binary variables, automatically. For examples if one categorical variable X has three values a, b anc c, then my output shows cofficient and t-values for x.a, x.b and x.c.

But in fact I want t-value at the level of x itself so that I can see if variable X is significant or not in determination of dependent variable. Can you please suggest some way so that I can see output directly at the level of X?

• What package are you using? (This has nothing to do with your question, but it might help if someone is willing to help with an illustrative reply.) – chl Mar 20 '12 at 20:58
• What about a Dirichlet-Regression? cran.r-project.org/web/packages/DirichletReg/index.html – EDi Mar 20 '12 at 21:15
• What is X? If X is ordinal there might be something to do, but if it is nominal, I don't really see how the question makes sense. What do you mean "directly at the level of X"? The dummy variables are at the level of X. – Peter Flom Mar 20 '12 at 21:35
• @chl - I am using S+ (Spotfire) for my analysis and generalized linear model (glm) algorithm for this. – Raghvendra Mar 20 '12 at 22:56
• @Peter Flom - Peter, I would try to explain myself a bit more. Say X is "type of occupation". Now this variable would have some 6-7 possible values. Through this regression, I want to see if Occupation plays an important role in determination of dependent variable (which is again a categorical variable). In current output I see t-values and cofficient generated for each value like X.Banker, X.Consultant etc. I want to see what are the t-value of X in determination of dependent var. If not possible through this, I may try contingency tables. Hope this explanation helps. – Raghvendra Mar 20 '12 at 23:02

## 2 Answers

To test whether or not a factor is related to your response variable, you need to assess the factor as a whole. That means that you cannot use the t-tests that are reported for the individual levels of the factor. Instead, you need to conduct a 'simultaneous' test. As @Will notes, this is done by dropping all levels of the factor, refitting the model, and conducting a nested model test. More information can be gleaned from this question and my answer there.

On a different note, you mention that your objective is to "see if any particular variable (which is categorical in nature) influences dependent variable enough to be kept in model". I don't want to be too critical, but this is a very bad idea, unless you are only thinking of your project as exploratory and you intend to draw an entirely new sample in which to test the resulting model. More specifically, the model parameter estimates that you come to in this way will be badly biased, and inferential statistics (such as p-values) will not mean what they are purported to mean. If that doesn't make sense, there is more information on that topic here.

I too am not sure exactly what you're asking.

If the variable is truly nominal then the results will be relative to the omitted (reference) category. However, this can be overcome, in Stata 12 at least, with the contrast command which performs anova style contrasts.

contrast var


This will test whether the mean outcome is the same for all groups of your variable (i.e. does the outcome vary significantly across the categories of your nominal variable?).

Depending on your model you could also use a lrtest to see if the model fit improves significantly when the dummies are added.

The bottom line, though, is that if any dummy is significant then you can safely conclude that your variable -on the whole- has a significant effect.

You can also use Stata's contrast command to see if categories of your variable can be safely combined - this may also be of interest to you.

EDITED to add: Probably the simplest approach would be to run the model with all the dummies, then simply drop those that aren't significant and keep those that are. This would accomplish pretty much the same thing as creating 50 different contingency tables with 50 separate chi square tests. The problem with either of these approaches is that at the standard .05 alpha level we expect 1 out of every 5 statistically significant effects to actually be null in the population. In other words, there's an error rate associated with significance tests - the error rate is small but when you go data-mining through a huge number of variables then the expected frequency of errors becomes large enough to be a concern.

What you should do in this case is let theory or common sense guide you a bit and then construct a well thought out model and test it. This is a better approach then simply throwing everything including the kitchen sink into the model.

Remember, if you ask, "does occupation matter?" then the answer is yes if any one occupational dummy has a significant effect.

If you must ignore my plea for theory over data mining then one sensible data-driven method of collapsing your categories would be factor analysis. Here again, though, I would recommend confirmatory over exploratory.
EDIT: as I thought about this a bit more, I don't think factor analysis or SEM would be apposite here. So please disregard that bad advice.

• Thanks Will for your suggestions. I particularly like your suggestion that "if any dummy is significant then you can safely conclude that your variable -on the whole- has a significant effect". However problem here is that some of the categorical variables have a large number of different nominal values. For an example, explanatory variable "occupation" may have some 50 different values. My current model goes on to create some 50 dummy variables and then it becomes difficult. – Raghvendra Mar 21 '12 at 5:05
• That's a different problem. In that case, you may have to combine categories. – Peter Flom Mar 21 '12 at 10:37
• @Raghvendra, I see. Peter Flom is correct, you need to collapse your occupational categories. Personally, I would do this substantively - ask yourself, what substantive distinctions between occupations 'ought' to impact the outcome? Then create your occupational categories accordingly. The more data oriented among us will probably suggest you contrast your categories against each other to see which can be collapsed. Of course that will be an undertaking in itself with 50 different occupations. – Will Mar 21 '12 at 15:07
• Oh, and I'm not at all familiar with Spotfire so I can't make suggestions as to how to actually 'do' any of this in that program. Sorry I can't be of more help. – Will Mar 21 '12 at 15:08
• @Will, Thanks for your suggestions. I understand your point here but collapsing of categories is not something I can take as viable option. My objective of this analysis is too see if any particular variable (which is categorical in nature) influences dependent variable enough to be kept in model. I was counting on t-value for that determination. But I think alternatively I can use contingency tables and tests like Chi-Square etc. for similar determination. Let me know if you have any thoughts on that. Thanks for all the help that you provided till now. – Raghvendra Mar 21 '12 at 17:04