# Can I use a polytomous categorical independent variable in logistic regression?

I found a few similar questions, but none quite had the answer I was looking for.

I aim to use logistic regression and have two IVs ("Independent Variables") that each have three categories. I have only seen IVs in ordinal logistic regression that have been continuous or binary categorical previously. I also cannot convert these IVs to a continuous format, as this will change the interpretability of the variables.

Am I able to include these IVs in their current state, or should I be looking to use another algorithm here? (E.g. decision tree?)

Thanks.

• If an IV is nominal, you should code it as a set of contrast variables (see Nick Stauner's answer). If an IV is ordinal (and you don't want to think back and treat it as nominal or interval) then, well, you might a) rank its values first, b) use optimal scaling categorical regression, c) use decision tree. See a related topic on correlating nominal and ordinal variables. Jan 7 '14 at 7:31

Here's an answer from a different forum about how you might use coding to handle your polytomous variables in regression in general; the original question was about logistic regression here too, so this corroborates other answers here that logistic vs. linear regression isn't an important distinction in the use of coding for polytomous variables. Here's another answer on Cross Validated from @StasK that answers a question just like yours, again suggesting coding.

However, in @GaetanLion's answer to one of those similar questions, some discussion of a drawback of coding appears (mostly interpretive complexity, I think) to emphasize that coding may not be necessary depending on your statistical software. On the other hand, judging from @gung's answer to another very similar question about the interpretive complexity of an analysis like yours, some software may code automatically, and different tests are necessary for estimating the significance of the polytomous factor as a whole (as opposed to particular levels).

• The thread from the alternative forum looks good Nick. Appreciate it Jan 7 '14 at 0:30

Yes, you can include categorical variables with multiple levels in logistic regression.

Whether trees are a good alternative is another question.

• Many thanks for your reply Peter. It is much appreciated. Jan 7 '14 at 0:09

Categorical IVs with more than two groups are perfectly fine for a logistic regression, just like multiple regression. If the dependent variable is more than two groups, however, then a multinomial logistic regression is appropriate. The UCLA website has a great tutorial for ordinal logistic regression in R. The example used only has a categorical predictor with 2 levels, but the same logic applies (much like in a multiple regression).

• Great @dmartin. I only have the two groups in my dependent variable, so ordinal logistic regression should be appropriate. Jan 7 '14 at 0:12
• If you have two groups in your dependent variable, that's logistic regression plain and simple. Jan 7 '14 at 0:17