Statistics

Correlation is not causation: what r and R² actually tell you

"Correlation is not causation" has become a slogan, and like every slogan, it gets repeated by people who could not say what correlation actually measures. Pearson’s r compresses the relationship between two variables into a single number between −1 and 1. It is powerful and deceptive in equal measure: it sees only straight lines, it is blind to curves, and a high R² proves neither a good model nor a cause. This guide shows what r sees, what it cannot see, why R² is routinely misread, and closes with the experiment every data scientist should run once: Anscombe’s quartet. Test the ideas in the [correlation calculator](tool:calculadora-correlacao) and the [linear regression](tool:calculadora-regressao-linear) tool as you read.

J-Kit12 min readIntermediate
  • Statistics
  • Correlation
  • Regression
  • Causation
  • Data science

Key takeaways

  • Pearson’s r measures only linear association; r = 0 is not independence (y = x² on a symmetric domain has r = 0).
  • R² is the fraction of y’s variance the model explains, not "quality" and not proof of causation; R² = r² only in simple regression.
  • Anscombe’s quartet: four sets with identical r, R² and regression line but radically different shapes. Always plot.
  • Correlation becomes causal evidence only with randomization and/or the converging weight of the Bradford Hill viewpoints.

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
Pearson’s r: the covariance of x and y standardized by each one’s spread.

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.

Compute the mean, variance and standard deviation of your own list, the numbers that go into r.Open the tool full page

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.

0.816r across the four Anscombe sets
0.667R² = r² in simple regression
≈ 67%of y’s variance "explained" by the line

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.

02.715.428.1310.844914xySet I (linear cloud)Set II (parabola)
Anscombe (1973) data: sets I and II share the same x, the same r ≈ 0.816 and the same line, yet I is a linear cloud and II is a parabola.
View the data
xSet I (linear cloud)Set II (parabola)
44.263.1
55.684.74
67.246.13
74.827.26
86.958.14
98.818.77
108.049.14
118.339.26
1210.849.13
137.588.74
149.968.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.

The four Anscombe sets and their identical statistics (rounded).
StatisticSet ISet IISet IIISet IV
Mean of x9999
Variance of x (sample)11111111
Mean of y7.507.507.507.50
Variance of y (sample)4.1254.1254.1254.125
Correlation r0.8160.8160.8160.816
0.6670.6670.6670.667
Regression liney = 3.00 + 0.500xy = 3.00 + 0.500xy = 3.00 + 0.500xy = 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?
No. A correlation can arise from direct cause, reverse cause, a confounding variable (like temperature linking ice cream and drownings) or coincidence. To claim cause you need randomization, a controlled experiment, or a converging body of evidence such as the Bradford Hill viewpoints.
What is the difference between r and R²?
r (−1 to 1) measures the strength and direction of the linear association. R² (0 to 1) is the fraction of y’s variance the model explains. In simple linear regression, R² = r²: an r of 0.816 becomes an R² of 0.667. The sign is lost when you square, so R² does not tell you whether the relationship is positive or negative.
Does r = 0 mean there is no relationship at all?
No. r = 0 means no linear relationship. There can be a strong, deterministic relationship, like y = x² on a domain symmetric around zero, with r exactly zero. That is why the plot is irreplaceable: r cannot see curves.
When should you use Spearman instead of Pearson?
Use Spearman when the relationship is monotonic but not linear, when outliers distort Pearson, or when the data is ordinal (ranks, grades). Spearman is Pearson applied to the ranks of the data, which makes it robust and sensitive to any trend that only rises or only falls.
Does a high R² mean the model is good?
Not necessarily. Anscombe’s set II has R² = 0.667 and a completely inadequate linear model (the data is a curve). A high R² can accompany a wrong model, and in multiple regression it always rises when you add variables, even useless ones. Look at the residuals and the plot, not just R².

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

  1. Anscombe, F. J. (1973). "Graphs in Statistical Analysis", The American Statistician 27(1), 17–21
  2. Anscombe (1973), full text (PDF)
  3. Matejka & Fitzmaurice (2017), "Same Stats, Different Graphs" (Datasaurus Dozen), ACM CHI
  4. Hill, A. B. (1965). "The Environment and Disease: Association or Causation?", Proc. R. Soc. Med. 58(5)
  5. Tyler Vigen, Spurious Correlations