After a least-squares fit, two different questions can be asked at a new covariate value x*. Where is the regression line, θ = β0 + β1x*? And where will a new response Y* = θ + ε fall? The first interval, Ŷ* ± z s, shrinks as the sample grows; the second, Ŷ* ± z ξn with ξn2 = s2 + σ̂2 (13.16), never gets narrower than the noise. Panel (a) draws both bands; panel (b) shows how often each one catches a new response, from the Normal approximation of Exercise 13.10 (curves) and from a seeded simulation at the chosen x* (dots).
Fit: least squares (13.5)–(13.6) with σ̂2 = RSS/(n − 2) (13.7). At x*, s2 = σ̂2{1/n + (x* − x̄)2/Σ(xi − x̄)2} is the estimated variance of the fitted line and ξn2 = s2 + σ̂2. Simulation: the design is kept, the fitted line and σ̂ are taken as the truth with Normal errors, and each data set gets one new response at x*. The election data leave out Palm Beach, as the book does.
code/ch13_regression.py (simple_fit, predict, naive_coverage, pred_coverage_sim; Figure 13.S1).