University of Free Knowledge
QA 276.12 · fol. 12

The Line of Best Fit

A regression line summarizes a scatter with one equation you can predict from, but only within the range the data actually covers. · 14 min

The correlation number rated how tightly a cloud follows a line, but it never drew the line. This folio does. A regression line is one straight equation laid through a scatter so you can do something correlation cannot: put in a value of the explanatory variable and read out a prediction for the response. It comes with one firm rule about where that prediction can be trusted.

Guess before you learn

A line fitted to toddlers aged 1 to 4 says height is about 75 + 8 × (age in years) centimeters. Use it to predict the height of a 25-year-old.

A regression line is written ŷ = a + bx. The hat on ŷ marks it as a predicted value, not a measured one. The slope b is the heart of it: it says how much the predicted response changes for each one-unit increase in x. The intercept a is the predicted response when x is zero — sometimes meaningful, often just where the line crosses the axis.

THE DEPTH DIAL — the same idea, younger or deeper
9–12

9–12

The least-squares regression line is the one line that makes the sum of squared residuals — the vertical gaps between each point and the line — as small as possible. It always passes through the point of averages (x̄, ȳ), and its slope is b = r·(s_y / s_x): the correlation scaled by the ratio of the spreads. Interpret b as the predicted change in y per unit of x, and a as the predicted y at x = 0. Predicting outside the observed range of x is extrapolation, and nothing in the data justifies it.

regression line

The straight line ŷ = a + bx fit through a scatter to predict the response from the explanatory variable.

extrapolation

Using a regression line to predict outside the range of x-values the data covers — where its accuracy is unsupported.

Why is this true?

Why does the regression line always pass through the point of averages (x̄, ȳ)?

Because the least-squares fit balances the points. Put x = x̄ into ŷ = a + bx with intercept a = ȳ − b·x̄, and the b·x̄ terms cancel, returning exactly ȳ. The average input predicts the average output.

024681012020406080100hours studiedquiz scorebest-fit lineextrapolation
PLATE I Inside the data the line predicts; in the shaded region beyond x = 5 it is only guessing.

Predict a quiz score from ŷ = 30 + 5x — the steps fade as you master them

1
Write the equation with the hours substituted for x = 4
ŷ = 30 + 5(4)
2
Multiply
ŷ = 30 + 20
3
Add
ŷ = 50
4
Check the range: is x = 4 inside the data span of 1 to 5?
1 to 5 covers 4 — the prediction is safe
Retrieval Gate — answer before you continue 0 / 4

1.Using ŷ = 30 + 5x, predict the score for x = 3 hours.

2.In ŷ = 30 + 5x, with x in hours and ŷ a score, what does the slope 5 mean?

3.A regression line is guaranteed to pass through which point?

4.What does the hat in ŷ signal?

The slope is not pulled from nowhere. It equals the correlation times the ratio of the spreads: b = r·(s_y / s_x). A stronger correlation, or a response that varies more per unit of x, makes a steeper line. Once you have the equation, prediction is arithmetic — but the gap between each real point and the line, called the residual, is what the line could not explain.

HOURS XPREDICTED SCORE Ŷ = 30 + 5X13524034545040230 — far outside the data
PLATE II The first four rows are safe predictions; the last is extrapolation gone absurd.

Ink That Thinks — guess first; the answer draws itself.
A scatter of six points climbs steadily. Draw the single straight line that fits them best — guess in pencil first.

024681005101520xy
Drag across the axes to sketch.
PLATE III The line of best fit through six points — guess in graphite, truth in ink.
observed pointpredicted (on the line)residualbest-fit line
PLATE IV A residual is the vertical gap from a point to the line — what the prediction missed.
Retrieval Gate — answer before you continue 0 / 4

1.A relationship has r = 0.75, with s_x = 4 and s_y = 16. What is the regression slope b = r·(s_y / s_x)?

2.A line fit to house sizes of 800 to 2,000 square feet predicts price. Which prediction should you distrust most?

3.For one house the actual price is 20,000 above what the line predicts. Its residual is which of these?

4.Explain in one sentence why you should not use a regression line to predict far outside the data's x-range.

You can now fit a line, read its slope as a rate, predict from it, and — most importantly — refuse to predict where the data cannot vouch for you. One caution remains, large enough for its own folio: a line that predicts well does not prove that x causes y. That is where you head next.

Practice — new ink and old, interleaved

1.Using ŷ = 12 + 2x, predict y for x = 10.

2.In an otherwise tight upward cloud, one point sits far below all the others. What is it called?

3.The regression slope is b = r·(s_y / s_x). If r = 0, what is the slope?

4.A survey answer runs from strongly disagree to strongly agree — an ordinal variable. Which measure of center is defensible?

5.The data average to x̄ = 6 and ȳ = 40. Because a regression line passes through the point of averages, what is ŷ when x = 6?

6.Before fitting a line, why plot the scatter first?

7.The intercept of ŷ = 30 + 5x is 30. With x measured as hours studied, what does it mean?

8.A scatterplot of hours studied (across) and test score (up) has points rising from lower left to upper right. What is its direction?

9.Without looking back: what does each point on a scatterplot represent?

The Call Slip — search everything Ctrl·K / ⌘K