Skip to main content

God is in Every Leaf of Every Tree

Building and checking models
Law or aphorism
Introductory
No problem is too small or too trivial if we really do something about it.
Published

November 9, 2026

Modified

November 13, 2026

Entry #27 in Andrew Gelman’s Handy Statistical Lexicon. Original discussion: God is in every leaf of every tree.

Filed under Building and checking models · Law or aphorism · Introductory.

Related terms: missing-value codes, data cleaning.

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

What it is

Gelman starts from a Richard Feynman line quoted by Freeman Dyson: “No problem is too small or too trivial if we really do something about it.” The saying “God is in every leaf of every tree” applies to statistics, he writes, in that “whenever I work on any serious problem in a serious way, I find myself quickly thrust to the boundaries of what existing statistical methods can do.” He gives the example of thinking “a simple logistic regression (or whatever) will do the trick, and before I know it, I realize that nothing off-the-shelf will work.” Even his cleanest project, on serial dilution assays, took about two years to set up correctly. In short: “doing even a simple problem right is just about never simple.”

Why it matters

There is a status hierarchy in which “big” methodological questions outrank “mere” applications. Gelman sees this as good news for researchers: “we can just try to work on interesting problems and the new theory/methods will be motivated as needed.” New methods come out of taking specific problems seriously. On the defensive side, small details such as a missing-data code, a units mismatch or a duplicated row can overturn a conclusion. Paying attention to the leaves is how you avoid publishing nonsense about the tree.

How it works

Gelman’s examples are about modeling: a “simple” regression that turns out to need something new. The simulation below is our own, smaller illustration of the same lesson, that a problem which looks routine rarely is once you take it seriously. Take survey data where “don’t know” or “missing” was coded as 99. It’s a tiny detail, but if it goes unnoticed it contaminates every downstream number. The effect on the mean is roughly

\[ \Delta\bar{y} \approx f\,(99 - \bar{y}_{\text{valid}}), \]

where \(f\) is the fraction miscoded. Even a few percent of rows can move the mean by several units, and in a regression they can flip a slope.

Simulated example

A 1–10 rating scale in which missing answers are coded as 99. Raise the share of missing responses and see what the “trivial” coding detail does to the mean and to a regression slope.

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

viewof missRate = Inputs.range([0, 0.15], {value: 0.04, step: 0.005, label: "Share of responses missing"})
viewof missingRelated = Inputs.toggle({label: "Missingness more common among older respondents", value: true})
viewof seed = Inputs.range([1, 500], {value: 27, step: 1, label: "Random seed"})

leaf = {
  const r = rng(seed);
  return range(1000).map(() => {
    const age = r.uniform(18, 80);
    const rating = Math.min(10, Math.max(1, Math.round(6 - 0.03 * (age - 50) + r.normal(0, 1.8))));
    const pMiss = missingRelated ? missRate * 2 * (age - 18) / 62 : missRate;
    const missing = r() < pMiss;
    return {age, rating, recorded: missing ? 99 : rating, missing};
  });
}
cmp = {
  const valid = leaf.filter(d => !d.missing);
  return {
    meanNaive: mean(leaf.map(d => d.recorded)), meanClean: mean(valid.map(d => d.rating)),
    slopeNaive: lm(leaf.map(d => d.age), leaf.map(d => d.recorded)).b,
    slopeClean: lm(valid.map(d => d.age), valid.map(d => d.rating)).b
  };
}

Plot.plot({
  ariaLabel: "God is in Every Leaf of Every Tree: simulation chart",
  ariaDescription: "Horizontal axis: Age. Vertical axis: Recorded rating. The chart updates with the controls above it, and the summary below the charts states the result in words.",
  height: 280,
  x: {label: "Age", grid: true},
  y: {label: "Recorded rating", type: "symlog", grid: true},
  marks: [Plot.dot(leaf, {x: "age", y: "recorded", r: 1.8, fill: d => d.missing ? "#d6604d" : "#2166ac", fillOpacity: 0.6})]
})
# God is in every leaf of every tree: missing answers coded as 99.
1miss_rate <- 0.04 # share of responses missing
missing_related <- TRUE # missingness more common among older respondents
2set.seed(27)

age <- runif(1000, 18, 80)
rating <- round(6 - 0.03 * (age - 50) + rnorm(1000, 0, 1.8))
rating <- pmin(10, pmax(1, rating)) # a 1-10 scale
3p_miss <- if (missing_related) miss_rate * 2 * (age - 18) / 62 else miss_rate
missing <- runif(1000) < p_miss
4recorded <- ifelse(missing, 99, rating) # the "trivial" coding detail

cat(
  "Mean rating: 99 treated as a number", round(mean(recorded), 2),
  "| missing code dropped", round(mean(rating[!missing]), 2), "\n"
)
cat(
  "Slope on age:", round(coef(lm(recorded ~ age))[2], 3), "vs",
  round(coef(lm(rating[!missing] ~ age[!missing]))[2], 3), "\n"
)

5plot(age, recorded,
  log = "y", pch = 16, cex = 0.6,
  col = ifelse(missing, "#d6604d", "#2166ac"), xlab = "Age",
  ylab = "Recorded rating (log scale)"
)
1
The page’s controls: the share of missing responses, and whether missingness rises with age.
2
Fixes the random numbers so the run is reproducible.
3
Older respondents skip the question more often, so the missing code is not spread evenly.
4
The trivial coding detail: missing answers stored as 99 on a 1 to 10 scale.
5
Recorded ratings against age. The 99s sit far above the scale and, being concentrated among the old, flip the slope on age.
# God is in every leaf of every tree: missing answers coded as 99.
import numpy as np
import matplotlib.pyplot as plt

miss_rate = 0.04        # share of responses missing
missing_related = True  # missingness more common among older respondents
rng = np.random.default_rng(27)

age = rng.uniform(18, 80, 1000)
rating = np.clip(np.round(6 - 0.03 * (age - 50) + rng.normal(0, 1.8, 1000)),
                 1, 10)
p_miss = miss_rate * 2 * (age - 18) / 62 if missing_related else miss_rate
missing = rng.uniform(size=1000) < p_miss
recorded = np.where(missing, 99, rating)  # the "trivial" coding detail

print(f"Mean rating: 99 treated as a number {recorded.mean():.2f} "
      f"| missing code dropped {rating[~missing].mean():.2f}")
print(f"Slope on age: {np.polyfit(age, recorded, 1)[0]:.3f} vs "
      f"{np.polyfit(age[~missing], rating[~missing], 1)[0]:.3f}")

plt.scatter(age, recorded, s=6, c=np.where(missing, "#d6604d", "#2166ac"))
plt.yscale("log")
plt.xlabel("Age")
plt.ylabel("Recorded rating (log scale)")
plt.show()

Key takeaways

  • Small problems deserve full attention. General insights often come from specific puzzles.
  • Data details such as codes, units and duplicates can dominate the substantive result.
  • Look at the raw data. The leaf you skip may be the one that matters.

Source

Back to top