Step 5 of 6 in Statistics & Probability
Regression & Modeling
Fitting models to data and interpreting coefficients. Citation needed
The whole, before the parts
Regression summarizes how one variable moves, on average, as another moves — a line, or a surface, drawn through a cloud of points. The single idea that carries the subject is the residual: the gap between what the model predicts and what the data say. Fitting a model means making the residuals small; trusting a model means checking the residuals are patternless; and almost every abuse of regression is a coefficient read as a cause when the fit only ever earned it the rank of a summary. Citation needed
Terminology and core concepts
-
The regression line
The regression of y on x is the line ŷ = a + bx predicting the average y at each x; its slope is b = r · s₳/sₓ — the correlation coefficient times the ratio of standard deviations — and it always passes through the point of means. Citation needed
- What does ŷ at a given x estimate?
- the average y among points near that x Citation needed
- What is the regression slope in terms of r and the two standard deviations?
- r × (SD of y)/(SD of x) Citation needed
- Which point does every regression line pass through?
- (mean of x, mean of y) Citation needed
- Is the regression of y on x the same line as x on y?
- no Citation needed
-
Least squares
A residual is an observed y minus its prediction ŷ, and the least-squares line is the one minimizing the sum of squared residuals — squared so that misses count by size and the calculus gives a unique answer. Citation needed
- What is a residual?
- observed y minus predicted y Citation needed
- What quantity does least squares minimize?
- the sum of squared residuals Citation needed
- What do the residuals of a least-squares fit sum to?
- zero Citation needed
- Why do outliers pull a least-squares line so hard?
- squaring makes big misses dominate Citation needed
- A point has y = 12 and ŷ = 9; its residual?
- +3 Citation needed
-
Reading the coefficients
The slope says how the predicted average of y differs between points one unit apart in x — a comparison across observed cases, not a promise about what intervening on x would do. Citation needed
- What does a slope of 3 say, carefully?
- cases 1 unit apart in x average 3 apart in y Citation needed
- When is the intercept meaningful?
- when x = 0 lies among the data and makes sense Citation needed
- Does a fitted slope show that changing x changes y?
- no — a confounder can produce the slope Citation needed
- What is extrapolation?
- predicting outside the range of the observed x Citation needed
- Why is extrapolation dangerous?
- the line was never tested out there Citation needed
-
How good is the fit: r²
r², the square of the correlation coefficient, is the fraction of the variance of y that the line accounts for; the rest stays in the residuals — and a high r² certifies neither causation nor that the line is the right shape. Citation needed
- What fraction of y's variance does r = 0.5 explain?
- 25% Citation needed
- Where does the unexplained variance live?
- in the residuals Citation needed
- Can a curved relation give a high r² to a wrong straight line?
- yes Citation needed
- Does r² = 0.9 establish causation?
- no — it measures fit only Citation needed
-
Residual plots as the model's x-ray
Plot residuals against the predictions: a healthy model leaves a patternless horizontal band, a curve betrays a wrong shape, and a fan that widens betrays spread that changes with the prediction. Citation needed
- What does a healthy residual plot look like?
- a patternless horizontal band Citation needed
- What does a U-shape in the residuals mean?
- the true relation is curved, not linear Citation needed
- What does a widening fan of residuals mean?
- spread grows with the prediction Citation needed
- Why plot residuals rather than admire r²?
- patterns invisible in r² show up there Citation needed
-
Regression to the mean
Whenever correlation is imperfect, extreme cases are predicted to be less extreme next time — purely because luck does not repeat — and mistaking this drift for a real effect is the regression fallacy. Citation needed
- Why do the top scorers on a test average lower on a retest?
- part of their score was luck, and luck resets Citation needed
- When does regression to the mean vanish?
- when correlation is perfect Citation needed
- What is the regression fallacy?
- explaining mean-reversion with a causal story Citation needed
- Why do patients recruited at their sickest improve under any treatment?
- extremes revert toward the mean regardless Citation needed
-
Multiple regression and "holding constant"
Multiple regression predicts y from several variables at once; each coefficient compares cases that differ in one variable with the others held fixed — statistically, in the fit, which is far weaker than holding them fixed in the world. Citation needed
- What does a coefficient in multiple regression compare?
- cases differing in that variable, others held fixed Citation needed
- Why can adding a variable flip another's coefficient sign?
- the comparison changes to within-group Citation needed
- Does controlling for a variable in the fit equal controlling it in an experiment?
- no — only measured variables can be adjusted Citation needed
- What is left uncontrolled by any regression adjustment?
- confounders that were never measured Citation needed
-
Overfitting and out-of-sample honesty
A model with enough knobs can fit the noise in its own data perfectly and predict nothing; the honest test of any model is performance on data it never saw, which is why data are split into a fitting set and a held-out test set. Citation needed
- What is overfitting?
- fitting the noise instead of the pattern Citation needed
- What happens to fit on the training data as knobs are added?
- it always improves Citation needed
- What is the honest test of a model?
- prediction on data it never saw Citation needed
- What is a held-out test set?
- data kept away from the fitting Citation needed
- A degree-9 polynomial through 10 points fits perfectly; trust it?
- no — it has memorized the noise Citation needed
Problems that prove it
-
Fit the least-squares line to (1, 2), (2, 3), (3, 5).
Drills: a complete small fit, through the point of means.
Derivation steps
- Means: x̄ = 2, ȳ = 10/3.
- Deviations in x: −1, 0, 1; in y: −4/3, −1/3, 5/3.
- Slope = Σ(dx · dy) / Σ(dx²) = (4/3 + 0 + 5/3)/2 = 3/2.
- Intercept from the point of means: 10/3 − (3/2)(2) = 1/3.
- Line: ŷ = 1/3 + 1.5x. Check residuals: 1/6, −1/3, 1/6 — sum 0. ✓
Citation needed
-
An airline praises pilots after harsh criticism: criticized pilots improved next flight, praised ones got worse. Reconstruct the statistical explanation.
Drills: spotting the regression fallacy in a causal story.
Derivation steps
- Flights are skill plus luck; criticism follows the unluckiest flights, praise the luckiest.
- Luck does not persist, so extremes revert toward each pilot's average.
- Improvement after criticism and decline after praise are exactly what reversion predicts with no effect at all.
- To detect a real effect of feedback, randomize who gets criticized — which breaks the link to luck.
Citation needed
Sources
- David Freedman, Robert Pisani, and Roger Purves, Statistics — the regression and residuals treatment these notes compress.
- Andrew Gelman and Jennifer Hill, Data Analysis Using Regression and Multilevel/Hierarchical Models — what coefficients do and do not mean.
- Daniel Kahneman, Thinking, Fast and Slow — the flight-instructor story and the regression fallacy.
Learning path
Continue through Statistics & Probability in order, using the concepts above to connect this topic to the next.