Mochi’s activity: Ŷ = 10 + 2X.
X is play minutes. At X = 4, observed Y = 17.
What is the residual?
Linear regression.
Let’s make it
make sense.
Fit a line. Read a result. Question the conclusion.
50 minutes · predict → discuss → reveal
Discuss your prediction with a neighbour before each reveal.
What does a regression actually let us say?
An average is not a promise.
Three play sessions. An activity score of 18.
How far is this cat from “typical”?
We can compare it with the average at X = 3, or with the best straight-line prediction.
Observed − group average:
18 − 16 = 2 · CEF error ε.
Observed − population line:
18 − 14 = 4 · projection residual u.
The line is 2 points below the group average here.
18 − 14 = (18 − 16) + (16 − 14).
Each of 15 outcomes is equally likely. The group means are 10, 14, 16, 16, 14.
Can your line beat OLS?
One person chooses the intercept. Another chooses the slope. Make the squared vertical errors as small as possible.
OLS minimizes Σ(Yᵢ − Ŷᵢ)². With an intercept, its residuals sum to zero and its line passes through (X̄, Ȳ).
Squaring prevents positive and negative errors cancelling, and gives large errors more weight.
X = minutes of feather-wand play; Y = toy pounces.
46 more treat packs. What does that mean?
A cat-treat brand has a TV coefficient of 0.04576. Which interpretation fits?
B. For a $1,000 TV increase:
0.04576 thousand packs × 1,000 = 45.76 packs.
Radio and newspaper spending stay fixed.
Predict first: How many more packs for a $500 TV increase?
TV: +45.76 packs. Radio: −188.53 packs.
45.76 − 188.53 = −142.77 ≈ −143 packs.
Both budgets change. This is an adjusted prediction, not a causal spending recommendation.
A cat-treat brand’s campaign
| Term | Coefficient |
|---|---|
| Intercept | 2.93889 |
| TV | 0.04576 |
| Radio | 0.18853 |
| Newspaper | −0.00104 |
Sales: 1,000 treat packs. Budgets: $1,000.
Compare two predictions: TV changes;
radio and newspaper stay the same.
ISL resources.
Test a budget reallocation
Moving $1,000 from radio to TV predicts a change of −142.77 packs. Its standard error is 60 packs. Test whether the adjusted slopes are equal at 5% using a two-sided cutoff of 2. What would justify a causal recommendation?
Worked answer
The contrast is TV minus radio. Under equal slopes, its expected value under the null is zero. The statistic is −142.77 / 60 ≈ −2.38. Reject at 5%. The interval is −142.77 ± 120, or [−262.77, −22.77] packs. A causal interpretation also needs a source of variation in the reallocation unrelated to other sales determinants, such as random assignment.
Should I drink my way to an A?
Students who drink more coffee have higher scores. Would you prescribe another cup?
What if well-prepared students also tend to buy more coffee?
Here, higher preparation predicts both more coffee and higher scores. Omitting it makes the coffee slope larger: 8 = 2 + 6.
Even the adjusted slope is not automatically causal. We still need a design or assumptions that justify an intervention claim.
Optional formula: β₁short = β₁ + β₂ Cov(X,W)/Var(X), when Cov(X,u)=0 in the full model.
X = coffee cups; Y = exam score. The dots do not tell us what would happen if we changed a student’s coffee intake.
Same slope. Different confidence.
The estimated slope stays at 0.20 toy pounces per extra minute of cat play. What happens when its standard error grows?
SE estimates how much the fitted slope varies across repeated samples.
Larger SE → wider interval → smaller |t| for a fixed estimate and null.
The interval concerns the population slope. It does not describe the spread of individual cats’ pounces.
Over repeated samples, a valid 95% interval procedure covers the fixed population slope approximately 95% of the time.
“Not significant” does not mean “zero”.
Cat-treat newspaper-ad estimate: −0.001037.
HC1 standard error: 0.006423.
What can we conclude?
B. At 5%, fail to reject βN = 0. The interval includes negative and positive slopes; it does not prove the slope is exactly zero.
The p-value is calculated under H₀. It is not the probability that H₀ is true.
Work from estimate ÷ uncertainty
t ≈ −0.16; two-sided p ≈ 0.872.
95% CI: −0.001037 ± 1.96 × 0.006423
≈ [−0.01363, 0.01155].
Translate the interval into cat-treat packs.
About −13.6 to +11.6 predicted cat-treat packs sold per $1,000 of newspaper spending, holding TV and radio fixed.
+10 packs: inside the interval.
+20 packs: outside the interval.
Zero is one compatible value; it is not the only one.
Test the business decision
The campaign pays for itself above 8 extra packs per $1,000. The estimated newspaper slope is −1.037 packs, with SE 6.423. Write and test the directional claim at 5%, using 1.6 as the normal cutoff. Can you rule out a profitable campaign?
Worked answer
Use H₀: β ≤ 8 against H₁: β > 8. At the boundary, t = (−1.037 − 8) / 6.423 ≈ −1.41. This is below +1.6, so the data do not establish profitability. To rule out a profitable effect, check the upper one-sided bound. It is −1.037 + 1.6 × 6.423 ≈ 9.24 packs, above 8. Both conclusions remain possible.
Four cat shelters. One regression summary.
Compare 11 cats in each shelter: play minutes and activity scores. The four regression summaries almost match. Would you trust them equally?
I: a roughly linear cloud of cats.
II: a curved activity pattern.
III: one unusually active cat.
IV: one cat determines the slope.
R² measures in-sample fit relative to a constant prediction. It does not establish the right functional form, causality, or good predictions on new data.
R’s original dataset documentation
What could the cats’ data look like?
The four regression summaries match only approximately.
New reference cat. Same predictions.
Make Miso the reference cat. What happens to the intercept? To the other coefficients? To predicted playtime?
The intercept is the reference group’s sample mean. Each dummy coefficient is a gap from that group. Changing the reference changes the coefficients, not the fitted group means. All three cats’ records stay in the model.
Why not include all three dummies plus an intercept? The dummies sum to 1: perfect collinearity.
Mean daily playtime · minutes
| Cat | Coefficient / meaning |
|---|
Each daily record belongs to exactly one cat: Mochi, Nori, or Miso.
What are the residuals telling you?
Our model predicts cats’ activity scores from playtime. What pattern remains in the residuals? Would new standard errors fix it?
Cat-activity residuals. In C, we observe the same cat on successive days. A pattern suggests what to investigate, not a definitive cause.
A · Mean shapeInvestigate curvature.
B · Error spreadAllow unequal variance.
C · DependenceAccount for related days.
Three claims. Can you explain each?
Write your answers alone for 60 seconds. Compare with a neighbour for 30 seconds, then explain your reasons.
A 95% interval for the cat-play slope is [−0.4, 0.7].
Have we proved “no relationship”?
Adding a random “lucky collar number” to the cat-activity model raises training R².
Is the model now better?
More cats. Less wobble.
In our cat-activity model, which helps precision: more cats, less noise, or more variation in playtime?
Under this correctly specified model, all three changes improve precision. Repeated estimates center on the true slope of 2.
Unbiasedness: correct average at a given n.
Consistency: estimates concentrate on the target as n grows. More data does not automatically fix a wrong target.
40 cats → one fitted slope. Repeat 100 times.
X: centered playtime. Y: activity score.
Y = 5 + 2X + u. SD(β̂₁ | X) = σ / √Σ(Xᵢ − X̄)².
A coefficient is not always the whole gap.
Y: cat activity score. Z: playtime in minutes.
D = 1: wand toy; D = 0: ball toy.
Is the wand-versus-ball gap always 6 activity points? Compare cats at the same play duration.
For D=0: 18 + 0.8Z.
For D=1: 24 + 1.2Z.
Group gap at Z=z: 6 + 0.4z.
The coefficient on D is the gap at Z=0. An adjusted toy-group gap alone does not establish a causal effect of the toy.
“Eight percent” is an approximation.
A cat-video channel: Y > 0 is daily views; S is the number of cat videos posted that day.
When β₁ = 0.08, does one more cat video mean exactly 8% more views?
Two days: 100 and 400 views.
Arithmetic mean: (100 + 400) / 2 = 250.
Geometric mean: √(100 × 400) = 200.
The conditional geometric mean of daily views is multiplied by eβ₁. The exact percentage difference is 100(eβ₁−1)%.
This does not automatically describe the conditional arithmetic mean of daily views. Retransformation requires accounting for the conditional distribution of the log error.
The approximation is closer when |β₁| is small.
Example: exp(E[log Y | S=s+1]) / exp(E[log Y | S=s]) = exp(β₁). This concerns an association unless causal assumptions justify more.
You cannot just add standard errors.
A cat-activity model has slopes 0.04 for wand-play minutes and 0.01 for ball-play minutes. Their SEs are 0.02 and 0.03. How uncertain is the sum?
= √(SE₁² + SE₂² + 2 Cov(β̂₁,β̂₂))
Positive covariance makes the sum more variable; negative covariance makes it less variable. Here Cov = ρ × 0.02 × 0.03.
For a difference, the covariance enters with a minus sign. Use a′V̂a for a general linear combination.
Test H₀: β₁ + β₂ = 0
This is one restriction. It is different from requiring both β₁ = 0 and β₂ = 0.
A zero sum is not two zeros.
For the cat-treat campaign, suppose βR = 0.20 and βN = −0.20. Which null is satisfied?
A. βR + βN = 0
B. βR = 0 and βN = 0
A is satisfied; B is not. A has one independent restriction. B has two.
Rejecting B gives evidence that at least one slope differs from zero. It does not establish that both are nonzero, nor identify a causal effect.
Campaign joint test
Estimated slopes: radio 0.18853; newspaper −0.001037.
H₀: βR = βN = 0, holding TV fixed.
352.55 > 5.99
5% cutoff for χ²2: 5.99.
Reject the both-zero null.
Evidence that at least one adjusted slope differs from zero.
Not all “zero errors” say the same thing.
Model a cat’s activity score using playtime. Which zero-error statements are automatic, and which need a linear conditional mean?
Definition. We subtract the true conditional mean.
Population minimization. Orthogonality need not mean zero residual average at each X.
Sample identity. With an intercept, fitted residuals sum to zero.
Linear conditional mean. Requires E[Y | X] = X′β; fitting OLS alone does not supply it.
Here Y is cat activity; X contains playtime and an intercept. In vector notation k counts the intercept.
Zero sample correlation between X and fitted residuals is an OLS identity. It does not establish exogeneity or causal identification. Consistency for the population projection can hold without a linear CEF with IID observations, finite moments, and full-rank regressors.