Link function

Link function

Type Topic
Taught in Introduction to generalised linear models · Introduction to generalised linear models · Underdispersion, positive responses, and quasi-likelihood
Part Generalised linear models
Questions using it 5

The function g that ties the mean of a GLM to its linear predictor, g(\mu_i)=\mathbf{X}_i^\top\boldsymbol{\beta}. It is chosen so that every value of the linear predictor gives a legal mean: the logit keeps a probability in (0,1), the log keeps a count’s mean positive.

In Introduction to generalised linear models

Definition 1 Observations Y_1,\ldots,Y_n follow a generalised linear model when all three of the following are specified.

  1. Random component. The Y_i are independent, and each belongs to the same exponential family. The functions a, b, c, d and e are common; the parameter \theta_i may depend on i.
  2. Linear predictor. Covariate vectors {\boldsymbol{X}}_1,\ldots,{\boldsymbol{X}}_n and a coefficient vector \boldsymbol{\beta}=(\beta_0,\ldots,\beta_d)^\top form \eta_i={\boldsymbol{X}}_i^\top\boldsymbol{\beta}.
  3. Link. A monotone function g connects the mean \mu_i=\mathrm{E}(Y_i) to that predictor, g(\mu_i)={\boldsymbol{X}}_i^\top\boldsymbol{\beta}.

Article: Generalised linear model →

The three choices are separate, and all three are yours. You choose the distribution. You choose which covariates go into {\boldsymbol{X}}_i, and whether to transform them first: log dose is still just a column of {\color{blue}\boldsymbol{X}}. You choose the link. Nothing forces the link that is “canonical” for the distribution you chose.

Definition 2 The link g is canonical when the linear predictor is the natural parameter of the family: g(\mu_i)=b(\theta_i), in the notation of Equation (6) in Introduction to generalised linear models.

Article: Canonical link →

For the families above, the canonical links are

  • normal: g(\mu)=\mu, the identity, because the natural parameter is the mean;
  • Poisson: g(\mu)=\log\mu, because the natural parameter is \log\lambda and \mu=\lambda;
  • binomial, including Bernoulli: g(\mu)=\log\{\mu/(1-\mu)\}, the logit;
  • gamma, in the shape-and-rate form with mean \mu: g(\mu)=1/\mu, the inverse link.

If you call glm in R and name the family but not the link, you get the canonical link. That is a software default, not a scientific one. The canonical link for the gamma is the inverse link. The link used most often here for a positive continuous response is still the log link, because a slope is then a multiplicative change in the mean, and that is a sentence one can say to a collaborator. Canonical links are the natural mathematical choice. They are not always the appropriate one. You override the default by stating the link yourself.

The normal linear model is the GLM with identity link and normal random component: \mu_i={\boldsymbol{X}}_i^\top\boldsymbol{\beta} and \mathrm{Var}(Y_i)=\sigma^2. Logistic regression is the GLM with Bernoulli random component and the logit link Equation (5) in Introduction to generalised linear models. Writing those two out is not a new model. It is the definition, specialised.

Key idea

A GLM is an exponential family, a linear predictor, and a link, chosen independently. The canonical link equates the linear predictor with the natural parameter. It is the default in R. It is not a requirement.

In Underdispersion, positive responses, and quasi-likelihood

A clotting time, or an insurance claim amount, is continuous and cannot be negative. Three links are in ordinary use: \begin{align*} \log\mu_i&={\boldsymbol{X}}_i^\top\boldsymbol{\beta}, & \mu_i&=\exp({\boldsymbol{X}}_i^\top\boldsymbol{\beta}),\\ \mu_i^{-1}&={\boldsymbol{X}}_i^\top\boldsymbol{\beta}, & \mu_i&=1/({\boldsymbol{X}}_i^\top\boldsymbol{\beta}),\\ \mu_i^{-2}&={\boldsymbol{X}}_i^\top\boldsymbol{\beta}, & \mu_i&=1/\sqrt{{\boldsymbol{X}}_i^\top\boldsymbol{\beta}}. \end{align*} The log link is the one with a direct reading, and it keeps \mu positive for every finite predictor. It is not the canonical link for the gamma or the inverse Gaussian, so R will not choose it unless you name it. The canonical link for the gamma is the inverse link. The canonical link for the inverse Gaussian is the inverse quadratic. Both of those are only positive when {\boldsymbol{X}}^\top\boldsymbol{\beta}>0. If the linear predictor changes sign, the inverse link produces a negative mean, and the square root in the inverse quadratic leaves the reals. It is sometimes said that the inverse quadratic “ensures” non-negativity because a complex mean is not a mean. That is a restriction on the domain of \boldsymbol{\beta}, not a guarantee for every coefficient vector. You still have to keep the linear predictor positive.

Used in

See also

Generalised linear model · Linear predictor · Three components of a GLM · Logit link · Exponential family · Mean and variance of an exponential family · Canonical link · What a regression statement is hiding

Glossary and index