MISSION · Data and probability

Correlation and the Line of Best Fit

Turning "the points look linear" into two numbers

Explorer level
Grades 11-12
Quest time
7 minutes
Mission skill
Measuring the strength of a linear relationship and fitting a line to it

LEVEL 1 · EXPLORE

Make the idea move

Change the controls and watch what happens. Follow your curiosity and see what you notice.

Loading the activity…

LEVEL 2 · LEARN

Unlock the explanation

Open the chapters in any order. Try the examples as you go.

The idea in one sentence

The correlation coefficient puts a number on how tightly points hug a straight line, and least squares finds the line that hugs them back.

The correlation coefficient

\(r\) runs from \(-1\) to \(+1\):

\(r\) Meaning
\(+1\) Perfect positive — every point exactly on a rising line
\(+0.7\) Strong positive
\(0\) No linear relationship
\(-0.7\) Strong negative
\(-1\) Perfect negative

Two things \(r\) does not tell you. It says nothing about slope — a gentle line and a steep one can both have \(r = 1\), since \(r\) measures tightness, not steepness. And it only detects linear relationships: a perfect parabola through your data can give \(r\) near zero while the relationship is exact.

Always plot the data. Anscombe’s quartet is four datasets with identical means, variances, correlations, and regression lines, and four completely different pictures — one of which is a curve and another a single outlier dragging a line around.

Least squares

The line of best fit minimises the sum of the squared residuals, where a residual is the vertical gap between a point and the line.

Squaring does two jobs. It stops positive and negative gaps cancelling, and it penalises big misses far more than small ones — so the line is pulled hard towards distant points. That also means least squares is sensitive to outliers, which is a design choice rather than a flaw, and one to be aware of before trusting a line drawn through data with a stray point in it.

The line always passes through \((\bar{x}, \bar{y})\), the mean of both variables. It pivots around the centre of the data.

r squared

\(r^2\) is the fraction of the variation in \(y\) explained by the linear relationship with \(x\).

An \(r\) of 0.8 gives \(r^2 = 0.64\): about 64% of the variation is accounted for, and 36% is down to everything else. This is usually the more honest number to quote, because it falls off faster — a correlation of 0.5 sounds substantial and explains just a quarter of what’s going on.

Predicting, carefully

The fitted line can estimate \(y\) for an \(x\) you didn’t measure. Within the range of your data — interpolation — that’s reasonable. Outside it — extrapolation — you have no evidence the relationship continues, and it frequently doesn’t.

And the warning from any scatter plot still applies at full strength: a good fit is not evidence of cause. A tight line through ice cream sales and drownings is still summer doing the work.

Common mix-ups

  • Reading \(r\) as a slope. It measures tightness only.
  • Concluding causation from a high \(r\).
  • Trusting \(r\) without plotting. Curves and outliers hide inside the number.
  • Extrapolating past the data, where the line has nothing behind it.

Check yourself

A study reports \(r = 0.6\) between hours revised and exam score. What does that justify saying?

That there’s a moderate positive linear association, and that revision hours account for about \(0.36\) — a third — of the variation in scores. It doesn’t establish that revising more causes the rise, nor predict anything for someone revising far outside the range studied.

LEVEL 3 · REFLECT

Add this quest to your trail

When you feel ready, mark this idea as explored. You can always come back and try it again.

EXPLORER STRATEGIES

More ways to see it

Loading shared methods…
Share how you learned it