Breadcrumbs
Building and checking models
Advice
Introductory
I need that trail.
What it is
When a paper reports a final estimate, such as a regression coefficient from a complex model with many controls, Gelman wants to see the trail leading to it. That means the raw data, the simple comparisons, the intermediate steps and how each modeling choice moved the estimate. Without the breadcrumbs, a reader can’t tell whether the result comes from the data or from a particular path through the analysis.
Why it matters
Complex analyses involve dozens of decisions: sample restrictions, variable codings, controls, functional forms. A final number with no trail gives the reader nothing to check, even when the code is available. Showing the steps from raw comparison to final model makes the analysis understandable and lets readers see where the result is robust and where it hangs on one choice.
How it works
A toy model of reproducibility. An analysis has \(k\) decision points. A documented decision is followed exactly. An undocumented one is guessed by a re-analyst from several reasonable options, each of which shifts the estimate somewhat. The spread of re-analysts’ results grows with the number of missing breadcrumbs. Even honest re-analysis can’t recover the original number, and nobody can tell which step matters.
Simulated example
An analysis has 10 decision points, each with a few reasonable options. Choose how many steps are documented and see how widely independent re-analyses scatter around the published estimate.
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, sd, sum, fmt} from "../js/stats.js"
viewof documented = Inputs.range([0, 10], {value: 3, step: 1, label: "Decision points documented (of 10)"})
viewof seed = Inputs.range([1, 500], {value: 78, step: 1, label: "Random seed"})
trail = {
const r = rng(seed);
const shifts = range(10).map(() => r.normals(4, 0, 0.08)); // each decision's options shift the estimate
const chosen = range(10).map(() => r.int(0, 3)); // what the original authors did
const published = 0.25 + sum(range(10).map(j => shifts[j][chosen[j]]));
const reanalyses = range(300).map(() => 0.25 + sum(range(10).map(j => j < documented ? shifts[j][chosen[j]] : shifts[j][r.int(0, 3)])));
return {published, reanalyses};
}
Plot.plot({
ariaLabel: "Breadcrumbs: simulation chart",
ariaDescription: "Horizontal axis: Estimate obtained by independent re-analysts. Vertical axis: Re-analyses. The chart updates with the controls above it, and the summary below the charts states the result in words.",
height: 260,
x: {label: "Estimate obtained by independent re-analysts", grid: true},
y: {label: "Re-analyses"},
marks: [
Plot.rectY(trail.reanalyses, Plot.binX({y: "count"}, {x: d => d, fill: "#2166ac", thresholds: 30})),
Plot.ruleX([trail.published], {stroke: "#d6604d", strokeWidth: 3}),
Plot.ruleY([0])
]
})# Breadcrumbs: undocumented decisions make results irreproducible.
1documented <- 3 # decision points documented (of 10)
2set.seed(78)
3shifts <- matrix(rnorm(40, 0, 0.08), nrow = 10) # 10 decisions x 4 options
chosen <- sample(4, 10, replace = TRUE) # what the authors did
4published <- 0.25 + sum(shifts[cbind(1:10, chosen)])
reanalyses <- replicate(300, {
pick <- chosen
undocumented <- seq_len(10) > documented
5 pick[undocumented] <- sample(4, sum(undocumented), replace = TRUE)
0.25 + sum(shifts[cbind(1:10, pick)])
})
cat("Published estimate:", round(published, 3), "\n")
cat(
"Spread (sd) of re-analyses with", documented, "of 10 steps documented:",
round(sd(reanalyses), 3), "\n"
)
6hist(reanalyses,
breaks = 30, col = "#2166ac", border = "white", main = "",
xlab = "Re-analysis estimate", ylab = "Re-analyses"
)
abline(v = published, col = "#d6604d", lwd = 3)- 1
- The page’s control: how many of the ten analytic decisions the authors wrote down.
- 2
- Fixes the random numbers so the run is reproducible.
- 3
- Ten decision points with four options each, and how much each option shifts the estimate.
- 4
- The published estimate comes from the options the authors actually chose.
- 5
- A re-analyst follows the documented decisions and guesses the rest.
- 6
- The spread of re-analyses around the published estimate (red). More breadcrumbs, less spread.
# Breadcrumbs: undocumented decisions make results irreproducible.
import numpy as np
import matplotlib.pyplot as plt
documented = 3 # decision points documented (of 10)
rng = np.random.default_rng(78)
shifts = rng.normal(0, 0.08, (10, 4)) # 10 decisions x 4 options
chosen = rng.integers(0, 4, 10) # what the authors did
published = 0.25 + shifts[np.arange(10), chosen].sum()
reanalyses = []
for _ in range(300):
pick = chosen.copy()
pick[documented:] = rng.integers(0, 4, 10 - documented)
reanalyses.append(0.25 + shifts[np.arange(10), pick].sum())
reanalyses = np.array(reanalyses)
print(f"Published estimate: {published:.3f}")
print(f"Spread (sd) of re-analyses with {documented} of 10 steps documented: "
f"{reanalyses.std(ddof=1):.3f}")
plt.hist(reanalyses, bins=30, color="#2166ac")
plt.axvline(published, color="#d6604d", linewidth=3)
plt.xlabel("Re-analysis estimate")
plt.ylabel("Re-analyses")
plt.show()Key takeaways
- Show the path from raw data to the final estimate, not just the endpoint.
- Simple comparisons first, then each modeling step and how it moved the result.
- Code is necessary but not enough. Readers need to see which steps matter.
Source
- Andrew Gelman, I need that trail of breadcrumbs (2019).