Back to the Introduction to Statistics outline The Course Maker
Introduction to Statistics outline
Week 17 · Lecture outline

Week 17 — Lecture Outline · Linear Regression with Inference + Course Synthesis

Introduction to Statistics Generic evergreen edition

Course: Introduction to Statistics (18-week generic edition)
Objectives covered: Objective 8 — Fit and interpret a simple linear regression and carry out inference for the slope. The synthesis segment revisits Objectives 6, 7, and 9 (intervals, tests, chi-square) as review — this is the last instructional week.
SLOs touched: A (reason quantitatively from data) · B (communicate results to a non-technical audience)
Meeting pattern: planned as 2 sessions × ~75 min = ~150 min. Segment minutes below total ~150; scale them to your own pattern.


Week at a Glance

The week's big question "When can a line drawn through yesterday's data be trusted to predict tomorrow — and how do we tell a real slope from a lucky tilt?"
By the end of the week, students can… (1) interpret the slope and intercept of a least-squares line in context; (2) read as the share of variation explained and a residual as actual − predicted; (3) judge a residual plot and refuse to extrapolate; (4) run the t-test and confidence interval for the slope from computer output (df = n − 2); (5) choose the right procedure for any Week 11–17 scenario.
Key vocabulary least-squares line, ŷ (predicted value), slope b, intercept a, r² (coefficient of determination), residual, residual plot, extrapolation, conditions for inference (LINE), population slope β, standard error of the slope SE(b), t-test / confidence interval for the slope, df = n − 2, choosing the right procedure
Materials slides (Deck 17), the Week 17 chapter, the week's readings + video links, a spreadsheet (Google Sheets or Excel), the embedded t-table (same one since Week 11), the student's chatbot for the AI-critique moment and the tutorial
Timing note 8 segments, ~150 min total. Session 1 = Segments 1–4 (~75). Session 2 = Segments 5–8 (~75).

Segment 1 — Hook & the Promise (8 min) · Session 1 opens

Hook. "Your energy bill arrives and it's ugly. You mutter: it was a cold month. Congratulations — you just ran a regression in your head: you used one number you know (temperature) to explain another (energy use). Every 'it was cold, that's why' is a slope waiting for a formula."

  • Last week we finished the inference tour for categories. Today the final tool: a line that turns one variable into a prediction of another — and then we put its slope on trial with the same t-machinery you've used since Week 11.
  • Callback: "In Week 4 you drew scatterplots and computed r — you could see and measure a linear relationship. Today you finally get to use it."

The promise (write it on the board): "By the end of this week you can take any two-variable dataset, fit the line, say exactly what its slope means, refuse to let it lie to you outside the data — and decide, with a p-value, whether the slope is real. And you can look at ANY question from the second half of this course and name the right tool for it."

Why it matters line (memory hook): "A regression line is a promise about averages, made by data — your job is to check the fine print."


Segment 2 — The Least-Squares Line: Slope & Intercept (22 min)

Plain language first.
- A scatterplot with a linear pattern can be summarized by one straight line: ŷ = a + bx, where ŷ ("y-hat") is the predicted y for a given x. The hat means predicted, not actual — same hat, same warning, as p̂ in Week 12.
- Of all possible lines, the least-squares line is the one that makes the squared vertical misses as small as possible. Memory hook: "the line of least regret — it minimizes the squared misses."
- b (slope) = the predicted change in y for each one-unit increase in x. a (intercept) = the predicted y when x = 0 — read it with care (x = 0 must make sense and sit near the data).
- Two shortcut facts run everything: b = r · (s_y ⁄ s_x)"correlation sets the direction, the SDs set the exchange rate" — and the line always passes through (x̄, ȳ): "the average day sits on the line." So a = ȳ − b·x̄.

One fully worked example (do every step out loud).

A homeowner logs 30 heating-season days: x = the day's average outdoor temperature (°C, ranging 2 to 18), y = the home's energy use (kWh). Summary statistics: x̄ = 10 °C, s_x = 4 °C; ȳ = 30 kWh, s_y = 8 kWh; r = −0.9.
- Slope: b = r · (s_y ⁄ s_x) = (−0.9) × (8 ÷ 4) = (−0.9) × 2 = −1.8 kWh per °C.
- Intercept: a = ȳ − b·x̄ = 30 − (−1.8)(10) = 30 + 18 = 48 kWh.
- The line: ŷ = 48 − 1.8x.
- Say the slope out loud, in context: "Each additional degree of outdoor temperature predicts, on average, 1.8 kWh LESS energy use." Not "causes" — predicts, on average.
- The intercept: at 0 °C the line predicts 48 kWh. Here 0 °C sits just below the coldest observed day (2 °C), so it's a near-data anchor — meaningful-ish. (Next segment shows what happens when x = 0 is nowhere near the data.)
- Check the "average day" fact: ŷ at x = 10 is 48 − 1.8(10) = 48 − 18 = 30 = ȳ. The line really does pass through (x̄, ȳ).

Land the key idea: the slope is the headline. Every slope interpretation this week must have four parts: per one unit of x · predicted · on average · in context units.


Segment 3 — r², Residuals & the Extrapolation Trap (20 min)

Plain language first.
- (the coefficient of determination) = the fraction of the variation in y that the linear relationship with x explains. Here r = −0.9, so r² = (−0.9)² = 0.81: 81% of the day-to-day variation in energy use tracks temperature; the other 19% is everything else (laundry day, guests, thermostat fiddling). Memory hook: "r² is a share, not a grade."
- A residual = actual y − predicted ŷ — the vertical miss. Above the line → positive (the line under-predicted); below → negative.

Worked example, continued (all arithmetic shown).

  • Predict a 5 °C day: ŷ = 48 − 1.8(5) = 48 − 9 = 39 kWh.
  • One actual 5 °C day used 42 kWh. Residual = actual − predicted = 42 − 39 = +3 kWh — the home used 3 kWh more than the line predicted. The line missed low; the point sits above the line.
  • Residual plot = residuals vs. x. Read it like a doctor reads an X-ray: random, patternless scatter around zero = the linear model is doing its job. A curve = the relationship isn't a line. A fan (spread growing) = predictions are less reliable at one end. Outliers = investigate.
  • Extrapolation — the trap:
    Predict a 35 °C summer day with the same line: ŷ = 48 − 1.8(35) = 48 − 63 = −15 kWh. Negative energy use — the line predicts the power company pays you. Impossible. The line was built on 2–18 °C heating-season days; at 35 °C the relationship it captured doesn't just weaken, it reverses (air conditioning kicks in and hot days raise energy use).
    Memory hook: "Inside the data, the line predicts. Outside the data, the line is fiction."

Segment 4 — Misconceptions + Quick Interaction (25 min) · Session 1 closes (~75)

Name the misconceptions out loud, then cure each:

  • "A significant slope (or a big r²) means x causes y."
    Cure: Week 4's line still runs the show — correlation is a handshake, not a push. Regression measures the handshake precisely; only random assignment earns the word "because." The homeowner data can't tell "cold → heater" apart from any lurking third variable — the arithmetic never checks the arrow.
  • "r² = 0.81 means the line's predictions are 81% accurate (or right 81% of the time)."
    Cure: r² is a share of variation explained, not an accuracy rate. Individual predictions still miss — the residuals are the misses.
  • "The intercept is always meaningful."
    Cure: the intercept is just where the line crosses x = 0. If x = 0 is absurd or far from the data (a 0-mm flipper, a 0-m² apartment), the intercept is a mathematical anchor, not a statement about the world.
  • "A strong line can predict anywhere."
    Cure: the −15 kWh disaster. Predictions live inside the range of x the line was fitted on. Extrapolation isn't "less precise" — it can be flat wrong, because the pattern itself can change out there.
  • "Swapping x and y doesn't matter — the line is the line."
    Cure: regression is directional: x explains, y responds. Swap them and slope, intercept, and predictions all change (r is the only survivor). Decide what predicts what before fitting.

Interaction — Think-Pair-Share (rapid-fire, ~12 min):
Put these on a slide; students answer solo (30 sec), compare with a neighbor, then class vote. Using ŷ = 48 − 1.8x (energy example):
1. Predicted energy use on a 15 °C day? (48 − 27 = 21 kWh.)
2. A 15 °C day actually used 18 kWh — the residual, and is the point above or below the line? (18 − 21 = −3; below.)
3. True or false: "r = −0.9 means 90% of variation is explained." (False — r² = 0.81, so 81%. And r² is the share, not r.)
4. Your roommate says: "the intercept 48 means a house uses 48 kWh when it's freezing." Fair? (Roughly — 0 °C is near the data's cold edge here, so it's a defensible anchor; the sin is automatic trust, not this particular reading.)
5. Predict energy use at 40 °C? (Refuse — extrapolation; the line gives 48 − 72 = −24 kWh, fiction.)
6. Does the −1.8 slope prove colder weather causes the higher usage? (No — strong, sensible association; causation needs design, not arithmetic. It's plausible physics, but the regression alone doesn't prove it.)


Segment 5 — Is the Slope Real? The t-Test for β (22 min) · Session 2 opens

Hook back in: "Two random columns of numbers will produce a nonzero slope — luck alone tilts lines. So the question that decides whether your regression means anything: is the slope real, or is this tilt just noise? You already own the machinery to answer it."

Plain language first.
- The fitted slope b comes from a sample, so it varies sample to sample — exactly like x̄ (Week 10) and p̂ (Week 12). Behind it stands the true population slope β.
- H₀: β = 0the flat line. If β = 0, x tells you nothing about y; the "relationship" is luck. Hₐ: β ≠ 0 (two-sided, our default).
- Test statistic: t = (b − 0) ⁄ SE(b) with df = n − 2 (a line spends two degrees of freedom — one for the slope, one for the intercept). Same t-logic, same table, as Weeks 11 and 14.
- Conditions — the LINE check (say it as a word): Linear pattern in the scatterplot · Independent observations · Normal-ish residuals (no wild skew/outliers) · Equal spread of residuals across x (no fan). Check L and E on the residual plot, N on a histogram of residuals.

The embedded t-table (the same course table since Week 11; regression just changes the df rule to n − 2):

The table below gives the course's two-sided critical values t*.

df t* (90%) t* (95%) t* (99%)
9 1.833 2.262 3.250
15 1.753 2.131 2.947
24 1.711 2.064 2.797

Problems in this course land on these df; for any other df, technology supplies the value.

One fully worked example — reading real-style output (this is the week's second centerpiece).

An HR analyst at one company regresses annual salary (in thousands of dollars) on years of experience for n = 26 employees and gets this output:

Predictor Coef SE Coef T P Constant 41.50 2.30 18.04 0.000 Experience 2.50 1.25 2.00 0.057 R-Sq = 14.3%

  • The fitted line: ŷ = 41.50 + 2.50x — each additional year of experience predicts, on average, $2,500 more salary (2.50 thousand).
  • The slope test, by hand from the output: t = Coef ÷ SE Coef = 2.50 ÷ 1.25 = 2.00, df = n − 2 = 26 − 2 = 24.
  • Compare: |t| = 2.00 < t = 2.064 (df 24, 95%) → fail to reject H₀* at the 5% level. The output agrees: P = 0.057 > 0.05.
  • Conclusion, in words: "With only 26 employees, this positive-looking slope is not statistically convincing at the 5% level — a flat line (β = 0) remains plausible."
  • The trap to spring: "So experience doesn't matter here?" NO — fail to reject ≠ accept (Week 13's law). The data are merely inconclusive; note how close 0.057 sits to 0.05, and r² = 14.3% says experience explains only a modest share at this company anyway.

Segment 6 — The CI for the Slope & the Duality (18 min)

Plain language first. The confidence interval answers the better question: how big might the true slope β actually be?
- b ± t* · SE(b), df = n − 2 — the same recipe as every interval since Week 11: estimate ± (table value)(standard error).

Worked example, continued (all arithmetic shown).

95% CI for the experience slope: 2.50 ± 2.064 × 1.25.
- Margin of error: 2.064 × 1.25 = 2.58.
- Interval: 2.50 − 2.58 = −0.08 to 2.50 + 2.58 = 5.08(−0.08, 5.08) thousand dollars per year.
- In words: "We are 95% confident each year of experience is associated with between −$80 and +$5,080 in predicted salary."
- The duality, visible: the interval (barely) contains 0 — exactly why the test (barely) failed to reject at 5%. Interval contains 0 ⇔ two-sided test fails to reject at the matching α. One computation, two readings — this closed the loop in Week 14 and it closes it again here.

Reading output is the skill: locate Coef (the slope b), SE Coef (its standard error), T (their ratio — recompute it as a habit), P (the two-sided p-value), R-Sq (r² as a percent). You will never compute SE(b) by hand in this course — technology reports it; you interpret it.


Segment 7 — Course Synthesis: Choosing the Right Procedure (20 min)

Plain language first. "You now own every tool this course teaches. The final skill — the one the cumulative final actually tests — is choosing. And choosing is one question asked well: what shape is the answer?"

The decision map (put it on one slide; students will photograph it):
- Answer is one mean (an average) → one-sample t (interval to estimate, test to judge a claim), df = n − 1.
- Answer is one proportion (a yes/no percent) → one-proportion z (interval or test).
- Answer compares two groups → two-sample t (means) or two-proportion z (percents); paired data → one-sample t on the differences.
- Answer is counts across categories → chi-square (goodness-of-fit for one variable vs. claimed percents; independence for a two-way table).
- Answer predicts one number from another → regression: the line, r², and the t-test/CI for the slope, df = n − 2.

Memory hook: "Mean, proportion, counts, or a line? Name the answer's shape, and the procedure names itself."

Interaction — rapid-fire "name the tool" (with answers):
1. Does the number of plants in an office predict employees' reported focus scores? (Regression — slope inference.)
2. What fraction of a town's streetlights are LED? A crew inspects a random 150. (One-proportion z-interval.)
3. Does the mean mass of this orchard's apples differ from the 180 g the packing plant assumes? (One-sample t-test.)
4. Do two trailheads differ in average daily hikers? (Two-sample t-test.)
5. Is preferred music genre independent of age group? (Chi-square test of independence.)
6. Did the proportion of riders wearing helmets change after new signage? (Separate before and after samples.) (Two-proportion z-test.)

The course in one breath (the synthesis story, 3 minutes, told with feeling): Weeks 1–4: describe — get honest data and summarize it. Weeks 5–8: chance — learn how randomness behaves so we can recognize it. Weeks 10–17: infer — use a sample plus the logic of chance to say something disciplined about the world, with a margin of humility attached. Every tool in the map is that one sentence wearing different clothes.

Final-exam framing (say it plainly): the final in Week 18 is cumulative, 60 multiple-choice — a low-stakes checkpoint at 5%, exactly like the midterm. The study guide, practice exam, and exam-prep tutorial are all in the Week 18 module. Steady weekly work has already banked the grade; Week 18 is the victory lap.


Segment 8 — Technology Workflow + AI-Critique, Callback & Hand-off (15 min) · Session 2 closes (~75)

Technology workflow — the whole fit in three cells (exact steps):
1. Put x-values in column A (say A2:A31) and y-values in column B.
2. =SLOPE(B2:B31, A2:A31) → b. =INTERCEPT(B2:B31, A2:A31) → a. =RSQ(B2:B31, A2:A31) → r². (=CORREL(B2:B31, A2:A31) → r.) Argument order: y-range first, then x-range — the classic silent error is swapping them.
3. See it: select both columns → Insert ▸ Chart ▸ Scatter, then in the chart editor Customize ▸ Series ▸ Trendline (check "Show R²"). Google Sheets and Excel behave identically; a Desmos-class tool fits the same line from pasted points.
4. Quick check with a tiny practice set — type x: 1, 2, 3, 4, 5 and y: 3, 5, 6, 9, 12. You should get slope 2.2, intercept 0.4, r² 0.968. If you don't, your ranges are swapped or misaligned.

AI-critique moment (students verify, not consume):

Paste the salary output from Segment 5 into your chatbot and ask: "Interpret this regression for me." Then grade its answer against this week: Does it call R-Sq "the correlation"? (r² is the share of variation explained — the correlation here is √0.143 ≈ 0.38.) Does it declare "experience significantly increases salary"? (P = 0.057 — fails at 5%; and "increases" smuggles in causation.) Does it happily predict salary for 40 years of experience? (Extrapolation.) The tool drafts, you judge — this exact audit is in the week's data lab.

Callback + tease:
- Callback: "Week 4 gave you the scatterplot and r — a handshake you could see. Week 17 measured the handshake, tested it, and bounded it. It is still not a push."
- Tease Week 18: "Final Exam Week — cumulative, and the exam bundle (study guide, practice exam, exam-prep tutorial) is waiting in the Week 18 module. Eighteen weeks ago a statistic was a number someone told you. Now it's a claim you know how to interrogate. The last chapter of the story is yours."

Hand-off (the week's work):
- Chapter 17 (the primary reading) if they haven't read it — then Lecture Tutorial 17 (AI tutor, share-link submission) — the line, r²/residuals, slope inference, choosing the procedure.
- Data Lab 17 (the penguin capstone: fit the flipper-length → body-mass line) · Quiz 17 (end of week) · Discussion 17 (the tool you'll keep) · Assignment 17 (AI-coached, includes the choose-the-procedure synthesis).


Instructor FAQ — Common Stumbles

Student says / does Quick cure
"Which variable goes on which axis?" The explanatory x predicts; the response y responds. Ask: which one would you know first / use to predict? Then =SLOPE(y, x) — y-range first in the function, even though x comes first in your head.
Interprets slope without units or "on average." Require the four-part sentence: per one unit of x, predicted, on average, in y's units. "−1.8" is not an interpretation; "each extra °C predicts 1.8 kWh less, on average" is.
"r² = 0.81 means predictions are 81% accurate." r² is the share of variation explained, not an accuracy rate. The residuals are the actual misses — some are big even when r² is high.
Predicts far outside the data when the fit is strong. The −15 kWh example: a strong fit on 2–18 °C says nothing about 35 °C, where the pattern reverses. Outside the data, the line is fiction — strong r² doesn't extend the warranty.
"t was small, so there's no relationship." Fail to reject ≠ accept (Week 13's law). Small t = the data couldn't rule out a flat line — often a sample-size problem, not proof of β = 0. Point at the CI: (−0.08, 5.08) allows big positive slopes too.
Uses df = n − 1 for the slope test. A fitted line spends two df (slope + intercept): df = n − 2. One-sample t (Weeks 11/14) is n − 1. The table is the same; the row changes.
"The slope is significant, so x causes y." Significance says the tilt isn't luck — not who's pushing whom. Still a handshake; causation needs random assignment (Week 1's law, unrepealed).
Freezes on "which procedure?" questions. One question first: what shape is the answer — a mean, a proportion, counts in categories, or a line? Then count the groups. The decision-map slide resolves every scenario in the course.

Scope flag

This outline stays within Objective 8 plus assigned synthesis review. Deliberate scope choices: the slope is computed from summary statistics via b = r·(s_y ⁄ s_x) — never from raw Σ formulas; SE(b) is always technology-supplied (interpret-the-output depth, per the spine); tests are two-sided; p-values off the embedded table rows are supplied, not computed. The salary example's "significance so close to 0.05" discussion is added nuance worth the two minutes; cut the "course in one breath" story only if desperate for time — it's the last lecture's soul.