Math · Introductory statistics · Worked example
Fit a least-squares line and interpret r²
Five students report hours studied and exam scores: (1, 55), (2, 62), (3, 64), (4, 71) and (5, 78). Find the least-squares line, r and r², and predict the score after 3.5 hours.
Find the means
Find the slope
Multiply each pair of deviations and add: (−2)(−11) + (−1)(−4) + 0(−2) + 1(5) + 2(12) = 55. The squared x-deviations add to 10.
Find the intercept
The line passes through (x̄, ȳ) = (3, 66).
Find r and r²
The squared y-deviations add to 310.
Predict
Substitute x = 3.5, which lies inside the data.
Result
ŷ = 49.5 + 5.5x; r ≈ 0.988 and r² ≈ 0.976, so the line accounts for about 97.6% of the variation in scores. At 3.5 hours it predicts 68.75.
Your turn
The line ŷ = 49.5 + 5.5x predicts 71.5 at x = 4, where the observed score was 71. What is the residual?
Show the answer and explanation
−0.5.
Residual = observed − predicted = 71 − 71.5 = −0.5, so the point sits just below the line.
Keep exploring
In Statistics, Regression shows the same equation, r and R², and the residuals 0, 1.5, −2, −0.5 and 1. The line would predict 115.5 for 12 hours, an impossible score: extrapolation.
Return to the concept →Sources and scope
Authored study material. Tool results depend on the stated inputs and model assumptions.
Try in the workspace
Open the example inputs, change a value and keep a useful result on your board.
Fit the line in Statistics Check the line in Math Open worked example on a board Statistics formulas in Math ReferenceYour existing work stays on this device. Examples open as editable copies.