hanegreefs.com/ statistics II
Home / Chapters / 09
Chapter 09 · Course ch. 16

Inference for regression

LINE conditions, the slope t-test and interval, and intervals for predictions.

About 15 min read · Lecture material: HOC 9

Priority labels: ImportantNeutralLess important show where to spend revision time.

From a fitted line to a population modelImportant

Chapter 8 described the sample. To generalise, we posit a population model in which, at each x, the responses scatter around a true mean line:

Formula
y = β₀ + β₁x + ε, ε ~ N(0, σ²)
SymbolMeaningEstimated by
β₀, β₁population intercept and slopeb₀, b₁
εrandom error of one observationresidual e = y − ŷ
σspread of the errors around the lines_e
Formula
s_e = √( Σ e² / (n − 2) )

The divisor n − 2 reflects the two estimated parameters. s_e is the typical size of a residual in y's own units (the TI-84 labels it s; R calls it the "residual standard error"). Smaller s_e means a tighter fit.

The LINE conditionsImportant

AssumptionHow to check
LLinearity: the true relation is straightScatterplot; residual plot without curvature
IIndependent errorsData collection; residuals against time or order
NNearly Normal errorsHistogram or Normal probability plot of the residuals
EEqual spread at all xResiduals against fitted values: a band, not a fan

Check in the order L → I → E → N and stop to rethink if an early one fails. Chapter 10 shows what to do when conditions break.

The standard error of the slopeImportant

The slope b₁ changes from sample to sample. Its precision improves with less scatter around the line (small s_e), more spread in x (large s_x) and more data (large n):

Formula
SE(b₁) = s_e / ( s_x · √(n − 1) )
Formula
t = (b₁ − β₁) / SE(b₁) ~ t with n − 2 degrees of freedom

Testing the slopeImportant

H₀: β₁ = 0 (no linear association) against β₁ ≠ 0 (or a one-sided alternative). If β₁ = 0 the best prediction is ȳ whatever x is, so x carries no linear information.

Formula
t = b₁ / SE(b₁), df = n − 2
  • The test of β₁ = 0 is equivalent to the test of ρ = 0 for the population correlation.
  • Software gives the two-sided p-value. For a one-sided alternative, halve it — but only if b₁ has the sign the alternative predicts.

Interval for the slopeImportant

Formula
b₁ ± t*ₙ₋₂ · SE(b₁)

Read it as: "we are C% confident that each extra unit of x goes with a true mean change in y between these limits." An interval that excludes 0 agrees with a significant two-sided test.

Worked example

Does advertising pay? (data from chapter 8)

For the 8 weeks of spend and sales, b₁ = 2.083, s_e = 1.448 and s_x = 2.449. Test H₀: β₁ = 0 and build a 95% interval.

1

Standard error of the slope

SE(b₁) = 1.448 / (2.449 × √7) = 0.2235
2

Test statistic

t = 2.083 / 0.2235 = 9.32, df = 6 → p ≈ 0.0001
3

Interval

t*₆ = 2.447 → 2.083 ± 2.447 × 0.2235 = [1.54, 2.63]
Answer

Strong evidence of a positive linear relation: each extra €1,000 of spend goes with roughly €1,540–€2,630 more weekly sales (95% confidence). Eight points is a small sample, so check the residuals before trusting this.

Predictions: two different questionsImportant

For a new value x_v the point prediction is ŷ_v = b₀ + b₁x_v. The uncertainty depends on what you ask:

CI for the mean response μ_vPrediction interval for one new y_v
QuestionWhere does the mean response of every unit at x = x_v sit?Where will a single new unit with x = x_v fall?
SE²SE²(b₁)(x_v − x̄)² + s_e²/nSE²(b₁)(x_v − x̄)² + s_e²/n + s_e²
WidthNarrowerAlways wider (adds individual scatter)
NormalityHelped by the CLT for large nNeeds Normal errors; the CLT does not rescue it
Formula
ŷ_v ± t*ₙ₋₂ · SE(μ̂_v) ŷ_v ± t*ₙ₋₂ · SE(ŷ_v)

Both bands widen as x_v moves away from x̄ — hence the bow-tie shape around the line — and are narrowest at x̄.

Worked example

Spending 5.5 k€

1

Point prediction

ŷ = 9.75 + 2.083 × 5.5 = 21.21
2

Mean response

SE = √(0.2235² × 1² + 1.448²/8) = 0.559 → 21.21 ± 2.447 × 0.559 = [19.84, 22.58]
3

Single week

SE = √(0.559² + 1.448²) = 1.552 → 21.21 ± 2.447 × 1.552 = [17.41, 25.01]
Answer

The average sales at a 5.5 k€ budget are pinned down to about ±1.4; a particular week could land anywhere from roughly 17.4 to 25.0.

Reading regression outputImportant

TI-84 LinRegTTestR summary(lm)Meaning
a(Intercept) Estimateb₀
bx Estimateb₁
t, pt value, Pr(>|t|)test of β₁ = 0 (two-sided)
dfdegrees of freedomn − 2
sResidual standard errors_e
r², rMultiple R-squaredR², r

The calculator does not print SE(b₁); recover it as b/t. It has no built-in command for prediction intervals, so combine the formulas above with invT. R gives everything:

fit <- lm(sales ~ spend, data = d) summary(fit) confint(fit, level = 0.95) predict(fit, data.frame(spend = 5.5), interval = "confidence") predict(fit, data.frame(spend = 5.5), interval = "prediction")

PitfallsImportant

PitfallConsequence
No scatterplotCurvature, clusters and outliers go unnoticed
Quoting r or R² without the plotCan hide outliers and non-linearity
One-sided p taken straight from softwareOutput is two-sided; halve it after checking the sign
Confusing the CI for the mean with a prediction intervalAnswers the wrong question
ExtrapolatingUnreliable, and the intervals understate the risk
Causal wording from observational dataConfounding may explain the slope

Key takeaways

  • Slope inference uses t with n − 2 df: t = b₁/SE(b₁), SE(b₁) = s_e / (s_x√(n−1)).
  • Check L, I, E, N (in that order) before trusting any p-value or interval.
  • CI for a mean response is narrower than a prediction interval for one case; both bow outward away from x̄.
Question
Tap or press space to reveal
Answer
Did you know it?

Multiple choice

Ch 09 · Question 1

Degrees of freedom for inference on a simple regression slope?

Why: Two parameters are estimated.
Ch 09 · Question 2

Which does NOT shrink SE(b₁)?

Why: Larger s_e inflates SE.
Ch 09 · Question 3

H₀: β₁ = 0 is rejected with p < 0.001. This means…

Why: Only association is shown.
Ch 09 · Question 4

A prediction interval is… the CI for the mean response at the same x.

Why: It adds individual scatter s_e².
Ch 09 · Question 5

Intervals are narrowest at…

Why: (x_v − x̄)² = 0.
Ch 09 · Question 6

Output gives b₁ = 2.1, t = 7. SE(b₁) = ?

Why: 2.1/7 = 0.3.
Ch 09 · Question 7

Which condition is checked first in LINE?

Why: If linearity fails, nothing else matters.
Ch 09 · Question 8

s_e measures…

Why: Typical size of a residual.

Exam-style questions

Exam-style · Ch 09

Software gives b₁ = 1.92, SE(b₁) = 0.31, n = 20, s_e = 3.1. Test H₀: β₁ = 0 and give a 95% interval. Which assumptions need checking?

Show outline of a full answer
  1. t = 1.92/0.31 ≈ 6.2 on 18 df, p < 0.0001.
  2. t*₁₈ = 2.101 → 1.92 ± 0.65 = [1.27, 2.57].
  3. LINE: linearity, independence, equal spread, Normal residuals.
  4. Plots: scatter, residuals vs fitted, histogram/Normal plot of residuals.
Exam-style · Ch 09

Explain the difference between a confidence interval for the mean response and a prediction interval at x = 5.5. Which is wider and why?

Show outline of a full answer
  1. CI: average y at x; PI: a single new y.
  2. SE²_μ = SE(b₁)²(x−x̄)² + s_e²/n; SE²_ŷ = SE²_μ + s_e².
  3. PI always wider, never shrinks below s_e.
  4. Both are narrowest at x̄ and flare outwards.

Regression inference labInteractive

Switch on the confidence and prediction bands and read SE(b₁), t, p and the slope interval.