Lawfare Group → Knowledge Institute → Lawfare Academy

← Course syllabus · Related lesson

A fitted mean is not an individual prediction

Current complete on-site edition 6

Required teaching and complete optional models are supplied on LawfareGroup.com. Publisher and primary links are optional provenance or further reading. Florida is the contemporary state-law default; federal rules and explicitly comparative accounting frameworks are distinguished. Independent subject review and observed human learner testing remain pending.

Cumulative regression and forecasting dossier, transfer models and 30-point rubric

Preserved original teaching integrated with complete current on-site preparation. Independent human subject review and observed learner testing remain pending.

Name the uncertainty target

A small workshop relates production time y to batch size x. A regression line can estimate the conditional mean time at a chosen size, but the next individual batch also has unexplained variation. These are different inferential targets. A confidence interval for the mean response narrows uncertainty about a population average; a prediction interval includes both estimation uncertainty and a new residual. Using the former to promise a delivery time confuses precision of a mean with variability of individual work.

For this teaching example, assume independent normally distributed errors with common variance, a correctly specified linear conditional mean and fixed or appropriately conditioned predictor values. Normality is used for the exact small-sample t intervals, not for the algebra of least squares. A curved relation, changing variance, time dependence or measurement error in batch size requires further analysis. Five observations cannot diagnose these possibilities reliably.

Work from sufficient arithmetic

Take x=[1,2,3,4,5] and y=[2,4,5,4,5]. The means are x-bar=3 and y-bar=4. Centered predictor sum of squares Sxx is 10; cross-product sum Sxy is 6. Therefore the fitted slope is 0.6 and intercept is 2.2. The fitted values are [2.8,3.4,4.0,4.6,5.2], leaving residuals [-0.8,0.6,1.0,-0.6,-0.2]. Their sum is zero, while their squared sum is 2.4.

Two estimated coefficients consume two degrees of freedom. The residual variance estimate is s²=2.4/(5-2)=0.8, not 2.4/5. This distinction changes interval widths. The zero sum of fitted residuals follows from the intercept normal equation; it is not evidence that future errors will average to zero or that the linear model is true. Check algebraic properties separately from substantive assumptions.

Separate leverage and irreducible variation

At x0, define h0=1/n+(x0-x-bar)²/Sxx. The standard error for the fitted mean is s sqrt(h0); for a new observation it is s sqrt(1+h0). The extra 1 represents the new observation's residual variation. At x0=3, h0=0.2 and the fitted response is 4. With t0.975,3 about 3.182446, the mean interval is 4 ± 1.27298, whereas the individual prediction interval is 4 ± 3.11815. Both use the same point prediction and residual variance; their different widths answer different questions.

At x0=6, the fitted response is 5.8 and h0=1.1. The mean interval is roughly [2.81460,8.78540], and the individual interval roughly [1.67508,9.92492]. Distance from the observed predictor mean increases parameter uncertainty. But the formula's widening does not protect against an incorrect extrapolated mean function. A process that bends beyond batch size five can invalidate both intervals even if all arithmetic is correct.

A useful report includes the boundary of the model

Report the observed predictor range, the fitted line, the uncertainty target, the sample size and degrees of freedom, the assumptions and any evidence against them. Do not present an individual prediction interval as a universal guarantee. Repeated predictions at many predictor values also introduce a distinction between pointwise coverage and simultaneous coverage. A collection of 95% pointwise intervals is not automatically a 95% band for the whole line.

An operations manager might care about an upper delivery bound rather than a central interval. That calls for a specified one-sided target, a model that respects the process and validation on later batches. A negative lower endpoint for a nonnegative production time signals that the normal additive model may be a poor description; clipping it does not derive a valid new prediction procedure. Compare appropriate transformations or alternative models using training-only choices and genuinely later evaluation. Preserve the simpler benchmark and the timing ledger so an improved fit is not mistaken for improved prospective prediction.

What more observations can and cannot remove

If the residual process remains variable, learning the regression coefficients precisely does not eliminate individual variation. As coefficient uncertainty decreases, the fitted-mean interval can become narrow, while an individual interval still reflects the residual scale. Replicating measurements at one predictor value also does not teach the slope across an unobserved range.

Progressive independent practice

Write your analysis before opening each model. Then change the stated fact and revise the reasoning.

Guided

Calculate SSE, residual degrees of freedom and the two standard errors at x0=3.

Compare the model reasoning

SSE=2.4, df=3, s²=0.8. Mean SE=sqrt(0.8×0.2)=0.4. Individual SE=sqrt(0.8×1.2)=0.979796.

Changed conditions

An analyst divides SSE by five.

Compare the revised analysis

That is not the unbiased residual variance estimate for this two-parameter fit; it understates the stated t-interval scale.

Independent

Recalculate h0 and both intervals at x0=6, then write a delivery-time caveat.

Compare the model reasoning

h0=1.1, fitted value=5.8. Mean interval approximately [2.81460,8.78540]; individual interval approximately [1.67508,9.92492]. Six lies beyond the observed 1–5 range; validity requires an extrapolation assumption the interval arithmetic cannot establish.

Changed conditions

The same x values represent successive days and residuals are serially correlated.

Compare the revised analysis

The independent-error standard errors and t reference are unsupported. Examine temporal structure and use a justified dependence model or design before quoting those coverage claims.

Transfer

A vendor promises every future batch will fall inside a pointwise 95% prediction interval. Assess the statement.

Compare the model reasoning

A pointwise procedure has a repeated-sampling coverage target under its model. It does not guarantee every future batch, simultaneous coverage for many batches or validity after a process shift. Specify the service decision and evaluate later errors.

Changed conditions

The vendor selects the best interval model after inspecting the future test batches.

Compare the revised analysis

That test set has become part of model selection. Preserve a new prospective evaluation or clearly label the retrospective comparison; do not retain the original independent-test claim.

Source readings and scope

NIST: least-squares regression — Least-squares fitting background. Dataset, arithmetic, decision analysis and exercises are original.

Reproduce the worked cases

Download the Python 3 laboratory. Uses only the standard library and synthetic data. Run locally; it does not access accounts, a network service or production records. Assertions check the stated results.