Skip to content
ihateDesmos

What R² doesn’t tell you: reading a regression properly

· 9 min read · ihateDesmos

In 1973 the statistician Frank Anscombe published four small data sets with the same means, the same regression line and the same R². Plotted, they could hardly look more different. Fifty years on, they are still the best argument for looking at a fit rather than just its numbers.

Same numbers, different data

Each of Anscombe’s four data sets has eleven points. Fitting a straight line to each with this calculator gives:

SetSlope mIntercept bR²
I0.500 ± 0.1183.00 ± 1.120.667
II0.500 ± 0.1183.00 ± 1.130.666
III0.500 ± 0.1183.00 ± 1.120.666
IV0.500 ± 0.1183.00 ± 1.120.667

To two or three significant figures, all four say the same thing: y ≈ 3 + 0.5x, with R² ≈ 0.67. If you only looked at that output, you would treat them as the same. Here they are.

5101520510
Open in calculator
Set I: a reasonable linear relationship with scatter.
5101520510
Open in calculator
Set II: a clear curve. A straight line is the wrong model.
5101520510
Open in calculator
Set III: a perfect line except for one outlier, which drags the fit away from the other ten points.
5101520510
Open in calculator
Set IV: no relationship at all, except one high-leverage point that creates the whole fit.

What R² actually measures

R² is the fraction of the variation in y that the fitted model accounts for: 1 − (sum of squared residuals)/(total sum of squares). It says how much closer the line is to the data than a flat line at the mean of y. It does not say whether a line is the right shape, whether one point is doing all the work, or whether the relationship would hold outside the data. Sets II, III and IV all have a respectable R² for the wrong reasons.

Look at the residuals

The residuals are the vertical distances from each point to the fitted line. If the model is right, they should look like random noise: no pattern, no trend, roughly even spread. Set II’s residuals form an arch, the signature of a missing curve. Set III’s are tiny except one. Turn on Residuals under any regression in the calculator to plot them.

5101520510
Open in calculator
Set II with a quadratic model, y₁ ~ a x₁² + b x₁ + c, instead: the curve passes through every point, and R² is essentially 1.

Standard errors: how sure is each parameter?

Each fitted parameter is an estimate, and its standard error says how much it would vary if you collected new data from the same process. In the table above, every slope is 0.500 ± 0.118. Roughly, the true slope is likely to be within about two standard errors of the estimate, here between about 0.26 and 0.74. A parameter whose standard error is as big as the value itself is not well determined by the data.

Confidence bands

A 95% confidence band surrounds the fitted curve with the region where the true curve plausibly lies. It is narrowest at the centre of the data and widens toward the ends, because a small change in slope moves the line more the further you go from the centre. Outside the range of the data, the band flares out quickly: a warning against extrapolation.

510152051015
Open in calculator
Set I with its 95% confidence band. The band is tightest near the middle of the data, around x = 9, and widens beyond it.

A confidence band is about the line, not the data: most individual points lie outside it. The wider region expected to contain new observations is the prediction band, which adds the scatter of individual points to the uncertainty in the line.

A checklist for any fit

  1. Plot the data first. Shape, outliers and clusters are obvious in a picture and invisible in a table.
  2. Check the residuals for patterns. A pattern means the model is missing something.
  3. Read the standard errors, not just the parameter values.
  4. Check influence. Remove the most extreme point and refit. If the answer changes a lot, say so.
  5. Don’t extrapolate far beyond the data without a reason to believe the model holds there.

Every figure here opens in the calculator. Try typing y1 ~ a e^(b x1) next to a table of your own data and turning on the band and residuals.

Read next

See it for yourself

Every figure in this post opens in the calculator, where you can change it and watch what happens.

Open the calculator