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.
1
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.
2
Find the averages
xˉ is the average number of hours, and yˉ the average score.
51+2+3+4+5=3555+62+64+71+78=66
3
Build the deviation table
Subtract the averages, then multiply and square. The three column sums are all the line needs.
Deviations from (3,66)
x
y
(x−3)(y−66)
(x−3)2
(y−66)2
1
55
22
4
121
2
62
4
1
16
3
64
0
0
4
4
71
5
1
25
5
78
24
4
144
Sum
55
10
310
4
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.
1055=5.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
6
Find r and r2
r uses all three sums. The line explains about 97.6% of the variation in scores.
√10⋅31055≈0.9880.9882≈0.976
7
Predict
Substitute x=3.5, which lies inside the data.
49.5+5.5⋅3.5=68.75
Result
y^=49.5+5.5x, 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.7x, 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 Sxy=6+1+0+2+8=17,Sxx=10 and Syy=34. Then b=17/10=1.7,a=6−1.7⋅3=0.9 and r2=172/(10⋅34)=0.85.
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⋅67=127172+127⋅(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−3107.5≈0.976
Keep exploring
In Statistics, Regression shows the same equation, r and R2, and the residuals 0,1.5,−2,−0.5and 1. The line would predict 115.5 for 12 hours, an impossible score, which is the danger of extrapolation.