# A regression in R with a categorical response variable

I have a conceptual question.

I have a dataset with a categorical response variable (integers from 1 till 10) and numerical predictors (independent variables).

I want to be able to predict the value (rank, perhaps) from 1 to 10 depending on the values of predictors.

Logistic regression with a family = binomial will not work because the response variable is not binary.

I can think of several options:

1. Convert response variable into a factor variable and run a linear regression

2. keep response variable numeric but round the predictions to the nearest integer using linear regression

3. Try to use multinom() but not sure if it changes anything relative to the approaches above.

What would you recommend for R?

• If the integers are genuinely ranks then you need ordinal regression. If they are integer counts then you can use glm with family = poisson Commented Mar 4, 2022 at 17:20
• Seconding what Allan mentioned. If they are ranks, this package might be useful to you: cran.r-project.org/web/packages/ordinal/vignettes/…
– sjp
Commented Mar 4, 2022 at 17:40
• Count me as another vote for ordinal regression. However, if you find yourself having multiple unordered categories (e.g., dog, cat, horse, alligator), the analogue of logistic regression is multinomial logistic regression, which uses a multinomial response variable instead of a binomial.
– Dave
Commented Mar 4, 2022 at 23:55
• The response variable is an integer number on the scale from 1 to 10: 1 - the worst, 10 - the best. I call them ranks. Of course, it might be better to group 10 ranks into 3 groups: bad, medium, good. That might be advantageous if SVV, KNN or Trees are used. What do you think?
– Toly
Commented Mar 6, 2022 at 0:52

As pointed out in the comments, you need ordinal regression. Here's how you can fit it in R using the polr (proportional odds logistic regression) from the MASS library:

library(MASS)

ordinal_model <- polr(factor(rank_response_variable) ~ indep_var1 + indep_var2, data = data)

summary(ordinal_model)


The model output of cumulative logit models for ordinal responses can be a bit tricky to interpret so feel free to ask for more help in the comments if you need it.

• Luz - The response variable is an integer number on the scale from 1 to 10: 1 - the worst, 10 - the best. I call them ranks. Of course, it might be better to group 10 ranks into 3 groups: bad, medium, good. That might be advantageous if SVV, KNN or Trees are used. What do you think?
– Toly
Commented Mar 6, 2022 at 0:52
• @Toly I think you should use ordinal regression. By taking into account the ordering of the response categories you can have improved model parsimony and power. Commented Mar 7, 2022 at 21:44