# Logistic Regression for non-binary classification (multi-class) in R

I am trying to use glm(family = binomial(link = 'logit')) for a classification task with 14 classes. I know that logistic regression is used in R for binary classification and as a result it outputs the probabilities for the predicted value being either 0 or 1. But is it possible to also use it for a non-binary classification task?

I have 14 classes and 93 features in my dataset.

This is how I have written it, and of course it does not work, because this is the approach that I use when I only have two classes;

log.model <- glm(fold1\$class ~ . - id, data=fold1, family = binomial(link = 'logit'))
predict.glm(log.model, newdata=fold1.test.set, type = "response")

• You have tagged your question with multinomial-logit which is what you are looking for. Perhaps revising some of the questions and answers there might help you? – mdewey Dec 18 '16 at 14:40
• @mdewey: well, it was me doing the re-tagging, so that people following the relevant tag can see the post ... – kjetil b halvorsen Dec 18 '16 at 15:17
• @kjetilbhalvorsen mystery solved, I did wonder why the OP had tagged it. – mdewey Dec 18 '16 at 15:52

As you note glm won't do it: the family=binomial part, implies two-way, not multi-way.
To look through packages you already have installed, try ??multinomial and look through the results. Among others the nnet package has a multinom, and there are several Bayesian R packages that support multinomial logistic regression including brms. (You can also do searches like ??"multinomial logistic" or ??"ordinal logistic".) For packages you don't have installed, search on CRAN.
• Great answer. I just tried multinom and it worked perfectly, but the misclassification error is disastrous. equal to 82% – l.. Dec 18 '16 at 19:25