- Published on
Multinomial Logit Model
- Authors
- Name
- Kevin Navarrete-Parra
I am writing quick and easy R guides for my didactic purposes and to provide useful starting places for my peers in grad school. If you see that I have made a mistake or would like to suggest some way to make the post better or more accurate, please feel free to email me. I am always happy to learn from others' experiences!
Table of contents
Model Formula
The multinomial logistic regression is used for nominal response variables with multiple unordered categories, like party ID variables. You can also use this for an ordinal response variable, assuming the proportional odds assumption doesn't hold. This model differs from the proportional odds and partial proportional odds models because it compares the odds of being in a given category against the odds of being in the baseline category. Recall that the PO and PPO models compare the odds of being at or below a given category. The multinomial logit model can be expressed as
where . J is the baseline category, which can be any category but is usually the highest. represents the intercepts and the beta values represent the logit coefficients. This model is similar to the generalized ordinal logit model in that it estimates logit coefficients for each independent variable.
As you can see, this model is essentially a series of logit models, where being in a given category is coded as 1 and being in the baseline is a 0.
It's important to note that this model assumes the dependent variable follows the multinomial distribution, which is an extension of the binomial distribution. The binomial distribution can be expressed as
where is the binomial coefficient, k is the number of successes (1), n is the number of trials, and p is the success probability when the outcome is 1. Therefore,
Since our model has a response variable with multiple categories, the probability function can be expressed as
where j is the number of categories in the response, is the number of observations for a given category, and is the probability of choosing a given category.
The log-likelihood function for the multinomial distribution can be expressed as
where is a constant term and does not involve parameter p. is the sum of the number of observations for a given category and the log probability of choosing that category.
Conditional Probabilities and Odds Ratios
If you want to calculate the odds of being in a category as opposed to the baseline, you can express the equation as
The odds ratios for this model function almost exactly like those for the logit model.
Running it in R
There are three packages you can use to run the multinomial logit model: VGAM
, nnet
, and mlogit
. Using VGAM
, you can run the vglm
function. nnet
uses the multinom
function. And mlogit
uses the mlogit
function. The syntax for the vglm
function is
mlm.mod <- vglm(dv ~ iv1 + iv2 + ivp, multinomial(refLevel = 1), data = data)
summary(mlm.mod)
where multinomial is the family function and the refLevel argument indicates which level will serve as the baseline.
After running the code above, make sure to generate an odds ratio table, which can be done by running the following code:
mlm.or <- cbind(exp(coef(mlm.mod)), exp(confint(mlm.mod)))
Diagnostic Statistics
The diagnostic statistics for this model are exactly the same as those for the logit model.