# Generalized linear model

In statistics, the generalized linear model (GLM) is a useful generalization of ordinary least squares regression. It relates the random distribution of the measured variable of the experiment (the distribution function) to the systematic (non-random) portion of the experiment (the linear predictor) through a function called the link function.

The subject of generalized linear models was formulated by John Nelder and Robert Wedderburn as a way of unifying various other statistical models under one framework, allowing for one general method of efficiently performing maximum likelihood estimation for these models.

## Overview

In a GLM, each outcome of the dependent variable Y is assumed to be generated from a particular distribution function in the exponential family (a large range of probability distributions). The mean μ of the distribution depends on the independent variables X through:

$\operatorname {E} (\mathbf {Y} )={\boldsymbol {\mu }}=g^{-1}(\mathbf {X} {\boldsymbol {\beta }})$ where is the linear predictor, a linear combination of unknown parameters β, and g is called the link function.

In this framework, the variance is typically a function V of the mean:

$\operatorname {Var} (\mathbf {Y} )=\operatorname {V} ({\boldsymbol {\mu }})=\operatorname {V} (g^{-1}(\mathbf {X} {\boldsymbol {\beta }})).$ 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, quasi-maximum likelihood, or Bayesian techniques.

## Model components

The GLM consists of three elements.

1. A distribution function f, from the exponential family.
2. A linear predictor η = X β.
3. A link function g such that E(Y) = μ = g-1(η).

### Exponential family

The exponential family of distributions are those probability distributions, parameterized by θ and τ, whose density functions f (or probability mass function, for the case of a discrete distribution) can be expressed in the form

$f_{Y}(y;\theta ,\tau )=\exp {\left({\frac {a(y)b(\theta )+c(\theta )}{h(\tau )}}+d(y,\tau )\right)}.\,\!$ τ, called the dispersion parameter, typically is known and is usually related to the variance of the distribution. The functions a, b, c, d, and h are known. Many, although not all, common distributions are in this family.

θ is related to the mean of the distribution. If a is the identity function, then the distribution is said to be in canonical form. If, in addition, b is the identity and τ is known, then θ is called the canonical parameter and is related to the mean through

$\mu =\operatorname {E} (Y)=-c'(\theta ).\,\!$ Under this scenario, the variance of the distribution can be shown to be

$\operatorname {Var} (Y)=-c''(\theta )h(\tau ).\,\!$ ### Linear predictor

The linear predictor is the quantity which incorporates the information about the independent variables into the model. The symbol η (Greek "eta") is typically used to denote 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

$\eta =\mathbf {X} \beta .\,$ The elements of X are either measured by the experimenters or stipulated by them in the modeling design process.

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 can be convenient 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 θ, a link function exists which allows for XTY to be a sufficient statistic for β. This occurs when the link function equates θ and the linear predictor. Following is a table of canonical link functions and their inverses (sometimes referred to as the mean function, as done here) used for several distributions in the exponential family.

Distribution Name Link Function Mean Function
Normal Identity $\mathbf {X} \beta =\mu \,\!$ $\mu =\mathbf {X} \beta \,\!$ Exponential Inverse $\mathbf {X} \beta =\mu ^{-1}\,\!$ $\mu =(\mathbf {X} \beta )^{-1}\,\!$ Gamma
Inverse
Gaussian
Inverse
squared
$\mathbf {X} \beta =\mu ^{-2}\,\!$ $\mu =(\mathbf {X} \beta )^{-1/2}\,\!$ Poisson Log $\mathbf {X} \beta =\ln {(\mu )}\,\!$ $\mu =\exp {(\mathbf {X} \beta )}\,\!$ Binomial Logit $\mathbf {X} \beta =\ln {\left({\frac {\mu }{1-\mu }}\right)}\,\!$ $\mu ={\frac {\exp {(\mathbf {X} \beta )}}{1+\exp {(\mathbf {X} \beta )}}}\,\!$ Multinomial

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 which avoids this would be to utilize a noncanonical link function.

## 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 case of the generalized linear model with identity link. As most exact results of interest are obtained only for the general linear model, the development of the general linear model has undergone a somewhat longer historical development. Results for the generalized linear model with non-identity 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. Here 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. Unlike most other GLMs, there is a closed form solution for the maximum likelihood parameter 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 binomial distribution and the interpretation of μi is then the probability p of Yi taking on the value one.

There are several popular link functions for binomial functions; the most typical is the canonical logit link:

$g(p)=\ln {\left({p \over 1-p}\right)}.$ GLMs with this setup are logistic regression models.

In addition, the inverse of any continuous cumulative distribution function (CDF) can be used for the link since the CDF's range is [0, 1], the range of the binomial mean. The normal CDF $\Phi$ is a popular choice and yields the probit model. Its link is

$g(p)=\Phi ^{-1}(p).\,\!$ The identity link is also sometimes used for binomial data, but a drawback of doing this 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 [0,1] but interpreting the coefficients can be difficult in this model. The model's primary merit is that near p = 0.5 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:

$\operatorname {Var} (Y_{i})=\tau \mu _{i}(1-\mu _{i})\,\!$ where the dispersion parameter τ is typically exactly one. When it is not, the model is often described as binomial with overdispersion or quasibinomial.

### 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

$\operatorname {var} (Y_{i})=\tau \mu _{i},\,$ where the dispersion parameter τ is typically exactly one. When it is not, the model is often described as poisson with overdispersion or quasipoisson. 