What Is GLM in Statistics? General vs. Generalized

GLM is shorthand for two different but closely related models, and textbooks, papers, and software don’t agree on which one the letters mean. So the first thing to settle is whether a source is talking about the general linear model or the generalized linear model.1Deepchecks. What are the three components of a generalized linear model? The generalized model was built as a wider version of the general one, and which you need depends on what kind of outcome you are measuring.

The General Linear Model Is Regression and ANOVA in One Framework

The general linear model writes an outcome as a starting value, plus a weighted contribution from each predictor, plus an error term.2Regression Diagnostics with R. 2 Model Assumptions | Regression Diagnostics with R The error stands for every other influence on the outcome that the predictors don’t capture.2Regression Diagnostics with R. 2 Model Assumptions | Regression Diagnostics with R A typical example is predicting someone’s reaction time from their age.3From Questions to Knowledge: Data Analysis for Psychology and Behavioural Science using R. 3.5 Assumptions of the General Linear Model

Each weight says how much the predicted outcome changes when that predictor goes up by one unit, with the other predictors held fixed. In the reaction-time example, the age weight is the predicted extra milliseconds for each additional year of age. The starting value is the predicted outcome when every predictor equals zero, which may not be a realistic situation, such as an age of zero. Real people won’t fall exactly on the predicted line, and the gap between a person’s actual and predicted reaction time is that person’s error.

Regression and ANOVA turn out to be the same model. Run a one-way ANOVA and a linear regression on the same data and you get the same F-statistic, p-value, and R-squared, because both are special cases of the general linear model.4MetricGate. ANOVA vs Regression: Two Sides of the Same Coin The same holds for factorial ANOVA, repeated-measures ANOVA, and ANCOVA, which are all forms of multiple regression.5The Tutorial in Quantitative Methods for Psychology. General Linear Models: An Integrated Approach to Statistics

A group comparison works like a predictor coded as 0 or 1 for group membership, so you learn one framework instead of separate recipes for t-tests, ANOVA, and regression. It also explains why statistics programs often run ANOVA through their regression routines.

The model assumes the average outcome changes in a straight-line way with the predictors.2Regression Diagnostics with R. 2 Model Assumptions | Regression Diagnostics with R It also assumes the errors follow a normal distribution, a bell curve centered on zero.2Regression Diagnostics with R. 2 Model Assumptions | Regression Diagnostics with R The errors should have the same spread at every predictor value and be unrelated to each other.6BrainVoyager. The General Linear Model When these hold, least squares gives the most efficient unbiased estimates of the weights.6BrainVoyager. The General Linear Model

A common misreading is that the raw outcome values must look like a bell curve. The assumption applies to the errors, not to the outcome or the predictors, so skewed predictors are fine. To check, look at a plot of the residuals rather than a histogram of the raw data. The other assumptions matter too, including no extreme outliers and no strongly overlapping predictors.

Why the Generalized Linear Model Was Needed

Many outcomes can’t be analyzed properly with linear regression, such as pass/fail results, agree-to-disagree rating scales, or a choice among options.7Physical Review Physics Education Research. Beyond linear regression: A reference for analyzing common data types in discipline based education research The general model also struggles when the outcome is limited to a range, as with yes/no answers or counts, and when the outcome’s spread depends on its average.8bookdown.org. Chapter 6 Models for binary data | Regression Models The generalized linear model extends the framework to deal with both problems.8bookdown.org. Chapter 6 Models for binary data | Regression Models

Run ordinary regression on yes/no data and the model can predict probabilities below 0 or above 1, which makes no sense. The spread of a yes/no outcome naturally changes with its average, which breaks the equal-spread assumption, so hypothesis tests and confidence intervals can be misleading.

Counts and skewed amounts strain the model in similar ways. A count can’t go below zero, but a straight-line model can happily predict negative counts for some predictor values. Counts and costs tend to vary more when their average is large, so the equal-spread assumption fails in a predictable way. Skewed amounts have a long right tail, so errors aren’t symmetric around the prediction and don’t follow a bell curve.

The core difference is that the general model requires normally distributed errors, while the generalized model lets the outcome follow other distributions.9Medium. General and Generalized Linear Models That makes it suitable for counts, occurrences, survival times, and binary data.10Predictive Solutions. General linear models and generalised linear models – differences and similarities It also allows different functions to connect the predictors to the outcome.10Predictive Solutions. General linear models and generalised linear models – differences and similarities The general linear model is therefore one special case inside the generalized family.

John Nelder and Robert Wedderburn introduced the generalized linear model in a 1972 paper.11R-bloggers. Quick History: glm() They wanted to bring linear, logistic, and Poisson regression together into one framework.12Wikipedia. Generalized linear model They also hoped this would make the subject simpler to teach to both specialists and non-specialists.11R-bloggers. Quick History: glm()

The Three Parts of a Generalized Linear Model

  • Distribution: a distribution for the outcome, chosen from a family that includes the normal, binomial, Poisson, and gamma distributions.12Wikipedia. Generalized linear model
  • Linear predictor: the same weighted sum of the predictors used in regression.12Wikipedia. Generalized linear model
  • Link function: a function that connects the average outcome to the linear predictor.12Wikipedia. Generalized linear model

The link changes the scale of the average outcome so that a straight-line sum can predict it. A log link keeps predicted counts positive. A logit link keeps predicted probabilities between 0 and 1. An identity link combined with a normal distribution gives back ordinary regression.

Choosing a distribution starts from what the outcome is: yes/no results suggest binomial, event counts suggest Poisson, and positive skewed amounts suggest gamma. Every member of this family has a built-in rule for how the outcome’s spread relates to its average.13Technical University of Denmark. Introduction to General and Generalized Linear Models14Christoph Molnar’s “Interpretable Machine Learning”. 8 GLM, GAM and more15Journal of the Royal Statistical Society Series B: Statistical Methodology. Exponential Dispersion Models Because each distribution carries a built-in relationship between average and spread, picking one also decides what the model assumes about variability. If that spread rule doesn’t match the data, you move to a related distribution rather than abandoning the framework.

The linear predictor’s value isn’t the predicted outcome itself but a number on the link scale, which the link must translate back. That’s why a coefficient in a generalized model describes a change on the link scale, such as log-odds, rather than a change in the outcome.

Each distribution has a standard, or “canonical,” link, such as the logit for binary data, which gives results that are simple to interpret.16Journal of Statistical Planning and Inference. Noncanonical Links in Generalized Linear Models – When is the Effort Justified? A different link sometimes fits the data noticeably better, although the results become harder to interpret.16Journal of Statistical Planning and Inference. Noncanonical Links in Generalized Linear Models – When is the Effort Justified? Some fields have their own preferences, such as probit links in toxicology and log links when they want relative risks.17PubMed. Summary goodness-of-fit statistics for binary generalized linear models with noncanonical link functions

Generalized models are fitted by maximum likelihood, usually through a repeated, reweighted form of least squares.18Wikipedia. Iteratively reweighted least squares It begins with a rough guess for the weights and calculates predictions from them. It then refits the weights, giving different observations different influence based on the assumed spread, and repeats until the estimates stop changing. Occasionally the steps fail to settle, and the program warns that the model did not converge, which signals a problem with the model or data.

Logistic Regression for Yes or No Outcomes

Regression with a binary outcome is a generalized linear model, called logistic regression or a logit model.19Workshop 6: Generalized linear models. Chapter 8 Binomial GLM The weighted sum predicts the logit, the log-odds, of a probability, so you apply the logistic function to that value to get the probability back.20Analysing Data using Linear Models. Chapter 15 Generalised linear models: logistic regression In software terms, this is a Bernoulli outcome paired with a logit link.21Stata. glm — Generalized linear models

Odds are the probability of the event divided by the probability of no event, so a probability of 0.75 corresponds to odds of 3 to 1. The logistic function takes any value on the log-odds scale, however large or small, and returns a probability between 0 and 1. A straight-line change on the log-odds scale produces an S-shaped curve for the probability, so the same predictor change shifts probability by different amounts at different starting points.

A coefficient describes the change in log-odds for a one-unit change in the predictor, not a change in the probability itself. Exponentiating a coefficient turns it into an odds ratio, and odds aren’t the same as probability. If you want a relative risk instead, a log link can be used.

To fit one, you code the outcome as 0 for no and 1 for yes, and the model estimates the probability of the one. In R this is glm() with a binomial family, whose default link is logit. Predicted probabilities can be turned into yes/no predictions by choosing a cutoff, but the model itself returns probabilities. Ordered rating scales use ordinal models built on the same idea, and choices among several unordered options use multinomial models.

Poisson and Negative Binomial Models for Counts

Poisson and negative binomial regression are the usual models for how often an event happens in a period of time or a space.22PubMed Central. Penalized negative binomial models for modeling an overdispersed count outcome with a high-dimensional predictor space: Application predicting micronuclei frequency Poisson regression models the average count with a log link, so predicted counts stay positive. Its coefficients, once exponentiated, are rate ratios that say by what factor the expected count is multiplied for a one-unit change in the predictor. When counts come from observation periods or areas of different size, the model includes that exposure so the rates are compared fairly.

A Poisson model assumes the variance equals the mean.22PubMed Central. Penalized negative binomial models for modeling an overdispersed count outcome with a high-dimensional predictor space: Application predicting micronuclei frequency When counts are more spread out than that, the data show overdispersion. Counts such as doctor visits often have many zeros and a few very large values, so the variance is larger than the mean. Differences between individuals that the predictors don’t capture are a common reason. In that case the Poisson weights may still be reasonable, but their uncertainty is understated.

Comparing the variance of the raw counts with their mean is only a rough first check, because the predictors also explain some of the spread. A residual deviance much larger than the degrees of freedom is also a warning sign. Ignoring the problem makes standard errors too small, so effects look more certain than they are. Deviance can also be used to compare different count models.

Quasi-Poisson and negative binomial models have the same number of parameters, and either can handle counts more spread out than Poisson expects.23PubMed. Quasi-Poisson vs. negative binomial regression: how should we model overdispersed count data? In quasi-Poisson the variance grows in proportion to the mean, while in negative binomial it grows with the mean squared.23PubMed. Quasi-Poisson vs. negative binomial regression: how should we model overdispersed count data? For positive, right-skewed outcomes such as costs or times, a gamma generalized model can be used instead of log-transforming the data.24Communications in Statistics – Simulation and Computation. The gamma generalized linear model, log transformation, and the robust Yuen-Welch test for analyzing group means with skewed and heteroscedastic data

How to Tell Which GLM a Source or Program Means

Authors and publications use GLM to mean either the general or the generalized linear model, so you have to work it out from context.1Deepchecks. What are the three components of a generalized linear model? SAS’s GLM procedure and R’s lm() fit the general linear model by least squares.1Deepchecks. What are the three components of a generalized linear model? Generalized models are fitted with SAS’s GENMOD procedure and R’s glm() function.1Deepchecks. What are the three components of a generalized linear model? Stata’s regress command fits the general linear model.2Regression Diagnostics with R. 2 Model Assumptions | Regression Diagnostics with R

In a paper or report, a named distribution or link function means the generalized model, and so do reported odds ratios or rate ratios. ANOVA tables reported alongside R-squared suggest the general model. Some writers use the abbreviation GLiM or GzLM for the generalized model.

Software output gives clues too. Output that mentions a family, such as binomial or Poisson, or a link, means a generalized model was fit. An F-test for the whole model and a residual standard error suggest the general model. When you don’t know which procedure produced a result, the code or methods section is more reliable than the label GLM.

Running R’s glm() with a normal distribution and identity link gives the same results as lm(). Running lm() on a yes/no outcome will still return numbers, but they rest on assumptions the data break.

Where Generalized Models Stop Being Enough

Linear models are easy to interpret but often miss real patterns in the data.25christophm.github.io. 8 GLM, GAM and more Extensions of the generalized model offer a gradual step toward more flexible models while keeping some interpretability.25christophm.github.io. 8 GLM, GAM and more With very many predictors, standard maximum likelihood can be badly biased in generalized models.26PubMed Central. Online inference in high-dimensional generalized linear models with streaming data

Common next steps include generalized additive models, which let a predictor’s effect follow a smooth curve instead of a straight line, and penalized models, which handle situations with many predictors. Mixed models handle repeated or grouped data. Ordinary generalized models assume observations are independent, which fails when the same person or school contributes several rows. Mixed models give each group its own baseline, so the grouping is accounted for. A highly flexible model can fit the quirks of one dataset and then predict new data poorly, and a linear model’s weights have a clear meaning that flexible methods often lose.