Multinomial logistic regression
This article needs additional citations for verification. (November 2011) |
Part of a series on |
Regression analysis |
---|
Models |
Estimation |
|
Background |
|
In
Multinomial logistic regression is known by a variety of other names, including polytomous LR,
Background
Multinomial logistic regression is used when the
- Which major will a college student choose, given their grades, stated likes and dislikes, etc.?
- Which blood type does a person have, given the results of various diagnostic tests?
- In a hands-free mobile phone dialing application, which person's name was spoken, given various properties of the speech signal?
- Which candidate will a person vote for, given particular demographic characteristics?
- Which country will a firm locate an office in, given the characteristics of the firm and of the various candidate countries?
These are all
Assumptions
The multinomial logistic model assumes that data are case-specific; that is, each independent variable has a single value for each case. As with other types of regression, there is no need for the independent variables to be
If the multinomial logit is used to model choices, it relies on the assumption of
If the multinomial logit is used to model choices, it may in some situations impose too much constraint on the relative preferences between the different alternatives. It is especially important to take into account if the analysis aims to predict how choices would change if one alternative were to disappear (for instance if one political candidate withdraws from a three candidate race). Other models like the
Model
Introduction
There are multiple equivalent ways to describe the mathematical model underlying multinomial logistic regression. This can make it difficult to compare different treatments of the subject in different texts. The article on logistic regression presents a number of equivalent formulations of simple logistic regression, and many of these have analogues in the multinomial logit model.
The idea behind all of them, as in many other statistical classification techniques, is to construct a linear predictor function that constructs a score from a set of weights that are linearly combined with the explanatory variables (features) of a given observation using a dot product:
where Xi is the vector of explanatory variables describing observation i, βk is a vector of weights (or
The difference between the multinomial logit model and numerous other methods, models, algorithms, etc. with the same basic setup (the
Setup
The basic setup is the same as in
Data points
Specifically, it is assumed that we have a series of N observed data points. Each data point i (ranging from 1 to N) consists of a set of M explanatory variables x1,i ... xM,i (also known as
Some examples:
- The observed outcomes are different variants of a disease such as hepatitis (possibly including "no disease" and/or other related diseases) in a set of patients, and the explanatory variables might be characteristics of the patients thought to be pertinent (sex, race, age, blood pressure, outcomes of various liver-function tests, etc.). The goal is then to predict which disease is causing the observed liver-related symptoms in a new patient.
- The observed outcomes are the party chosen by a set of people in an election, and the explanatory variables are the demographic characteristics of each person (e.g. sex, race, age, income, etc.). The goal is then to predict the likely vote of a new voter with given characteristics.
Linear predictor
As in other forms of linear regression, multinomial logistic regression uses a linear predictor function to predict the probability that observation i has outcome k, of the following form:
where is a
where is the set of regression coefficients associated with outcome k, and (a row vector) is the set of explanatory variables associated with observation i.
As a set of independent binary regressions
To arrive at the multinomial logit model, one can imagine, for K possible outcomes, running K-1 independent binary logistic regression models, in which one outcome is chosen as a "pivot" and then the other K-1 outcomes are separately regressed against the pivot outcome. If outcome K (the last outcome) is chosen as the pivot, the K-1 regression equations are:
- .
This formulation is also known as the Additive Log Ratio transform commonly used in compositional data analysis. In other applications it’s referred to as “relative risk”.[7]
If we exponentiate both sides and solve for the probabilities, we get:
Using the fact that all K of the probabilities must sum to one, we find:
- .
We can use this to find the other probabilities:
- .
The fact that we run multiple regressions reveals why the model relies on the assumption of independence of irrelevant alternatives described above.
Estimating the coefficients
The unknown parameters in each vector βk are typically jointly estimated by
As a log-linear model
The formulation of binary logistic regression as a
- .
As in the binary case, we need an extra term to ensure that the whole set of probabilities forms a probability distribution, i.e. so that they all sum to one:
The reason why we need to add a term to ensure normalization, rather than multiply as is usual, is because we have taken the logarithm of the probabilities. Exponentiating both sides turns the additive term into a multiplicative factor, so that the probability is just the Gibbs measure:
- .
The quantity Z is called the partition function for the distribution. We can compute the value of the partition function by applying the above constraint that requires all probabilities to sum to 1:
Therefore:
Note that this factor is "constant" in the sense that it is not a function of Yi, which is the variable over which the probability distribution is defined. However, it is definitely not constant with respect to the explanatory variables, or crucially, with respect to the unknown regression coefficients βk, which we will need to determine through some sort of optimization procedure.
The resulting equations for the probabilities are
- .
Or generally:
The following function:
is referred to as the softmax function. The reason is that the effect of exponentiating the values is to exaggerate the differences between them. As a result, will return a value close to 0 whenever is significantly less than the maximum of all the values, and will return a value close to 1 when applied to the maximum value, unless it is extremely close to the next-largest value. Thus, the softmax function can be used to construct a
Thus, we can write the probability equations as
The softmax function thus serves as the equivalent of the logistic function in binary logistic regression.
Note that not all of the vectors of coefficients are uniquely identifiable. This is due to the fact that all probabilities must sum to 1, making one of them completely determined once all the rest are known. As a result, there are only separately specifiable probabilities, and hence separately identifiable vectors of coefficients. One way to see this is to note that if we add a constant vector to all of the coefficient vectors, the equations are identical:
As a result, it is conventional to set (or alternatively, one of the other coefficient vectors). Essentially, we set the constant so that one of the vectors becomes 0, and all of the other vectors get transformed into the difference between those vectors and the vector we chose. This is equivalent to "pivoting" around one of the K choices, and examining how much better or worse all of the other K-1 choices are, relative to the choice we are pivoting around. Mathematically, we transform the coefficients as follows:
This leads to the following equations:
Other than the prime symbols on the regression coefficients, this is exactly the same as the form of the model described above, in terms of K-1 independent two-way regressions.
As a latent-variable model
It is also possible to formulate multinomial logistic regression as a latent variable model, following the two-way latent variable model described for binary logistic regression. This formulation is common in the theory of discrete choice models, and makes it easier to compare multinomial logistic regression to the related multinomial probit model, as well as to extend it to more complex models.
Imagine that, for each data point i and possible outcome k=1,2,...,K, there is a continuous
where i.e. a standard type-1
This latent variable can be thought of as the utility associated with data point i choosing outcome k, where there is some randomness in the actual amount of utility obtained, which accounts for other unmodeled factors that go into the choice. The value of the actual variable is then determined in a non-random fashion from these latent variables (i.e. the randomness has been moved from the observed outcomes into the latent variables), where outcome k is chosen if and only if the associated utility (the value of ) is greater than the utilities of all the other choices, i.e. if the utility associated with outcome k is the maximum of all the utilities. Since the latent variables are
Or equivalently:
Let's look more closely at the first equation, which we can write as follows:
There are a few things to realize here:
- In general, if and then That is, the difference of two independent identically distributed extreme-value-distributed variables follows the logistic distribution, where the first parameter is unimportant. This is understandable since the first parameter is a location parameter, i.e. it shifts the mean by a fixed amount, and if two values are both shifted by the same amount, their difference remains the same. This means that all of the relational statements underlying the probability of a given choice involve the logistic distribution, which makes the initial choice of the extreme-value distribution, which seemed rather arbitrary, somewhat more understandable.
- The second parameter in an extreme-value or logistic distribution is a scale parameter, such that if then This means that the effect of using an error variable with an arbitrary scale parameter in place of scale 1 can be compensated simply by multiplying all regression vectors by the same scale. Together with the previous point, this shows that the use of a standard extreme-value distribution (location 0, scale 1) for the error variables entails no loss of generality over using an arbitrary extreme-value distribution. In fact, the model is nonidentifiable(no single set of optimal coefficients) if the more general distribution is used.
- Because only differences of vectors of regression coefficients are used, adding an arbitrary constant to all coefficient vectors has no effect on the model. This means that, just as in the log-linear model, only K-1 of the coefficient vectors are identifiable, and the last one can be set to an arbitrary value (e.g. 0).
Actually finding the values of the above probabilities is somewhat difficult, and is a problem of computing a particular order statistic (the first, i.e. maximum) of a set of values. However, it can be shown that the resulting expressions are the same as in above formulations, i.e. the two are equivalent.
Estimation of intercept
When using multinomial logistic regression, one category of the dependent variable is chosen as the reference category. Separate odds ratios are determined for all independent variables for each category of the dependent variable with the exception of the reference category, which is omitted from the analysis. The exponential beta coefficient represents the change in the odds of the dependent variable being in a particular category vis-a-vis the reference category, associated with a one unit change of the corresponding independent variable.
Likelihood function
The observed values for of the explained variables are considered as realizations of stochastically independent, categorically distributed random variables .
The likelihood function for this model is defined by:
- where the index denotes the observations 1 to n and the index denotes the classes 1 to K. is the Kronecker delta.
The negative log-likelihood function is therefore the well-known cross-entropy: :
Application in natural language processing
In
See also
References
- ISBN 978-0-273-75356-8.
- .
- ISBN 9780761922087.
- ^ a b Malouf, Robert (2002). A comparison of algorithms for maximum entropy parameter estimation (PDF). Sixth Conf. on Natural Language Learning (CoNLL). pp. 49–55.
- ISBN 9780471528890.
- .
- ^ Stata Manual “mlogit — Multinomial (polytomous) logistic regression”
- .
- ^ Bishop, Christopher M. (2006). Pattern Recognition and Machine Learning. Springer. pp. 206–209.
- .