I need to make a logistic regression classifier to classify this categorical variable that can have 14 different values. Does anyone know if it is possible to do this with glm () or if I have to use another function (and what)?
I need to make a logistic regression classifier to classify this categorical variable that can have 14 different values. Does anyone know if it is possible to do this with glm () or if I have to use another function (and what)?
By definition, logistic regression can only be used to fit models where the answer is dichotomous: yes and no, success and failure, male and female.
A set of data whose response variable is categorical with 14 different levels can not have a logistic regression model fitted to it. For this, the Multinomial Regression is used (there is no entry in the wiki pt regarding this statistical model).
The R
is able to fit a model of this type through the command multinom
:
library(nnet)
?multinom
However, these models are more complicated to interpret than logistic regression models. I suggest Alan Agresti's book Categorical Data Analysis as a reference source. It is an excellent book in theoretical and reasonably didactic part. It has at least one whole chapter dedicated to the analysis of this type of model.
In addition, 14 levels is a fairly high number of levels. I have never set a multinomial model with so many levels like this. I do not know how a model of these would behave or even if it would be adjusted, as there may be numerical stability problems. I imagine that if the sample size is small, it is possible that the Type II error rate especially if the estimators have a high standard error.