ANOVA, Regression & Correlation: A Refresher
Info sheet · Statistics for Psychology & Neuroscience
Warning✎ Editing notes — to do / to check
Working notes for the author — not shown to students once collapsed; remove before publishing.
- [ ]
What you’ll get from this sheet
Three tools you’ve met — ANOVA, regression, and correlation — are really one idea wearing different hats. By the end you should be able to:
- Say how the three relate to each other.
- Run each in R, and see why the ANOVA and regression give the same answer.
All three are the same model: Outcome = Model + Error. Correlation (r) measures the strength of a linear relationship; regression gives the predictive equation (intercept + slope); ANOVA is just regression with a categorical predictor. r² — the proportion of variance explained — is shared by all three.
One model, three hats
Every ANOVA we’ve run — one‑way, factorial, repeated‑measures, mixed — does the same thing: it partitions variance into the part the model explains and the part it can’t (the residual). Total variance = Model + Residual. That’s exactly the general linear model, and regression is the same equation written for a continuous predictor:
\[y = \beta_0 + \beta_1 x + \varepsilon\]
with \(\beta_0\) the intercept, \(\beta_1\) the slope, and \(\varepsilon\) the residual. The punchline: ANOVA is a special case of regression where the predictor is categorical. Run a one‑way ANOVA and a regression with the same grouping variable and you get the same F, the same p, the same partition of variance.
Correlation is the third view. Pearson’s r summarises the strength and direction of a linear relationship on a fixed scale of −1 to +1; its square, r², is the proportion of variance explained. What correlation won’t give you is a way to predict — for that you need the regression coefficients.
See the equivalence
Below is danceability vs popularity. Drag the noise to weaken or strengthen the relationship, and flip between the regression view (continuous predictor, a line) and the ANOVA view (the same data split into low/medium/high groups). Same data, same variance partition — two ways of looking at it.
In the regression view you read off a prediction rule — each unit of danceability adds about 3 to popularity — plus r and r². Switch to the ANOVA view and the same cloud becomes three groups; comparing their means is exactly what a one‑way ANOVA does, and it partitions the variance identically. Turn the noise up and r, r², and the group separation all shrink together, because they’re all reading the same signal.
See it in code
The same data, all three ways — note how the ANOVA falls out of a regression on a categorical version of X:
dance = 10*rand(30,1); pop = 50 + 3*dance + 8*randn(30,1);
corrcoef(dance, pop) % correlation r
fitlm(dance, pop) % regression: intercept + slope + R^2The R and Python tabs run live; MATLAB is a static reference.
TipCheck your understanding
You find r = 0.33 between danceability and popularity. What does r² tell you, and what can regression add that correlation can’t?
r² = 0.33² ≈ 0.11, so about 11% of the variance in popularity is explained by danceability. Correlation stops there — it’s a strength/direction summary bounded in [−1, 1]. Regression adds the predictive equation (e.g. each unit of danceability → +0.27 popularity) and lets you predict popularity for a new song. Correlation quantifies the relationship; regression models it.
Correlation is unitless and bounded in [−1, 1] — a big r tells you the relationship is tight, not how steep it is, and it can’t predict. All three tools assume a linear relationship and share the usual GLM assumptions, so a curved relationship can show a small r while being perfectly predictable in the right model. And r² is the variance explained, not “how much y changes per unit x” — that’s the slope.
Where this shows up next
This is the doorway to the regression chapter. Next: how regression handles categorical predictors (dummy coding), then multiple predictors, assumptions, and model choice. See Chapter (Correlation & Regression).