What Pearson’s r really measures
Pearson’s correlation coefficient measures something very specific: how well the points (x, y) line up along a straight line. It is +1 when every point falls exactly on an upward line, −1 when they fall on a downward line, and 0 when there is no linear slope at all. The sign gives the direction; the magnitude gives how tightly the cloud hugs the line. Two properties make it elegant: it is dimensionless, and it does not change if you rescale or shift the axes, measuring height in centimetres or in inches returns exactly the same r.
r = Σ(xᵢ − x̄)(yᵢ − ȳ) / √[ Σ(xᵢ − x̄)² · Σ(yᵢ − ȳ)² ]- r
- correlation coefficient, always between −1 and 1
- xᵢ, yᵢ
- each observed pair of values
- x̄, ȳ
- the means of x and of y
- Σ
- sum over the n observations
Notice what the formula does: it takes the covariance, how much x and y vary together, and standardizes it by dividing by each variable’s standard deviation. That is why r is "unit-free covariance", bounded between −1 and 1. And here is the word almost everyone forgets: linear. Pearson’s r measures linear association. It has no idea what a parabola is.
One counterexample settles it. Take five points symmetric around zero: x = −2, −1, 0, 1, 2, and y = x², that is y = 4, 1, 0, 1, 4. The relationship is perfect and deterministic, given x, you know y exactly. Yet r = 0. The mean of x is zero, and the sum of the products xᵢ·yᵢ is (−2·4) + (−1·1) + (0·0) + (1·1) + (2·4) = −8 − 1 + 0 + 1 + 8 = 0, so the covariance is zero and so is r. The lesson is worth gold: r = 0 does not mean independence, it only means no linear trend. One variable can fully determine the other and still show zero correlation.
Covariance, residual and the exact vocabulary
Five words tend to be used interchangeably, and they are not the same thing. Linear regression fits the line that minimizes the sum of squared residuals; r standardizes the covariance; R² squares r (in simple regression). Pin down each term below with its precise definition before moving on.
- Covariance
- Measures how x and y vary together: positive when they rise together, negative when one rises as the other falls. Its magnitude depends on the units, which makes it hard to read on its own, hence it is standardized into r.
- r (Pearson correlation)
- The covariance divided by the two standard deviations: a number between −1 and 1 that captures only the strength and direction of the linear association between x and y.
- R² (coefficient of determination)
- The fraction of y’s variance the model explains, between 0 and 1. In simple linear regression, R² = r². The sign is lost: R² does not say whether the relationship is positive or negative.
- Residual
- The gap between the observed y and the value the line predicts (yᵢ − ŷᵢ). Least-squares regression picks precisely the line that minimizes the sum of these squared residuals.
- Confounding variable
- A third variable that drives both x and y at once, creating correlation between them without either causing the other (for example, temperature linking ice cream and drownings).
The standard deviations in the denominator of r are exactly what the standard deviation calculator returns for a list of numbers, mean, variance and deviation, population or sample. Paste your data and see the spread that feeds the formula; the same mean shown there is the one you get from the mean, median and mode calculator.
R² is not "quality" and not proof of cause
R², the coefficient of determination, has a precise definition: it is the fraction of y’s variance the model explains. If the total variance of y is the "mess" you want to understand, R² tells you what slice of that mess the line accounts for. An R² of 0.667 means the model explains about two-thirds of y’s variation; the remaining third lives in the residuals. In simple linear regression, a single explanatory variable, the identity R² = r² holds. In Anscombe’s quartet, r = 0.816, so R² = 0.816² ≈ 0.667.
Run the same cloud of points through the linear regression calculator and compare the R² it reports with the r from the correlation calculator: in simple regression, one is exactly the square of the other. When someone trades a strong number for a strong conclusion, this is where the mistake begins, the same risk of any summary index, like BMI, which squeezes the body into a single number and hides the real composition.
The climax: Anscombe’s quartet
In 1973, the statistician Francis Anscombe published four sets of eleven points each with a provocative goal: to show that summary statistics can coincide while the data has nothing in common. All four sets share the same mean of x (9), the same mean of y (7.50), the same variance, the same r (0.816), the same R² (0.667) and exactly the same regression line, y = 3.00 + 0.500x. A report showing only those numbers would call all four identical.
View the data
| x | Set I (linear cloud) | Set II (parabola) |
|---|---|---|
| 4 | 4.26 | 3.1 |
| 5 | 5.68 | 4.74 |
| 6 | 7.24 | 6.13 |
| 7 | 4.82 | 7.26 |
| 8 | 6.95 | 8.14 |
| 9 | 8.81 | 8.77 |
| 10 | 8.04 | 9.14 |
| 11 | 8.33 | 9.26 |
| 12 | 10.84 | 9.13 |
| 13 | 7.58 | 8.74 |
| 14 | 9.96 | 8.1 |
The chart dismantles the illusion. Set I is what you picture when you hear "r = 0.82": a noisy cloud around a line. Set II has no noise at all, it is a clean parabola that rises and then falls, with the regression line cutting across the top describing nothing. Sets III and IV are trickier still: III is a nearly perfect line with a single outlier that bends the slope, and IV is a vertical stack of points at x = 8 plus one far-off point at x = 19, that single point creates the entire "correlation". Four opposite stories, one identical set of numbers.
| Statistic | Set I | Set II | Set III | Set IV |
|---|---|---|---|---|
| Mean of x | 9 | 9 | 9 | 9 |
| Variance of x (sample) | 11 | 11 | 11 | 11 |
| Mean of y | 7.50 | 7.50 | 7.50 | 7.50 |
| Variance of y (sample) | 4.125 | 4.125 | 4.125 | 4.125 |
| Correlation r | 0.816 | 0.816 | 0.816 | 0.816 |
| R² | 0.667 | 0.667 | 0.667 | 0.667 |
| Regression line | y = 3.00 + 0.500x | y = 3.00 + 0.500x | y = 3.00 + 0.500x | y = 3.00 + 0.500x |
The quartet got a modern, tongue-in-cheek sequel: the "Datasaurus Dozen" by Matejka and Fitzmaurice (2017), thirteen sets with means, deviations and correlation nearly equal to two decimal places, one of them shaped like a dinosaur. The lesson is the same as in 1973, now animated: no summary statistic replaces looking at the plot.
Pearson, Spearman and heteroscedasticity
If Pearson’s r is blind to curves and sensitive to outliers, what do you do when the relationship clearly exists but is not a straight line? If it is monotonic, y always rises (or always falls) as x rises, even if the rate changes, Spearman’s correlation is the right tool. It is simply Pearson’s r computed on the ranks of the data rather than the raw values, which makes it robust to outliers and able to capture any monotonic trend, linear or not.
When should you use Spearman instead of Pearson?
Use Spearman in three situations: when the relationship is monotonic but not linear (a curve that only rises, say), when outliers distort Pearson, and when the data is ordinal, ranks, grades, ranking positions. Because Spearman works on ranks, it ignores the exact scale of the values and sees only the order, which leaves it immune to order-preserving transforms (log, root) and to isolated extreme points.
What is heteroscedasticity?
It is when the variance of the residuals is not constant across x, the "fan" that opens up in a scatter plot, with little spread on one side and a lot on the other. Least-squares regression still gives unbiased coefficient estimates, but the standard errors come out wrong, which invalidates significance tests and confidence intervals. That is why you inspect the residuals: a pattern in them (a fan, a curve) warns that a model assumption was broken, exactly what happens in Anscombe’s set II, whose residuals trace the curve the line ignored.
From correlation to cause: the missing piece
Correlation turns into a trap when a hidden third variable drives both at once. The classic classroom example: ice cream sales rise alongside the number of drownings. Nobody believes ice cream drowns anyone, what rises in both cases is the thermometer. Heat makes people buy more ice cream and, at the same time, swim more, so drownings go up. Temperature is the confounding variable; the ice-cream–drowning correlation is spurious. It is a teaching example, not a measured figure, but it captures the mechanism exactly. Tyler Vigen’s Spurious Correlations project pushes the idea to its limit, automatically pairing thousands of series that move together by pure chance.
So what elevates a correlation to causal evidence? Two lines of attack. The first is randomization: in a controlled experiment, you randomly assign who gets the treatment, which by construction breaks any confounding variable, that is why the randomized controlled trial is the gold standard. The second, when an experiment is impossible or unethical (you do not randomize who smokes), is the nine viewpoints Austin Bradford Hill proposed in 1965 for judging whether an association is causal. He called them "viewpoints", not a checklist: none is mandatory, and the converging weight of several is what builds the case.
- Strength, the stronger the association, the less likely it is mere confounding.
- Consistency, the effect repeats across different populations, places and studies.
- Specificity, the cause links to a well-defined effect.
- Temporality, the cause precedes the effect (the one indispensable criterion).
- Biological gradient, more exposure, more effect (dose-response).
- Plausibility, a mechanism makes the cause believable.
- Coherence, the hypothesis does not clash with what is already known.
- Experiment, intervening changes the outcome.
- Analogy, similar causes produce similar effects.
Frequently asked questions
Does correlation imply causation?
What is the difference between r and R²?
Does r = 0 mean there is no relationship at all?
When should you use Spearman instead of Pearson?
Does a high R² mean the model is good?
Pearson’s r and R² are powerful summaries, but blind ones: they measure alignment to a line and the fraction of variance explained, nothing more. Anscombe’s quartet proves that identical numbers can hide opposite data, so always plot before you trust. And remember that no correlation, however strong, becomes a cause without randomization or the careful judgment of the Bradford Hill viewpoints.
Sources & references
- Anscombe, F. J. (1973). "Graphs in Statistical Analysis", The American Statistician 27(1), 17–21
- Anscombe (1973), full text (PDF)
- Matejka & Fitzmaurice (2017), "Same Stats, Different Graphs" (Datasaurus Dozen), ACM CHI
- Hill, A. B. (1965). "The Environment and Disease: Association or Causation?", Proc. R. Soc. Med. 58(5)
- Tyler Vigen, Spurious Correlations