Before we start, we agree on the toolbox (nothing used before it is named):
A shared dataset (call it Set A) is used by several problems so you build fluency on one table:
x=(1,2,3,4,5,6),y=(3,4,6,5,8,9).
The figure shows Set A with its least-squares line (cyan), its centroid (xˉ,yˉ) (amber
cross), and the residuals ei as amber vertical segments. Keep it open while you work L2 and
L3 — the line is what you fit, the segments are what you square to get SSE.
The fitted line from some data is y^=2.2+0.6x. (a) What is the estimated slope
β^1? (b) What is the estimated intercept β^0? (c) What does the slope
mean in words?
Recall Solution
(a) The slope is the number multiplying x: β^1=0.6.
(b) The intercept is the standalone number (value when x=0): β^0=2.2.
(c) "Each time x goes up by 1, the fitted y goes up by 0.6 on average." The slope is a
rate, not a total.
Using x=(1,2,3,4,5,6), y=(3,4,6,5,8,9), compute xˉ,yˉ,Sxx,Sxy, then
β^1 and β^0.
Recall Solution
Means first (everything centres on them): xˉ=21/6=3.5, yˉ=35/6≈5.8333.
Centred x deviations(xi−xˉ): −2.5,−1.5,−0.5,0.5,1.5,2.5.
Sxx=2.52+1.52+0.52+0.52+1.52+2.52=6.25+2.25+0.25+0.25+2.25+6.25=17.5.
Centred y deviations(yi−yˉ): −2.8333,−1.8333,0.1667,−0.8333,2.1667,3.1667.
Multiply pairwise and add:
Sxy=(−2.5)(−2.8333)+(−1.5)(−1.8333)+(−0.5)(0.1667)+(0.5)(−0.8333)+(1.5)(2.1667)+(2.5)(3.1667)=20.5.
(Term by term: 7.0833+2.75−0.0833−0.4167+3.25+7.9167=20.5.)
Slope = co-movement over x-spread: β^1=17.520.5≈1.1714.
Intercept (forces the line through (xˉ,yˉ)): β^0=5.8333−1.1714(3.5)≈1.7333.
Fitted line: y^≈1.733+1.171x.
Using the L2.1 line, predict y^ at x=4, and verify the line passes through (xˉ,yˉ)=(3.5,5.8333).
Recall Solution
At x=4: y^=1.7333+1.1714(4)=1.7333+4.6857=6.4190.
At x=3.5: y^=1.7333+1.1714(3.5)=1.7333+4.1=5.8333=yˉ ✓.
The least-squares line always passes through the centre of mass — a free sanity check.
For Set A (n=6) the residuals are ei=yi−y^i and the residual sum of squares is
SSE=∑ei2=7.31429 (you may take this). Compute s2, s, SE(β^1),
and the t-statistic for testing β1=0. (These inference steps assume the error conditions
stated in the toolbox above.)
Recall Solution
Residual variance (divide by n−2 because two coefficients were estimated):
s2=n−2SSE=47.31429=1.82857,s=1.82857≈1.35225.Standard error of the slope (defined in the toolbox — precision improves with more x-spread):
SE(β^1)=Sxxs=17.51.35225=4.183301.35225≈0.32324.t-statistic (how many SEs the slope sits from zero):
t=SE(β^1)β^1−0=0.323241.17143≈3.624on n−2=4 df.
Critical value t4,0.975=2.776. At the 5% level, do we reject β1=0? Build the 95% CI.
Recall Solution
∣t∣=3.624>2.776, so we rejectβ1=0: the slope is significant.
95% CI:β^1±t4,0.975⋅SE=1.17143±2.776(0.32324)=1.17143±0.89732=[0.274,2.069].
The interval excludes 0 — consistent with rejection. Notice it's the same decision from two
angles (Hypothesis Testing via t, or via the CI using the t-distribution with 4 df).
For Set A, Syy=SST=31.3333 and SSE=7.31429. Compute R2 two ways
(via SSE and via SSR) and confirm R2=r2, where r is the Correlation coefficient.
Recall Solution
Total up–down variation:SST=31.3333. Residual (unexplained):SSE=7.31429.
Explained:SSR=SST−SSE=31.3333−7.31429=24.0190.
R^2=\frac{\text{SSR}}{\text{SST}}=\frac{24.0190}{31.3333}=0.7666.\ \checkmark$$
**Correlation check (exact):**
$r^2 = \dfrac{S_{xy}^2}{S_{xx}S_{yy}}=\dfrac{20.5^2}{17.5\cdot31.3333}=\dfrac{420.25}{548.33}=0.7664.$
The tiny gap from $0.7666$ is only rounding in the "given" SSE; with exact arithmetic
$R^2=r^2$ identically. The line explains about **77\%** of the variance in $y$.
Without recomputing from data: suppose you could triple the spread of the x's (so Sxx
becomes 9× larger) while s stays the same. Predict what happens to SE(β^1),
then confirm with the formula. What does this say physically?
Recall Solution
Predict:SE(β^1)=s/Sxx. If Sxx→9Sxx, then
Sxx→3Sxx, so the SE should shrink to one-third.
Verify numerically: old SE =1.3523/17.5=0.3233; new SE =1.3523/157.5=0.1078,
and 0.3233/0.1078=3.00 ✓.
Physical meaning: wide-spread x-values give the line a long lever arm, so the same vertical
wobble pins the slope down far more precisely — echoing the Gauss–Markov Theorem idea that
spread-out design points make the least-squares estimator sharp.
Starting from β^1=∑iciyi with weights ci=(xi−xˉ)/Sxx, and using
Var(yi)=σ2 with independent errors, prove that
Var(β^1)=σ2/Sxx. Show why the ci collapse so neatly.
Recall Solution
What we do: treat β^1 as a fixed weighted sum of random yi. For independent terms,
variance of a sum is the sum of (weight2× variance):
Var(β^1)=∑ici2Var(yi)=σ2∑ici2.Why: independence kills all the cross-covariance terms — only the diagonal survives.
Now the collapse:
=\frac{S_{xx}}{S_{xx}^2}=\frac{1}{S_{xx}}.$$
Therefore $\text{Var}(\hat\beta_1)=\dfrac{\sigma^2}{S_{xx}}$. The numerator sum-of-squares
*is* $S_{xx}$, so one power cancels. This is exactly the "long lever" fact made rigorous, and
replacing $\sigma^2$ by $s^2$ gives the $\text{SE}(\hat\beta_1)=s/\sqrt{S_{xx}}$ we assumed in L3.
(Under Gaussian errors this variance, plugged into a $t$-ratio, is what [[Maximum Likelihood Estimation]]
would also hand you.)
New dataset Set B: x=(0,1,2,3,4), y=(1,1,2,2,4). Do the whole job:
β^1,β^0, SSE, s2, SE(β^1), the t-statistic for
β1=0, and the significance decision at 5% (t3,0.975=3.182).
Recall Solution
Means:xˉ=2, yˉ=(1+1+2+2+4)/5=2.
x-deviations:−2,−1,0,1,2 → Sxx=4+1+0+1+4=10.
y-deviations:−1,−1,0,0,2.
Sxy=(−2)(−1)+(−1)(−1)+0+0+(2)(2)=2+1+0+0+4=7.Slope:β^1=7/10=0.7. Intercept:β^0=2−0.7(2)=0.6. Line y^=0.6+0.7x.
Fitted values:0.6,1.3,2.0,2.7,3.4.
Residualsei=yi−y^i: 0.4,−0.3,0.0,−0.7,0.6.
SSE=0.16+0.09+0+0.49+0.36=1.10.s2=5−21.10=0.3667, s=0.6055.
SE(β^1)=100.6055=0.1915.t=0.19150.7=3.656 on 3 df. Since 3.656>3.182, we rejectβ1=0 at 5%:
the slope is significant even with only 5 points, because the fit is tight and the x's are spread.
Recall One-line self-test
Slope of least squares ::: β^1=Sxy/Sxx
Why divide SSE by n−2 ::: two constraints (∑ei=0, ∑xiei=0) remove 2 df, making s2 unbiased
What makes SE(β^1) small ::: large Sxx (spread-out x) and small s (little noise)
R2 in one phrase ::: fraction of y's variance explained by the line, equals r2 here