Taking a Model Too Seriously
Building and checking models
Principle or heuristic
Intermediate
Really just another way of not taking it seriously at all.
What it is
Gelman’s example: in a paper with Aaron Edlin and Nate Silver on the probability that a single vote decides a presidential election, a normal-distribution model gave probabilities such as 5e-85 for a voter in Washington, D.C. “Sure, the probability that a vote in D.C. would be decisive was low, but 10^-85? No way.” Switching to a t distribution with 4 degrees of freedom gave about 2e-12, “not perfect, I’m sure, but more plausible. Just remember: don’t be a slave to your model. Work with it.” His explanation of the line: “if you say you really believe a probability such as 10^-85, what you’re really doing is devaluing the concept of belief in probabilities, and I’m thinking that will leak back and corrupt all the other probabilistic statements you make.”
More generally, taking a model seriously means working out its implications and checking them against data, including implications you didn’t build it for. Taking it too seriously means treating it as literally true: extrapolating it anywhere and believing its outputs without checking. The paradox is that the second attitude ends up ignoring the model’s content. If you really believed the model, you would want to see whether its predictions hold.
Why it matters
Models are tools with limited domains. A linear trend fitted to ten years of data, taken literally, predicts absurd values decades ahead. A model that assumes independence gives absurdly narrow intervals when the data are clustered. People who “trust the model” in this way often skip predictive checks entirely, and that is how they avoid learning what the model gets wrong. Gelman’s approach is the opposite: take the model seriously enough to falsify it.
How it works
- Too seriously: fit \(y = a + b x\) on \(x \in [0, 5]\), report \(\hat y(15)\) with its narrow model-based interval, and don’t look further.
- Seriously: the model implies the residuals should be structureless and future data should look like posterior predictive draws. Check those implications. Curvature in the residuals means the model’s own logic says not to extrapolate.
Simulated example
The simulation is our own illustration of a related failure: trusting a model’s predictions far outside the range where it was checked. The truth curves gently, but data are observed only on \(x \in [0, 5]\), where a straight line fits well. Extrapolate the straight line to larger \(x\) and compare with what actually happens. The residual plot is the model check that taking the model seriously demands.
Show simulation code
The R version uses base R, and the Python version uses NumPy and Matplotlib. Where the simulation draws random numbers, each language draws its own, so exact numbers differ slightly but show the same pattern. The numbered markers in the R code are explained under it.
import {rng, range, lm, fmt} from "../js/stats.js"
viewof curve = Inputs.range([0, 0.3], {value: 0.12, step: 0.01, label: "Curvature in the truth"})
viewof xFar = Inputs.range([5, 20], {value: 15, step: 1, label: "Extrapolate to x ="})
viewof seed = Inputs.range([1, 500], {value: 26, step: 1, label: "Random seed"})
mdl = {
const r = rng(seed);
const truth = x => 1 + 0.8 * x - curve * x * x;
const data = range(60).map(() => { const x = r.uniform(0, 5); return {x, y: truth(x) + r.normal(0, 0.6)}; });
const f = lm(data.map(d => d.x), data.map(d => d.y));
const grid = range(81).map(i => i * xFar / 80).map(x => ({x, truth: truth(x), fit: f.predict(x)}));
const resid = data.map(d => ({x: d.x, resid: d.y - f.predict(d.x)}));
return {data, f, grid, resid, truthFar: truth(xFar), fitFar: f.predict(xFar),
seFar: f.sigma * Math.sqrt(1 / 60 + (xFar - 2.5) ** 2 / (60 * 25 / 12))};
}
Plot.plot({
ariaLabel: "Taking a Model Too Seriously: chart 1 of 2",
ariaDescription: "Horizontal axis: x. Vertical axis: y. The chart updates with the controls above it, and the summary below the charts states the result in words.",
height: 300,
x: {label: "x", grid: true},
marks: [
Plot.rect([0], {x1: 0, x2: 5, y1: -60, y2: 30, fill: "#2166ac", fillOpacity: 0.05}),
Plot.dot(mdl.data, {x: "x", y: "y", r: 2, fill: "#2166ac"}),
Plot.line(mdl.grid, {x: "x", y: "fit", stroke: "#d6604d", strokeWidth: 2, strokeDasharray: "6 3"}),
Plot.line(mdl.grid, {x: "x", y: "truth", stroke: "currentColor"})
],
y: {domain: [Math.min(-2, mdl.truthFar - 1), Math.max(6, mdl.fitFar + 1)], grid: true, label: "y"}
})
Plot.plot({
ariaLabel: "Taking a Model Too Seriously: chart 2 of 2",
ariaDescription: "Horizontal axis: x (observed range). Vertical axis: Residual. The chart updates with the controls above it, and the summary below the charts states the result in words.",
height: 160,
x: {label: "x (observed range)", grid: true},
y: {label: "Residual", grid: true},
marks: [Plot.dot(mdl.resid, {x: "x", y: "resid", r: 2}), Plot.ruleY([0])]
})# Taking a Model Too Seriously: a straight line, extrapolated far away.
1curve <- 0.12 # curvature in the truth
x_far <- 15 # extrapolate to this x
2set.seed(26)
truth <- function(x) 1 + 0.8 * x - curve * x^2
3x <- runif(60, 0, 5)
y <- truth(x) + rnorm(60, 0, 0.6)
fit <- lm(y ~ x)
4pred <- predict(fit, data.frame(x = x_far), se.fit = TRUE)
cat("The line predicts y(", x_far, ") = ", round(pred$fit, 1), " +/- ",
round(1.96 * pred$se.fit, 1), "; the truth is ",
round(truth(x_far), 1), "\n",
sep = ""
)
par(mfrow = c(1, 2))
plot(x, y,
pch = 19, xlim = c(0, x_far),
ylim = range(y, truth(x_far), pred$fit), xlab = "x", ylab = "y"
)
abline(fit, col = "#2166ac", lwd = 2)
curve(truth, 0, x_far, add = TRUE, lty = 2, col = "#d6604d", lwd = 2)
5plot(x, resid(fit), pch = 19, xlab = "x", ylab = "Residual")
abline(h = 0, lty = 2)- 1
- The page’s controls: how much the truth curves, and how far out to extrapolate.
- 2
- Fixes the random numbers so the run is reproducible.
- 3
- Data observed only between 0 and 5, where a straight line fits well.
- 4
- The line’s prediction far outside the data, with the narrow interval the model believes in.
- 5
- The residual plot: the check that taking the model seriously demands. Its curvature says not to extrapolate.
# Taking a Model Too Seriously: a straight line, extrapolated far away.
import numpy as np
import matplotlib.pyplot as plt
curve = 0.12 # curvature in the truth
x_far = 15 # extrapolate to this x
rng = np.random.default_rng(26)
def truth(v):
return 1 + 0.8 * v - curve * v ** 2
x = rng.uniform(0, 5, 60)
y = truth(x) + rng.normal(0, 0.6, 60)
b, a = np.polyfit(x, y, 1)
resid = y - (a + b * x)
sigma = np.sqrt(resid @ resid / 58)
se_far = sigma * np.sqrt(1 / 60 + (x_far - x.mean()) ** 2
/ np.sum((x - x.mean()) ** 2))
print(f"The line predicts y({x_far}) = {a + b * x_far:.1f} +/- "
f"{1.96 * se_far:.1f}; the truth is {truth(x_far):.1f}")
fig, ax = plt.subplots(1, 2, figsize=(9, 4))
xs = np.linspace(0, x_far, 100)
ax[0].scatter(x, y, s=10, color="black")
ax[0].plot(xs, a + b * xs, color="#2166ac", linewidth=2)
ax[0].plot(xs, truth(xs), "--", color="#d6604d", linewidth=2)
ax[1].scatter(x, resid, s=10, color="black")
ax[1].axhline(0, color="black", linestyle="--")
ax[1].set_ylabel("Residual")
plt.show()Key takeaways
- Believing a model literally is a way of not engaging with it.
- Taking a model seriously means deriving its implications and checking them against data.
- A model’s stated uncertainty assumes the model is true. That assumption is what you need to check.
Source
- Andrew Gelman, Just one of these little things (2009).