The General Linear Model

Info sheet · Statistics for Psychology & Neuroscience

Author

Andrew Bell

Published

August 13, 2026

Info sheet 0.2 (draft) · Prerequisites: ANOVA and regression; the idea of residuals · Give feedback ↗

Working notes for the author — not shown to students once collapsed; remove before publishing.

  • [ ]

What you’ll get from this sheet

One framework sits under nearly everything we’ve done. By the end you should be able to:

  1. State the general linear model and recognise ANOVA, regression, and t-tests as special cases of it.
  2. Speak the regression dialect — outcome, predictor, parameter — fluently.

The general linear model (GLM) is one equation: Outcome = Model + Error, or \(y = \beta_0 + \beta_1x_1 + \dots + \varepsilon\). t-tests, ANOVA, ANCOVA, correlation and regression are all special cases — they differ only in whether the predictors are categorical or continuous. In R, they’re all lm().

One equation under everything

The thread running through this whole module is partitioning variance: the part we can explain (the model) and the part we can’t (the error / residual). Total variance = Model + Error — and that’s true for every ANOVA (one‑way, factorial, repeated‑measures, mixed): the equation gets more elaborate, but the shape never changes.

Regression is the same idea. The line \(y = mx + b\) from school, rewritten in β’s, is \(y = \beta_0 + \beta_1 x + \varepsilon\) — the “\(\beta_0 + \beta_1 x\)” is the model and \(\varepsilon\) is the error. So ANOVA is regression — both are forms of the general linear model. The two big differences are just emphasis and inputs: ANOVA asks can X explain Y (yes/no); regression asks how much, and can predict. And ANOVA needs categorical predictors, while regression takes anything — categorical, continuous, or a mix.

One model, many names

Pick what your predictor(s) look like and see which “classic test” the GLM collapses to — and that they’re all the same lm() call underneath.

Run through the options and the point lands: a t‑test, a one‑way ANOVA, an ANCOVA, a multiple regression — these aren’t different machines, they’re the same GLM with different predictors plugged in. That’s why R fits them all with lm(), and why aov() is really just lm() wearing an ANOVA‑shaped summary.

Talking the talk

In “regression mode” the vocabulary shifts, so a quick glossary — these are used interchangeably:

  • The dependent variable → the outcome or response variable.
  • The independent variablespredictors, explanatory variables, or informally regressors.
  • The coefficientsparameters, or informally the betas (“what are the betas for your regressors?”).

None of it changes the maths — same model, different dialect.

See it in code

The same two‑group comparison, three ways — all identical:

y = [randn(20,1)+10; randn(20,1)+12];
g = [ones(20,1); 2*ones(20,1)];
anova1(y, g);        % one-way ANOVA
fitlm(g, y)          % the same model as a regression

The R and Python tabs run live; MATLAB is a static reference.

A colleague runs a two‑sample t-test; you run lm(y ~ group) with the same binary grouping variable. Will you disagree?

No — you’ll get the same answer. A two‑group t-test is just a general linear model with one binary predictor: the regression’s slope is the difference in group means, and its t‑statistic and p‑value match the t‑test exactly (and equal the square root of the ANOVA’s F). Different names, one model.

“ANOVA vs regression” is a false choice — they’re the same GLM in different dialects, so don’t agonise over which to “use”. What actually changes your results is the data and the model specification, not whether you type aov() or lm() (they give the same fit). Do keep the vocabulary straight, though: outcome/response, predictor/regressor, and parameter/beta all point at the same three things.

Where this shows up next

The GLM is the trunk the rest of the book branches from — multiple regression, ANCOVA, and (loosening the “linear/normal” parts) generalised and mixed models. See Chapter (Correlation & Regression) and the mixed‑effects sheets.