Chalk−1

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 r2, and predict the score after 3.5 hours.

Plot and check

The five points rise in a nearly straight band, with no curve and no point far from the rest. A line is a reasonable model.

Find the averages

x¯ is the average number of hours, and y¯ the average score.

1+2+3+4+55=355+62+64+71+785=66

Build the deviation table

Subtract the averages, then multiply and square. The three column sums are all the line needs.

Deviations from (3,66)
xy(x−3)⁢(y−66)(x−3)2(y−66)2
155224121
2624116
364004
4715125
578244144
Sum5510310

Find the slope

Divide the sum of products by the sum of squared x-deviations. Each extra hour of study goes with 5.5 more points.

5510=5.5

Find the intercept

The line passes through (x¯,y¯)=(3,66), so a=66−5.5⋅3.

66−5.5⋅3=49.5

Find r and r2

r uses all three sums. The line explains about 97.6⁢% of the variation in scores.

5510⋅310≈0.9880.9882≈0.976

Predict

Substitute x=3.5, which lies inside the data.

49.5+5.5⋅3.5=68.75

Result

y^=49.5+5.5⁢x, with r≈0.988 and r2≈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

1. One like the example

Five plants get 1, 2, 3, 4 and 5 hours of extra light a day and grow 3, 5, 4, 8 and 10 cm. Find the least-squares line and r2.

Show the answer and explanation

y^=0.9+1.7⁢x, with r2=0.85 (r≈0.922).

The averages are x¯=3 and y¯=6. The y-deviations are −3, −1, −2, 2 and 4, so Sx⁢y =6+1+0+2+8 =17, Sx⁢x=10 and Sy⁢y=34. Then b=17⁢/10=1.7, a=6−1.7⋅3=0.9 and r2=172/⁢(10⋅34) =0.85.

(1,3),(2,5),(3,4),(4,8),(5,10)3+5+4+8+105=61710=1.76−1.7⋅3=0.917210⋅34=0.85
(1,3),(2,5),(3,4),(4,8),(5,10)3+5+4+8+105=61710=1.76−1.7⋅3=0.917210⋅34=0.85

2. A variation

Fathers in a study average 170 cm, with standard deviation 6 cm. Their adult sons average 172 cm, with standard deviation 7 cm, and r=0.5. Predict the height of a son whose father is 182 cm.

Show the answer and explanation

About 179 cm.

The slope is b=r⋅sy/sx =0.5⋅7⁢/6 =7⁢/12 ≈0.583 cm per cm, and the line passes through (170,172). That gives y^=172+(7⁢/12)⁢(182−170) =179. The father is 2 standard deviations above average, and his son is predicted to be only 1 above, which is regression toward the mean.

0.5⋅76=712172+712⋅(182−170)=179

3. Somewhere new

The study line’s residuals are 0, 1.5, −2, −0.5 and 1, and the scores’ squared deviations from their average add to 310. Find r2 without using r.

Show the answer and explanation

r2=1−7.5⁢/310≈0.976.

Square the residuals and add, 0+2.25+4+0.25+1 =7.5. That is SSE, the variation the line leaves. 1−7.5⁢/310≈0.976 matches 0.9882, because r2 is exactly the share of the variation the line explains.

0+2.25+4+0.25+1=7.51−7.5310≈0.976

Keep exploring

In Statistics, Regression shows the same equation, r and R2, and the residuals 0, 1.5, −2, −0.5 and 1. The line would predict 115.5 for 12 hours, an impossible score, which is the danger of extrapolation.

Return to the concept →
Sources and scope

Authored study material. Tool results depend on the stated inputs and model assumptions.

After reading

Try it, then study it

Open the example in its tool to check steps or change values, then review the key terms as flashcards.

Fit the line in Statistics Check the line in Math Study the 8 key terms Open worked example on a board Statistics formulas in Math Reference

Your existing work stays on this device. Examples open as editable copies.