Skip to main content

A chicken

Building and checking models
Method or technique
Intermediate
An egg’s way of making another egg. (Model checking and workflow.)
Published

November 9, 2026

Modified

November 13, 2026

Entry #118 in Andrew Gelman’s Handy Statistical Lexicon. Original discussion: Bill James does model checking.

Filed under Building and checking models · Method or technique · Intermediate.

Related terms: posterior predictive check, model checking, Bill James.

Source check: ✓ The explanation was checked against the source.

What it is

The entry adapts Samuel Butler’s quip that a hen is only an egg’s way of making another egg. Gelman’s post quotes the baseball writer Bill James on Total Baseball, Pete Palmer’s statistical encyclopedia, which rated the second baseman Glenn Hubbard above Pete Rose, Brooks Robinson and Sandy Koufax, “a conclusion which is every bit as preposterous as it seems to be at first blush.” James traced the error to “the failure to adjust Hubbard’s fielding statistics for the ground-ball tendency of his pitching staff.” Hubbard’s teams gave up unusually many ground balls, so he had many chances to make plays, and the model credited him with skill he didn’t have.

Gelman’s reaction: “Posterior checking!” Then the analogy: “A chicken is an egg’s way of making another egg. To make the analogy explicit: the ‘egg’ is the model and data, and the chicken is the inferences from the model. The chicken is implicit in the egg, but it needs some growing. The inferences are implicit in the model and the data, but it takes some computing.”

Why it matters

A model that produces many inferences can be checked against them. Total Baseball “included so much data and made so many inferences that people such as James could come in and see which of these statements made no sense—and what this revealed about the problems with Palmer’s model.” Gelman links this to Lakatos: “once you have the external counterexample—an implication that doesn’t make sense—you go find the internal flaw,” often an assumption so implicit “that you didn’t even realize it was an assumption at all.” The alternative is to take the model’s output and use it, with no way of noticing when it has gone wrong.

How it works

  1. Fit the model to the data. This is the egg.
  2. Compute its inferences, as many as you can: rankings, predictions, comparisons. This is the chicken.
  3. Look for inferences that make no sense, given what you know. Gelman notes that James’s is a posterior check, “because his criticism of the Total Baseball model comes from the absurdity of one of its inferences, conditional on the data.”
  4. Follow the absurd inference back to the assumption that produced it, fix the model, and repeat.

Simulated example

A toy version of James’s check, our own. Sixty second basemen play for 30 teams. Each team’s pitchers give up more or fewer ground balls, and a fielder’s assists depend on both his skill and how many ground balls come his way. One model rates fielders by raw assists, as Total Baseball effectively did. The other adjusts for the team’s ground-ball tendency. Skill is unrelated to team, so a sensible rating shouldn’t depend on it either. The check is whether the ratings imply that the best fielders all happen to play for ground-ball teams.

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, mean, sd, lm, cor, fmt} from "../js/stats.js"

viewof model = Inputs.radio(["Raw assists", "Adjusted for team ground balls"], {value: "Raw assists", label: "Model"})
viewof gbEffect = Inputs.range([0, 1], {value: 0.8, step: 0.05, label: "How much team ground balls drive assists"})
viewof seed = Inputs.range([1, 500], {value: 118, step: 1, label: "Random seed"})

fielders = {
  const r = rng(seed);
  const teams = range(30).map(() => r.normal(0, 1));          // ground-ball tendency (z-score)
  const players = range(60).map(i => {
    const gb = teams[Math.floor(i / 2)], skill = r.normal(0, 1);
    return {gb, skill, assists: 300 + 15 * skill + 40 * gbEffect * gb + r.normal(0, 10)};
  });
  const fit = lm(players.map(d => d.gb), players.map(d => d.assists));
  const raw = players.map(d => d.assists);
  const adj = players.map(d => d.assists - fit.predict(d.gb));
  const score = model === "Raw assists" ? raw : adj;
  const z = score.map(v => (v - mean(score)) / sd(score));
  const rated = players.map((d, i) => ({...d, rating: z[i]}));
  const cut = rated.map(d => d.gb).sort((a, b) => b - a)[19];  // top third of players by team ground balls
  const top10 = rated.slice().sort((a, b) => b.rating - a.rating).slice(0, 10);
  return {
    rated,
    top10GB: top10.filter(d => d.gb >= cut).length,
    corGB: cor(rated.map(d => d.rating), rated.map(d => d.gb)),
    corSkill: cor(rated.map(d => d.rating), rated.map(d => d.skill))
  };
}

Plot.plot({
  ariaLabel: "A chicken: simulation chart",
  ariaDescription: "Horizontal axis: the team's ground-ball tendency. Vertical axis: the fielder's rating under the chosen model. The chart updates with the controls above it, and the summary below the charts states the result in words.",
  height: 300,
  x: {label: "Team ground-ball tendency (sd units)", grid: true},
  y: {label: "Fielder rating (sd units)", grid: true},
  marks: [
    Plot.dot(fielders.rated, {x: "gb", y: "rating", fill: "#2166ac", fillOpacity: 0.7, r: 4}),
    Plot.linearRegressionY(fielders.rated, {x: "gb", y: "rating", stroke: "#d6604d"}),
    Plot.ruleY([0])
  ]
})
# A chicken: Bill James's check of a fielding rating, in miniature.
1adjust <- FALSE # FALSE: rate by raw assists; TRUE: adjust for team
gb_effect <- 0.8 # how much team ground balls drive assists
2set.seed(118)

gb <- rep(rnorm(30), each = 2) # team ground-ball tendency, 2 per team
skill <- rnorm(60) # fielders' true skill
3assists <- 300 + 15 * skill + 40 * gb_effect * gb + rnorm(60, 0, 10)
4score <- if (adjust) resid(lm(assists ~ gb)) else assists
rating <- as.vector(scale(score))

5top10 <- order(rating, decreasing = TRUE)[1:10]
cut <- sort(gb, decreasing = TRUE)[20] # top third of fielders by team
cat("Top-10 fielders on ground-ball teams:", sum(gb[top10] >= cut), "of 10\n")
cat("Correlation with team ground balls:", round(cor(rating, gb), 2), "\n")
cat("Correlation with true skill:", round(cor(rating, skill), 2), "\n")

6plot(gb, rating,
  pch = 19, col = "#2166ac",
  xlab = "Team ground-ball tendency (sd units)",
  ylab = "Fielder rating (sd units)"
)
abline(lm(rating ~ gb), col = "#d6604d", lwd = 2)
abline(h = 0)
1
The page’s controls: whether to adjust for the team’s ground balls, and how much those ground balls drive assists.
2
Fixes the random numbers so the run is reproducible.
3
A fielder’s assists depend on his skill and on how many ground balls his pitchers give up: the chance factor Total Baseball ignored.
4
The two models. Raw assists, as Total Baseball did, or assists after regressing out the team’s ground-ball tendency.
5
The posterior check: do the ten top-rated fielders all happen to play for ground-ball teams? Skill is unrelated to team, so they shouldn’t.
6
Each fielder’s rating against his team’s ground-ball tendency. A sloping line is the absurd inference Bill James noticed.
# A chicken: Bill James's check of a fielding rating, in miniature.
import numpy as np
import matplotlib.pyplot as plt

adjust = False   # False: rate by raw assists; True: adjust for team
gb_effect = 0.8  # how much team ground balls drive assists
rng = np.random.default_rng(118)

gb = np.repeat(rng.normal(size=30), 2)  # team tendency, 2 fielders per team
skill = rng.normal(size=60)             # fielders' true skill
assists = 300 + 15 * skill + 40 * gb_effect * gb + rng.normal(0, 10, 60)
if adjust:
    slope, intercept = np.polyfit(gb, assists, 1)
    score = assists - (intercept + slope * gb)
else:
    score = assists
rating = (score - score.mean()) / score.std(ddof=1)

top10 = np.argsort(-rating)[:10]
cut = np.sort(gb)[::-1][19]  # top third of fielders by team
print(f"Top-10 fielders on ground-ball teams: {(gb[top10] >= cut).sum()}"
      " of 10")
print(f"Correlation with team ground balls: "
      f"{np.corrcoef(rating, gb)[0, 1]:.2f}")
print(f"Correlation with true skill: {np.corrcoef(rating, skill)[0, 1]:.2f}")

slope, intercept = np.polyfit(gb, rating, 1)
xs = np.linspace(gb.min(), gb.max(), 2)
plt.scatter(gb, rating, color="#2166ac")
plt.plot(xs, intercept + slope * xs, color="#d6604d", linewidth=2)
plt.axhline(0, color="black", linewidth=0.8)
plt.xlabel("Team ground-ball tendency (sd units)")
plt.ylabel("Fielder rating (sd units)")
plt.show()

Key takeaways

  • The model and data are the egg. The inferences are the chicken, and it takes computing to grow them.
  • Look at the inferences, especially the surprising ones. An implication that makes no sense is evidence of a flaw in the model.
  • Follow the absurd inference back to the assumption that produced it, often one you hadn’t noticed you were making.

Source

Back to top