Frequent Links
Generalized linear model
Regression analysis 

File:Linear regression.svg 
Models 

Estimation 
Background 
In statistics, the generalized linear model (GLM) is a flexible generalization of ordinary linear regression that allows for response variables that have error distribution models other than a normal distribution. The GLM generalizes linear regression by allowing the linear model to be related to the response variable via a link function and by allowing the magnitude of the variance of each measurement to be a function of its predicted value.
Generalized linear models were formulated by John Nelder and Robert Wedderburn as a way of unifying various other statistical models, including linear regression, logistic regression and Poisson regression.^{[1]} They proposed an iteratively reweighted least squares method for maximum likelihood estimation of the model parameters. Maximumlikelihood estimation remains popular and is the default method on many statistical computing packages. Other approaches, including Bayesian approaches and least squares fits to variance stabilized responses, have been developed.
Contents
Intuition
Ordinary linear regression predicts the expected value of a given unknown quantity (the response variable, a random variable) as a linear combination of a set of observed values (predictors). This implies that a constant change in a predictor leads to a constant change in the response variable (i.e. a linearresponse model). This is appropriate when the response variable has a normal distribution (intuitively, when a response variable can vary essentially indefinitely in either direction with no fixed "zero value", or more generally for any quantity that only varies by a relatively small amount, e.g. human heights).
However, these assumptions are inappropriate for some types of response variables. For example, in cases where the response variable is expected to be always positive and varying over a wide range, constant input changes lead to geometrically varying, rather than constantly varying, output changes. As an example, a prediction model might predict that 10 degree temperature decrease would lead to 1,000 fewer people visiting the beach is unlikely to generalize well over both small beaches (e.g. those where the expected attendance was 50 at a particular temperature) and large beaches (e.g. those where the expected attendance was 10,000 at a low temperature). The problem with this kind of prediction model would imply a temperature drop of 10 degrees would lead to 1,000 fewer people visiting the beach, a beach whose expected attendance was 50 at a higher temperature would now be predicted to have the impossible attendance value of 950. Logically, a more realistic model would instead predict a constant rate of increased beach attendance (e.g. an increase in 10 degrees leads to a doubling in beach attendance, and a drop in 10 degrees leads to a halving in attendance). Such a model is termed an exponentialresponse model (or loglinear model, since the logarithm of the response is predicted to vary linearly).
Similarly, a model that predicts a probability of making a yes/no choice (a Bernoulli variable) is even less suitable as a linearresponse model, since probabilities are bounded on both ends (they must be between 0 and 1). Imagine, for example, a model that predicts the likelihood of a given person going to the beach as a function of temperature. A reasonable model might predict, for example, that a change in 10 degrees makes a person two times more or less likely to go to the beach. But what does "twice as likely" mean in terms of a probability? It cannot literally mean to double the probability value (e.g. 50% becomes 100%, 75% becomes 150%, etc.). Rather, it is the odds that are doubling: from 2:1 odds, to 4:1 odds, to 8:1 odds, etc. Such a model is a logodds model.
Generalized linear models cover all these situations by allowing for response variables that have arbitrary distributions (rather than simply normal distributions), and for an arbitrary function of the response variable (the link function) to vary linearly with the predicted values (rather than assuming that the response itself must vary linearly). For example, the case above of predicted number of beach attendees would typically be modeled with a Poisson distribution and a log link, while the case of predicted probability of beach attendance would typically be modeled with a Bernoulli distribution (or binomial distribution, depending on exactly how the problem is phrased) and a logodds (or logit) link function.
Overview
In a generalized linear model (GLM), each outcome of the dependent variables, Y, is assumed to be generated from a particular distribution in the exponential family, a large range of probability distributions that includes the normal, binomial, Poisson and gamma distributions, among others. The mean, μ, of the distribution depends on the independent variables, X, through:
 <math>\operatorname{E}(\mathbf{Y}) = \boldsymbol{\mu} = g^{1}(\mathbf{X}\boldsymbol{\beta}) </math>
where E(Y) is the expected value of Y; Xβ is the linear predictor, a linear combination of unknown parameters β; g is the link function.
In this framework, the variance is typically a function, V, of the mean:
 <math> \operatorname{Var}(\mathbf{Y}) = \operatorname{V}( \boldsymbol{\mu} ) = \operatorname{V}(g^{1}(\mathbf{X}\boldsymbol{\beta})). </math>
It is convenient if V follows from the exponential family distribution, but it may simply be that the variance is a function of the predicted value.
The unknown parameters, β, are typically estimated with maximum likelihood, maximum quasilikelihood, or Bayesian techniques.
Model components
The GLM consists of three elements:
 1. A probability distribution from the exponential family.
 2. A linear predictor η = Xβ .
 3. A link function g such that E(Y) = μ = g^{−1}(η).
Probability distribution
The overdispersed exponential family of distributions is a generalization of the exponential family and exponential dispersion model of distributions and includes those probability distributions, parameterized by <math>\boldsymbol\theta</math> and <math>\tau</math>, whose density functions f (or probability mass function, for the case of a discrete distribution) can be expressed in the form
 <math> f_Y(\mathbf{y}  \boldsymbol\theta, \tau) = h(\mathbf{y},\tau) \exp{\left(\frac{\mathbf{b}(\boldsymbol\theta)^{\rm T}\mathbf{T}(y)  A(\boldsymbol\theta)}
{d(\tau)} \right)}. \,\!</math>
<math>\tau</math>, called the dispersion parameter, typically is known and is usually related to the variance of the distribution. The functions <math>h(\mathbf{y},\tau)</math>, <math>\mathbf{b}(\boldsymbol\theta)</math>, <math>\mathbf{T}(y)</math>, <math>A(\boldsymbol\theta)</math>, and <math>d(\tau)</math> are known. Many common distributions are in this family.
For scalar <math>Y</math> and <math>\theta</math>, this reduces to
 <math> f_Y(y  \theta, \tau) = h(y,\tau) \exp{\left(\frac{b(\theta)T(y)  A(\theta)}{d(\tau)} \right)}. \,\!</math>
<math>\boldsymbol\theta</math> is related to the mean of the distribution. If <math>\mathbf{b}(\boldsymbol\theta)</math> is the identity function, then the distribution is said to be in canonical form (or natural form). Note that any distribution can be converted to canonical form by rewriting <math>\boldsymbol\theta</math> as <math>\boldsymbol\theta'</math> and then applying the transformation <math>\boldsymbol\theta = \mathbf{b}(\boldsymbol\theta')</math>. It is always possible to convert <math>A(\boldsymbol\theta)</math> in terms of the new parametrization, even if <math>\mathbf{b}(\boldsymbol\theta')</math> is not a onetoone function; see comments in the page on the exponential family. If, in addition, <math>\mathbf{T}(y)</math> is the identity and <math>\tau</math> is known, then <math>\boldsymbol\theta</math> is called the canonical parameter (or natural parameter) and is related to the mean through
 <math> \boldsymbol\mu = \operatorname{E}(\mathbf{Y}) = \nabla A(\boldsymbol\theta). \,\!</math>
For scalar <math>Y</math> and <math>\theta</math>, this reduces to
 <math> \mu = \operatorname{E}(Y) = A'(\theta). \,\!</math>
Under this scenario, the variance of the distribution can be shown to be^{[2]}
 <math>\operatorname{Var}(\mathbf{Y}) = \nabla\nabla^{\rm T} A(\boldsymbol\theta) d(\tau). \,\!</math>
For scalar <math>Y</math> and <math>\theta</math>, this reduces to
 <math>\operatorname{Var}(Y) = A(\theta) d(\tau). \,\!</math>
Linear predictor
The linear predictor is the quantity which incorporates the information about the independent variables into the model. The symbol η (Greek "eta") denotes a linear predictor. It is related to the expected value of the data (thus, "predictor") through the link function.
η is expressed as linear combinations (thus, "linear") of unknown parameters β. The coefficients of the linear combination are represented as the matrix of independent variables X. η can thus be expressed as
 <math> \eta = \mathbf{X}\boldsymbol{\beta}.\,</math>
Link function
The link function provides the relationship between the linear predictor and the mean of the distribution function. There are many commonly used link functions, and their choice can be somewhat arbitrary. It makes sense to try to match the domain of the link function to the range of the distribution function's mean.
When using a distribution function with a canonical parameter <math>\theta</math>, the canonical link function is the function that expresses <math>\theta</math> in terms of <math>\mu</math>, i.e. <math>\theta = b(\mu)</math>. For the most common distributions, the mean <math>\mu</math> is one of the parameters in the standard form of the distribution's density function, and then <math>b(\mu)</math> is the function as defined above that maps the density function into its canonical form. When using the canonical link function, <math>b(\mu) = \theta = \mathbf{X}\boldsymbol{\beta}</math>, which allows <math>\mathbf{X}^{\rm T} \mathbf{Y}</math> to be a sufficient statistic for <math>\boldsymbol{\beta}</math>.
Following is a table of several exponentialfamily distributions in common use and the data they are typically used for, along with the canonical link functions and their inverses (sometimes referred to as the mean function, as done here).
Distribution  Support of distribution  Typical uses  Link name  Link function  Mean function 

Normal  real: <math>(\infty,+\infty)</math>  Linearresponse data  Identity  <math>\mathbf{X}\boldsymbol{\beta}=\mu\,\!</math>  <math>\mu=\mathbf{X}\boldsymbol{\beta}\,\!</math> 
Exponential  real: <math>(0,+\infty)</math>  Exponentialresponse data, scale parameters  Inverse  <math>\mathbf{X}\boldsymbol{\beta}=\mu^{1}\,\!</math>  <math>\mu=(\mathbf{X}\boldsymbol{\beta})^{1}\,\!</math> 
Gamma  
Inverse Gaussian 
real: <math>(0, +\infty)</math>  Inverse squared 
<math>\mathbf{X}\boldsymbol{\beta}=\mu^{2}\,\!</math>  <math>\mu=(\mathbf{X}\boldsymbol{\beta})^{1/2}\,\!</math>  
Poisson  integer: <math>0,1,2,\ldots</math>  count of occurrences in fixed amount of time/space  Log  <math>\mathbf{X}\boldsymbol{\beta}=\ln{(\mu)}\,\!</math>  <math>\mu=\exp{(\mathbf{X}\boldsymbol{\beta})}\,\!</math> 
Bernoulli  integer: <math>\{0,1\}</math>  outcome of single yes/no occurrence  Logit  <math>\mathbf{X}\boldsymbol{\beta}=\ln{\left(\frac{\mu}{1\mu}\right)}\,\!</math>  <math>\mu=\frac{\exp{(\mathbf{X}\boldsymbol{\beta})}}{1 + \exp{(\mathbf{X}\boldsymbol{\beta})}} = \frac{1}{1 + \exp{(\mathbf{X}\boldsymbol{\beta})}}\,\!</math> 
Binomial  integer: <math>0,1,\ldots,N</math>  count of # of "yes" occurrences out of N yes/no occurrences  
Categorical  integer: <math>[0,K)</math>  outcome of single Kway occurrence  
Kvector of integer: <math>[0,1]</math>, where exactly one element in the vector has the value 1  
Multinomial  Kvector of integer: <math>[0,N]</math>  count of occurrences of different types (1 .. K) out of N total Kway occurrences 
In the cases of the exponential and gamma distributions, the domain of the canonical link function is not the same as the permitted range of the mean. In particular, the linear predictor may be negative, which would give an impossible negative mean. When maximizing the likelihood, precautions must be taken to avoid this. An alternative is to use a noncanonical link function.
Note also that in the case of the Bernoulli, binomial, categorical and multinomial distributions, the support of the distributions is not the same type of data as the parameter being predicted. In all of these cases, the predicted parameter is one or more probabilities, i.e. real numbers in the range <math>[0,1]</math>. The resulting model is known as logistic regression (or multinomial logistic regression in the case that Kway rather than binary values are being predicted).
For the Bernoulli and binomial distributions, the parameter is a single probability, indicating the likelihood of occurrence of a single event. The Bernoulli still satisfies the basic condition of the generalized linear model in that, even though a single outcome will always be either 0 or 1, the expected value will nonetheless be a realvalued probability, i.e. the probability of occurrence of a "yes" (or 1) outcome. Similarly, in a binomial distribution, the expected value is Np, i.e. the expected proportion of "yes" outcomes will be the probability to be predicted.
For categorical and multinomial distributions, the parameter to be predicted is a Kvector of probabilities, with the further restriction that all probabilities must add up to 1. Each probability indicates the likelihood of occurrence of one of the K possible values. For the multinomial distribution, and for the vector form of the categorical distribution, the expected values of the elements of the vector can be related to the predicted probabilities similarly to the binomial and Bernoulli distributions.
Fitting
Maximum likelihood
The maximum likelihood estimates can be found using an iteratively reweighted least squares algorithm using either a Newton–Raphson method with updates of the form:
 <math> \boldsymbol\beta^{(t+1)} = \boldsymbol\beta^{(t)} + \mathcal{J}^{1}(\boldsymbol\beta^{(t)}) u(\boldsymbol\beta^{(t)}), </math>
where <math>\mathcal{J}(\boldsymbol\beta^{(t)})</math> is the observed information matrix (the negative of the Hessian matrix) and <math>u(\boldsymbol\beta^{(t)})</math> is the score function; or a Fisher's scoring method:
 <math> \boldsymbol\beta^{(t+1)} = \boldsymbol\beta^{(t)} + \mathcal{I}^{1}(\boldsymbol\beta^{(t)}) u(\boldsymbol\beta^{(t)}), </math>
where <math>\mathcal{I}(\boldsymbol\beta^{(t)})</math> is the Fisher information matrix. Note that if the canonical link function is used, then they are the same.^{[3]}
Bayesian methods
In general, the posterior distribution cannot be found in closed form and so must be approximated, usually using Laplace approximations or some type of Markov chain Monte Carlo method such as Gibbs sampling.
Examples
General linear models
A possible point of confusion has to do with the distinction between generalized linear models and the general linear model, two broad statistical models. The general linear model may be viewed as a special case of the generalized linear model with identity link and responses normally distributed. As most exact results of interest are obtained only for the general linear model, the general linear model has undergone a somewhat longer historical development. Results for the generalized linear model with nonidentity link are asymptotic (tending to work well with large samples).
Linear regression
A simple, very important example of a generalized linear model (also an example of a general linear model) is linear regression. In linear regression, the use of the leastsquares estimator is justified by the GaussMarkov theorem, which does not assume that the distribution is normal.
From the perspective of generalized linear models, however, it is useful to suppose that the distribution function is the normal distribution with constant variance and the link function is the identity, which is the canonical link if the variance is known.
For the normal distribution, the generalized linear model has a closed form expression for the maximumlikelihood estimates, which is convenient. Most other GLMs lack closed form estimates.
Binomial data
When the response data, Y, are binary (taking on only values 0 and 1), the distribution function is generally chosen to be the Bernoulli distribution and the interpretation of μ_{i} is then the probability, p, of Y_{i} taking on the value one.
There are several popular link functions for binomial functions; the most typical is the canonical logit link:
 <math>g(p) = \ln \left( { p \over 1p } \right).</math>
GLMs with this setup are logistic regression models (or logit models).
In addition, the inverse of any continuous cumulative distribution function (CDF) can be used for the link since the CDF's range is <math>[0,1]</math>, the range of the binomial mean. The normal CDF <math>\Phi</math> is a popular choice and yields the probit model. Its link is
 <math>g(p) = \Phi^{1}(p).\,\!</math>
The reason for the use of the probit model is that a constant scaling of the input variable to a normal CDF (which can be absorbed through equivalent scaling of all of the parameters) yields a function that is practically identical to the logit function, but probit models are more tractable in some situations than logit models. (In a Bayesian setting in which normally distributed prior distributions are placed on the parameters, the relationship between the normal priors and the normal CDF link function means that a probit model can be computed using Gibbs sampling, while a logit model generally cannot.)
The complementary loglog function log(−log(1−p)) may also be used. This link function is asymmetric and will often produce different results from the probit and logit link functions.^{[citation needed]}
The identity link is also sometimes used for binomial data to yield the linear probability model, but a drawback of this model is that the predicted probabilities can be greater than one or less than zero. In implementation it is possible to fix the nonsensical probabilities outside of <math>[0,1]</math>, but interpreting the coefficients can be difficult. The model's primary merit is that near <math>p = 0.5</math> it is approximately a linear transformation of the probit and logit―econometricians sometimes call this the Harvard model.
The variance function for binomial data is given by:
 <math>\operatorname{Var}(Y_{i})= \tau\mu_{i} (1\mu_{i})\,\!</math>
where the dispersion parameter τ is typically fixed at exactly one. When it is not, the resulting quasilikelihood model often described as binomial with overdispersion or quasibinomial.
Multinomial regression
The binomial case may be easily extended to allow for a multinomial distribution as the response (also, a Generalized Linear Model for counts, with a constrained total). There are two ways in which this is usually done:
Ordered response
If the response variable is an ordinal measurement, then one may fit a model function of the form:
 <math> g(\mu_m) = \eta_m = \beta_0 + X_1 \beta_1 + \ldots + X_p \beta_p + \gamma_2 + \ldots + \gamma_m = \eta_1 + \gamma_2 + \ldots + \gamma_m \,</math> where <math> \mu_m = \mathrm{P}(Y \leq m) \,</math>.
for m > 2. Different links g lead to proportional odds models or ordered probit models.
Unordered response
If the response variable is a nominal measurement, or the data do not satisfy the assumptions of an ordered model, one may fit a model of the following form:
 <math> g(\mu_m) = \eta_m = \beta_{m,0} + X_1 \beta_{m,1} + \ldots + X_p \beta_{m,p} \,</math> where <math> \mu_m = \mathrm{P}(Y = m \mid Y \in \{1,m\} ) \,</math>.
for m > 2. Different links g lead to multinomial logit or multinomial probit models. These are more general than the ordered response models, and more parameters are estimated.
Count data
Another example of generalized linear models includes Poisson regression which models count data using the Poisson distribution. The link is typically the logarithm, the canonical link.
The variance function is proportional to the mean
 <math>\operatorname{var}(Y_{i}) = \tau\mu_{i},\, </math>
where the dispersion parameter τ is typically fixed at exactly one. When it is not, the resulting quasilikelihood model is often described as poisson with overdispersion or quasipoisson.
Extensions
The standard GLM assumes that the observations are uncorrelated. Extensions have been developed to allow for correlation between observations, as occurs for example in longitudinal studies and clustered designs:
 Generalized estimating equations (GEEs) allow for the correlation between observations without the use of an explicit probability model for the origin of the correlations, so there is no explicit likelihood. They are suitable when the random effects and their variances are not of inherent interest, as they allow for the correlation without explaining its origin. The focus is on estimating the average response over the population ("populationaveraged" effects) rather than the regression parameters that would enable prediction of the effect of changing one or more components of X on a given individual. GEEs are usually used in conjunction with HuberWhite standard errors.^{[4]}^{[5]}
 Generalized linear mixed models (GLMMs) are an extension to GLMs that includes random effects in the linear predictor, giving an explicit probability model that explains the origin of the correlations. The resulting "subjectspecific" parameter estimates are suitable when the focus is on estimating the effect of changing one or more components of X on a given individual. GLMMs are also referred to as multilevel models and as mixed model. In general, fitting GLMMs is more computationally complex and intensive than fitting GEEs.
Generalized additive models
Generalized additive models (GAMs) are another extension to GLMs in which the linear predictor η is not restricted to be linear in the covariates X but is the sum of smoothing functions applied to the x_{i}s:
 <math>\eta = \beta_0 + f_1(x_1) + f_2(x_2) + \ldots \,\!</math>
The smoothing functions f_{i} are estimated from the data. In general this requires a large number of data points and is computationally intensive.^{[6]}^{[7]}
Confusion with general linear models
The term "generalized linear model", and especially its abbreviation GLM, can be confused with general linear model. John Nelder has expressed regret about this in a conversation with Stephen Senn:
Senn: I must confess to having some confusion when I was a young statistician between general linear models and generalized linear models. Do you regret the terminology?
Nelder: I think probably I do. I suspect we should have found some more fancy name for it that would have stuck and not been confused with the general linear model, although general and generalized are not quite the same. I can see why it might have been better to have thought of something else.^{[8]}
See also
 Comparison of general and generalized linear models
 Generalized linear array model
 Tweedie distributions
 GLIM (software)
 Natural exponential family
Notes
 ^ Nelder, John; Wedderburn, Robert (1972). "Generalized Linear Models". Journal of the Royal Statistical Society. Series A (General) (Blackwell Publishing) 135 (3): 370–384. JSTOR 2344614. doi:10.2307/2344614.
 ^ McCullagh and Nelder (1989), Chapter 2.
 ^ McCullagh and Nelder (1989), Page 43.
 ^ Zeger, Scott L.; Liang, KungYee; Albert, Paul S. (1988). "Models for Longitudinal Data: A Generalized Estimating Equation Approach". Biometrics (International Biometric Society) 44 (4): 1049–1060. JSTOR 2531734. PMID 3233245. doi:10.2307/2531734.
 ^ Hardin, James; Hilbe, Joseph (2003). Generalized Estimating Equations. London: Chapman and Hall/CRC. ISBN 1584883073.
 ^ Hastie & Tibshirani 1990.
 ^ Wood 2006.
 ^ Senn, Stephen (2003). "A conversation with John Nelder". Statistical Science 18 (1): 118–131. doi:10.1214/ss/1056397489.
References
 Hastie, T. J.; Tibshirani, R. J. (1990). Generalized Additive Models. Chapman & Hall/CRC. ISBN 9780412343902.
 Madsen, Henrik, and Thyregod, Poul (2011). Introduction to General and Generalized Linear Models. Chapman & Hall/CRC. ISBN 9781420091557.
 McCullagh, Peter; Nelder, John (1989). Generalized Linear Models, Second Edition. Boca Raton: Chapman and Hall/CRC. ISBN 0412317605.
 Wood, Simon (2006). Generalized Additive Models: An Introduction with R. Chapman & Hall/CRC. ISBN 1584884746.
Further reading
 Dobson, A.J.; Barnett, A.G. (2008). Introduction to Generalized Linear Models (3rd ed.). Boca Raton, FL: Chapman and Hall/CRC. ISBN 1584881658.
 Hardin, James; Hilbe, Joseph (2007). Generalized Linear Models and Extensions (2nd ed.). College Station: Stata Press. ISBN 1597180149.
External links
 Systems Analysis, Modelling and Prediction (SAMP), University of Oxford
 John Nelder FRS
 Royal Society citation for Nelder
