Written and maintained by CASRAI Editorial Board
Last updated
A generalized linear model (GLM) is a regression model for outcomes that are not well described by a normal distribution, such as counts, yes/no results and positive skewed measurements. It keeps the familiar linear predictor of ordinary regression but adds two choices: a probability distribution for the outcome and a link function that connects the outcome’s mean to the predictors. This page gives the formula, a worked count-data example with the arithmetic shown, reporting wording and code.
What is a generalized linear model?
A generalized linear model is a regression model with three parts: a response distribution from the exponential family (for example normal, binomial, Poisson or gamma), a linear predictor built from the explanatory variables, and a link function that relates the two. Ordinary linear regression is the special case with a normal response and an identity link. Logistic regression (binomial response, logit link) and Poisson regression (Poisson response, log link) are the two GLMs researchers meet most often.
The R documentation describes the idea in the same terms: the family argument of glm() is “a description of the error distribution and link function to be used in the model”, and family objects “provide a convenient way to specify the details of the models used by functions such as glm” (R Core Team, stats package documentation, checked 2026-10-29).
Do not confuse the two similar names. The general linear model covers regression, ANOVA and ANCOVA with normally distributed errors. The generalized linear model extends that framework to other response distributions.
Generalized linear model formula
The model is written as
g(μᵢ) = β₀ + β₁x₁ᵢ + … + βₚxₚᵢ = Xᵢβ
- μᵢ is the expected (mean) value of the response for observation i.
- g( ) is the link function. Its inverse maps the linear predictor back to the mean: μᵢ = g⁻¹(Xᵢβ).
- Xᵢβ is the linear predictor: an intercept β₀ plus one coefficient βⱼ for each explanatory variable xⱼ.
- The variance of the response is a function of the mean, set by the chosen distribution. For a Poisson response, Var(Y) = μ.
Minitab’s documentation states the same canonical form, g(μᵢ) = Xᵢ′β = θ, where g is the link function, μᵢ the mean response and Xᵢ′β the linear predictor (Minitab Help, Poisson regression methods, checked 2026-10-29).
Because the link acts on the mean and not on the raw outcomes, a GLM never needs to transform individual observations. A count of zero is a valid observation under a log link, whereas taking the log of the raw count would fail.
Choosing the family and link
The default links below are those listed in the R family documentation. The last column describes how to read exp(β) and follows from the link itself.
| Outcome type | R family | Default link in R | Reading the coefficient |
|---|---|---|---|
| Continuous, roughly symmetric | gaussian | identity | β is the change in the mean per unit of x |
| Yes/no, or successes out of trials | binomial | logit | exp(β) is an odds ratio |
| Counts | poisson | log | exp(β) is a rate ratio |
| Positive, right-skewed | Gamma | inverse | Coefficients act on 1/μ; a log link is often used instead for a ratio reading |
| Counts with extra variation | quasipoisson | log | exp(β) is a rate ratio, with a dispersion estimate |
| Binary with extra variation | quasibinomial | logit | exp(β) is an odds ratio, with a dispersion estimate |
The same documentation notes that the gaussian family accepts the links identity, log and inverse. Minitab lists natural log, square root and identity links for Poisson models and calls the natural log “the canonical link function for Poisson models”.
Generalized linear model examples
Worked example: Poisson regression with a rate ratio
Illustrative data constructed for this page, not a real study. Twenty labs are split into 10 control labs and 10 labs using a new checklist. The outcome is the number of reportable incidents in one month.
- Control labs: 2, 4, 3, 5, 1, 3, 4, 2, 3, 3 (total 30, mean 3.0)
- Checklist labs: 2, 1, 3, 2, 0, 2, 3, 1, 2, 2 (total 18, mean 1.8)
The model is ln(μ) = β₀ + β₁x, with x = 0 for control and x = 1 for checklist labs. With a single binary predictor, the maximum-likelihood fit reproduces each group’s mean, so the arithmetic can be done by hand:
- β₀ = ln(3.0) = 1.0986, the log of the control mean.
- β₀ + β₁ = ln(1.8) = 0.5878, so β₁ = 0.5878 − 1.0986 = −0.5108.
- Rate ratio = exp(−0.5108) = 0.60, which equals 1.8 ÷ 3.0.
- Standard error of β₁ = √(1/30 + 1/18) = √(0.0333 + 0.0556) = √0.0889 = 0.298.
- z = −0.5108 ÷ 0.298 = −1.71, giving a two-sided p of about .087.
- Wald 95% CI for β₁: −0.5108 ± 1.96 × 0.298 = [−1.095, 0.074]. Exponentiated: [0.33, 1.08].
Fitting the same data in Python’s statsmodels gives the same estimates (β₁ = −0.511, SE = 0.298, p = .087, rate ratio 0.60, CI [0.33, 1.08]).
Interpretation
The checklist labs had 0.60 times the incident rate of the control labs, a 40% lower rate, but the confidence interval runs from 0.33 to 1.08 and includes 1, so this small sample does not rule out no difference at the .05 level.
| Link | What exp(β) means | Value of 1 means |
|---|---|---|
| log (Poisson) | Rate ratio per unit increase in x | No change in the rate |
| logit (binomial) | Odds ratio per unit increase in x | No change in the odds |
| identity (gaussian) | Not used: β itself is the mean difference | A β of 0 means no difference |
For deeper treatment of the binomial case, see logistic regression in R; for the count distribution itself, see the Poisson distribution.
Assumptions and common mistakes
- Independent observations. Repeated measures on the same unit break this. Use generalized estimating equations or a mixed model instead.
- Correct variance function. A Poisson model assumes the variance equals the mean. When counts vary more than that (overdispersion), standard errors are too small. R provides quasipoisson and quasibinomial families for this; for the Gaussian, Gamma and inverse Gaussian families R estimates the dispersion from the residual deviance. In the example above, Pearson χ² = 8.22 on 18 degrees of freedom, a ratio of 0.46, so there is no sign of overdispersion.
- Link and linearity. The relationship is linear on the link scale, not on the original scale. Check this for continuous predictors.
- Misreading coefficients. A logit or log coefficient is not a change in the outcome. Exponentiate it for a ratio, as in the table above.
- Comparing nested models. Deviance, which R defines as up to a constant minus twice the maximized log-likelihood, supports a likelihood ratio test of nested models.
- Convergence. R’s default
glm.fitmethod uses iteratively reweighted least squares (IWLS). Warnings that the algorithm did not converge call for checking the data and model, not for ignoring the output.
How to report a generalized linear model (APA)
Name the family and link, give the coefficient with its standard error and test, and add the ratio with its confidence interval:
A Poisson regression with a log link showed that monthly incident counts were lower in labs using the checklist than in control labs, b = −0.51, SE = 0.30, z = −1.71, p = .087, rate ratio = 0.60, 95% CI [0.33, 1.08].
State the software and version, report any dispersion check, and name which interval type you used (Wald or profile likelihood).
Generalized linear model in Excel, R and Python
Excel
Excel has no built-in GLM function. For a Poisson model with one two-level predictor, the fitted rate ratio is the ratio of group means. With control counts in A2:A11 and checklist counts in B2:B11:
=AVERAGE(B2:B11)/AVERAGE(A2:A11) (rate ratio, 0.60)
=LN(AVERAGE(B2:B11)/AVERAGE(A2:A11)) (b, -0.511)
=SQRT(1/SUM(A2:A11)+1/SUM(B2:B11)) (SE, 0.298)
Models with several predictors need R, Python or a statistics package.
R
y = c(2,4,3,5,1,3,4,2,3,3, 2,1,3,2,0,2,3,1,2,2)
group = factor(rep(c("control","checklist"), each = 10),
levels = c("control","checklist"))
fit = glm(y ~ group, family = poisson(link = "log"))
summary(fit)
exp(cbind(RR = coef(fit), confint(fit)))
Python
import numpy as np, statsmodels.api as sm
y = np.array([2,4,3,5,1,3,4,2,3,3, 2,1,3,2,0,2,3,1,2,2])
x = sm.add_constant(np.array([0]*10 + [1]*10))
fit = sm.GLM(y, x, family=sm.families.Poisson()).fit()
print(fit.summary())
print(np.exp(fit.params), np.exp(fit.conf_int()))
The R confint() call returns profile-likelihood intervals for a glm, so its limits can differ slightly from the Wald limits computed above.
Frequently asked questions
What is a generalized linear model?
It is a regression model that pairs a response distribution from the exponential family with a link function connecting the mean of the response to a linear combination of predictors. Linear, logistic and Poisson regression are all special cases.
What is the formula for a generalized linear model?
g(μ) = Xβ, where μ is the expected response, g is the link function and Xβ is the linear predictor.
What is the difference between a general and a generalized linear model?
The general linear model assumes normally distributed errors. The generalized model allows other distributions through the link and variance function. See regression analysis for the baseline case.
Which link function should I use?
Start with the default for the family in the table above (logit for binomial, log for Poisson), because those give odds ratios and rate ratios. Change the link only when the data or the question call for it.
Sources
- R Core Team. Family objects for models (stats::family), R documentation. https://stat.ethz.ch/R-manual/R-devel/library/stats/html/family.html. Checked 2026-10-29.
- R Core Team. Fitting generalized linear models (stats::glm), R documentation. https://stat.ethz.ch/R-manual/R-devel/library/stats/html/glm.html. Checked 2026-10-29.
- Minitab Help. Methods and formulas for Poisson regression. https://support.minitab.com/en-us/minitab/help-and-how-to/statistical-modeling/regression/how-to/fit-poisson-model/methods-and-formulas/methods. Checked 2026-10-29.
- McCullagh, P., and Nelder, J. A. (1989). Generalized linear models (2nd ed.). Chapman and Hall.
- Nelder, J. A., and Wedderburn, R. W. M. (1972). Generalized linear models. Journal of the Royal Statistical Society, Series A, 135(3), 370-384.








