Skip to main content

The Garden of Forking Paths

Noise and evidence
Principle or heuristic
Intermediate
Multiple comparisons can be a problem, even when there is no “fishing expedition” or “p-hacking” and the research hypothesis was posited ahead of time.
Published

November 9, 2026

Modified

November 13, 2026

Entry #44 in Andrew Gelman’s Handy Statistical Lexicon. Original discussion: The garden of forking paths (PDF).

Filed under Noise and evidence · Principle or heuristic · Intermediate.

Related terms: p-hacking, researcher degrees of freedom, data-dependent analysis, multiverse analysis.

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

What it is

The name comes from a Borges story. A researcher can run only one analysis, honestly and with a hypothesis stated in advance, and still have a multiple-comparisons problem. The reason is that the details of that analysis depend on the data. Which outcome measure, which subgroup, which exclusions and which covariates are all decided after seeing the data, often in good faith. Had the data come out differently, a different but equally reasonable analysis would have been run. The p-value assumes a single fixed analysis, so it is wrong.

Why it matters

Gelman and Loken’s point is that p-hacking doesn’t require deliberate fishing. Researchers who never “tried many things” still walk a path whose branches were chosen by the data. This explains why so many results from honest researchers fail to replicate. The issue is not bad intent. It is that the nominal 5% false-positive rate assumes a garden with one path.

How it works

If a researcher ran all \(k\) reasonable analyses and reported the best one, that would be fishing. For \(k\) independent paths under the null, the chance that at least one gives \(p < 0.05\) is

\[ \Pr(\min_j p_j < 0.05) = 1 - (0.95)^k, \]

and less when the paths are correlated. Gelman and Loken’s point is different. A researcher who computes only one p-value can still be partway along that road, because the choice of which analysis to run responds to the data: the outcome that shows the clearer pattern, the subgroup where the effect seems to be, the outliers that seem to be hiding it. Each choice is made by looking at the data, not at p-values, and each pushes the single reported test toward significance. The false-positive rate ends up between the nominal 5% and the fishing rate, depending on how closely the choices follow the noise.

Simulated example

Under a true null (the treatment does nothing), a study has two outcome measures, participants of both sexes, and the usual scattering of outliers. Three researchers analyze each of 1,000 such studies, and each reports a single test. The preregistered researcher always tests the first outcome on everyone. The forking-paths researcher makes three reasonable-looking choices after looking at plots of the data, and never computes a p-value for an alternative: use the outcome whose treatment–control difference looks larger; if the difference in one sex is more than twice that in the other, report that sex; and drop outliers (beyond 2.5 sd) if the difference looks larger without them. The fishing researcher tests every combination and reports the smallest p-value. Toggle the forks to see the effect of each.

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, variance, pValue, pct, debounce} from "../js/stats.js"

viewof forks = debounce(Inputs.checkbox(["Two outcome measures", "Optional outlier exclusion", "Subgroup by sex"], {value: ["Two outcome measures", "Optional outlier exclusion", "Subgroup by sex"], label: "Forks in the garden"}))
viewof n = debounce(Inputs.range([20, 400], {value: 100, step: 10, label: "Participants per arm"}))
viewof seed = debounce(Inputs.range([1, 500], {value: 44, step: 1, label: "Random seed"}))

garden = {
  const r = rng(seed);
  const useOutcome2 = forks.includes("Two outcome measures");
  const useTrim = forks.includes("Optional outlier exclusion");
  const useSex = forks.includes("Subgroup by sex");
  const diff = (t, c) => mean(t) - mean(c);
  const test = (t, c) => pValue(diff(t, c), Math.sqrt(variance(t) / t.length + variance(c) / c.length));
  const trim = a => { const m = mean(a), s = Math.sqrt(variance(a)); return a.filter(v => Math.abs(v - m) < 2.5 * s); };
  const pick = (D, grp, outcome) => D.filter(d => grp === "all" || d.sex === grp).map(d => d[outcome]);
  const reps = 1000;
  let pre = 0, forked = 0, fished = 0, paths = 0;
  for (let k = 0; k < reps; k++) {
    // Outcomes with heavy-ish tails, so that outliers occur; the true effect is zero.
    const mk = () => range(n).map(() => { const y1 = r.t(5), y2 = 0.5 * y1 + Math.sqrt(0.75) * r.t(5); return {y1, y2, sex: r.bernoulli(0.5)}; });
    const T = mk(), C = mk();
    // 1. Preregistered: one fixed analysis.
    if (test(pick(T, "all", "y1"), pick(C, "all", "y1")) < 0.05) pre++;
    // 2. Forking paths: one analysis, chosen by looking at the data (no p-values).
    let outcome = "y1";
    if (useOutcome2 && Math.abs(diff(pick(T, "all", "y2"), pick(C, "all", "y2"))) > Math.abs(diff(pick(T, "all", "y1"), pick(C, "all", "y1")))) outcome = "y2";
    let grp = "all";
    if (useSex) {
      const d0 = Math.abs(diff(pick(T, 0, outcome), pick(C, 0, outcome))), d1 = Math.abs(diff(pick(T, 1, outcome), pick(C, 1, outcome)));
      if (d1 > 2 * d0) grp = 1; else if (d0 > 2 * d1) grp = 0;
    }
    let t = pick(T, grp, outcome), c = pick(C, grp, outcome);
    if (useTrim && Math.abs(diff(trim(t), trim(c))) > Math.abs(diff(t, c))) { t = trim(t); c = trim(c); }
    if (test(t, c) < 0.05) forked++;
    // 3. Fishing: every path tested, the smallest p-value reported.
    const ps = [];
    for (const o of useOutcome2 ? ["y1", "y2"] : ["y1"])
      for (const tr of useTrim ? [false, true] : [false])
        for (const g of useSex ? ["all", 0, 1] : ["all"]) {
          let a = pick(T, g, o), b = pick(C, g, o);
          if (tr) { a = trim(a); b = trim(b); }
          ps.push(test(a, b));
        }
    paths = ps.length;
    if (Math.min(...ps) < 0.05) fished++;
  }
  return {pre: pre / reps, forked: forked / reps, fished: fished / reps, paths};
}

Plot.plot({
  ariaLabel: "The Garden of Forking Paths: simulation chart",
  ariaDescription: "Horizontal axis: false-positive rate when the true effect is zero. Three bars: a preregistered analysis, a single analysis chosen by looking at the data, and fishing through every path. The chart updates with the controls above it, and the summary below the charts states the result in words.",
  height: 160,
  marginLeft: 230,
  x: {label: "False-positive rate (true effect is zero)", domain: [0, 0.5], tickFormat: "%", grid: true},
  y: {label: null},
  marks: [
    Plot.barX([
      {k: "Preregistered (one fixed test)", v: garden.pre},
      {k: "Forking paths (one test, data-chosen)", v: garden.forked},
      {k: `Fishing (best of ${garden.paths} tests)`, v: garden.fished}
    ], {y: "k", x: "v", fill: (d, i) => ["#8a8a8a", "#d6604d", "#67001f"][i]}),
    Plot.ruleX([0.05], {stroke: "currentColor", strokeDasharray: "4 3"})
  ]
})
# The Garden of Forking Paths: one test, chosen by looking at the data.
1n <- 100 # participants per arm
2set.seed(44)

p_value <- function(a, b) { # two-sample test (normal approximation)
  z <- (mean(a) - mean(b)) / sqrt(var(a) / length(a) + var(b) / length(b))
  2 * pnorm(-abs(z))
}
trim <- function(a) a[abs(a - mean(a)) < 2.5 * sd(a)]
diff <- function(a, b) abs(mean(a) - mean(b))
3make <- function() { # heavy-ish tails, so outliers occur; no true effect
  y1 <- rt(n, 5)
  data.frame(y1,
    y2 = 0.5 * y1 + sqrt(0.75) * rt(n, 5),
    sex = rbinom(n, 1, 0.5)
  )
}
pick <- function(D, grp, out) D[[out]][grp == "all" | D$sex == grp]

res <- t(replicate(1000, {
  trt <- make()
  ctl <- make()
  # 1. Preregistered: always the same test
4  pre <- p_value(trt$y1, ctl$y1) < 0.05
  # 2. Forking paths: three choices made by looking at the data
5  out <- if (diff(trt$y2, ctl$y2) > diff(trt$y1, ctl$y1)) "y2" else "y1"
  d0 <- diff(pick(trt, 0, out), pick(ctl, 0, out))
  d1 <- diff(pick(trt, 1, out), pick(ctl, 1, out))
  grp <- if (d1 > 2 * d0) 1 else if (d0 > 2 * d1) 0 else "all"
  a <- pick(trt, grp, out)
  b <- pick(ctl, grp, out)
  if (diff(trim(a), trim(b)) > diff(a, b)) {
    a <- trim(a)
    b <- trim(b)
  }
6  forked <- p_value(a, b) < 0.05
  # 3. Fishing: test all 12 paths and report the smallest p-value
7  ps <- c()
  for (o in c("y1", "y2")) {
    for (tr in c(FALSE, TRUE)) {
      for (g in c("all", 0, 1)) {
        a <- pick(trt, g, o)
        b <- pick(ctl, g, o)
        if (tr) {
          a <- trim(a)
          b <- trim(b)
        }
        ps <- c(ps, p_value(a, b))
      }
    }
  }
  c(preregistered = pre, forking_paths = forked, fishing = min(ps) < 0.05)
}))
rates <- colMeans(res)
print(round(100 * rates, 1)) # false-positive rates (%), true effect zero

8barplot(rates,
  col = c("grey60", "#d6604d", "#67001f"), ylim = c(0, 0.5),
  ylab = "False-positive rate (true effect is zero)"
)
abline(h = 0.05, lty = 2)
1
The page’s control: participants per arm.
2
Fixes the random numbers so the run is reproducible.
3
One arm of one study: two outcomes, a sex variable and heavy-ish tails so outliers occur. The true effect is zero.
4
The preregistered researcher always runs the same test.
5
The forking-paths researcher looks at the data, not at p-values, and chooses the outcome with the larger difference, then a subgroup, then whether to drop outliers.
6
That researcher computes exactly one p-value.
7
The fishing researcher runs all twelve paths and reports the best.
8
False-positive rates. One data-chosen test lands between the nominal rate and fishing: no fishing was needed, only forks.
# The Garden of Forking Paths: one test, chosen by looking at the data.
from statistics import NormalDist
import numpy as np
import matplotlib.pyplot as plt

n = 100  # participants per arm
rng = np.random.default_rng(44)
N = NormalDist()


def p_value(a, b):
    """Two-sample test (normal approximation)."""
    se = np.sqrt(a.var(ddof=1) / len(a) + b.var(ddof=1) / len(b))
    return 2 * N.cdf(-abs(a.mean() - b.mean()) / se)


def trim(a):
    return a[np.abs(a - a.mean()) < 2.5 * a.std(ddof=1)]


def diff(a, b):
    return abs(a.mean() - b.mean())


def make():
    """Heavy-ish tails, so outliers occur; the true effect is zero."""
    y1 = rng.standard_t(5, n)
    y2 = 0.5 * y1 + np.sqrt(0.75) * rng.standard_t(5, n)
    return {"y1": y1, "y2": y2, "sex": rng.binomial(1, 0.5, n)}


def pick(D, grp, out):
    return D[out] if grp == "all" else D[out][D["sex"] == grp]


pre = forked = fished = 0
for _ in range(1000):
    T, C = make(), make()
    # 1. Preregistered: always the same test
    pre += p_value(T["y1"], C["y1"]) < 0.05
    # 2. Forking paths: three choices made by looking at the data
    out = "y2" if diff(T["y2"], C["y2"]) > diff(T["y1"], C["y1"]) else "y1"
    d0 = diff(pick(T, 0, out), pick(C, 0, out))
    d1 = diff(pick(T, 1, out), pick(C, 1, out))
    grp = 1 if d1 > 2 * d0 else 0 if d0 > 2 * d1 else "all"
    a, b = pick(T, grp, out), pick(C, grp, out)
    if diff(trim(a), trim(b)) > diff(a, b):
        a, b = trim(a), trim(b)
    forked += p_value(a, b) < 0.05
    # 3. Fishing: test all 12 paths and report the smallest p-value
    ps = []
    for o in ("y1", "y2"):
        for tr in (False, True):
            for g in ("all", 0, 1):
                a, b = pick(T, g, o), pick(C, g, o)
                if tr:
                    a, b = trim(a), trim(b)
                ps.append(p_value(a, b))
    fished += min(ps) < 0.05

rates = {"Preregistered": pre / 1000, "Forking paths": forked / 1000,
         "Fishing (best of 12)": fished / 1000}
for k, v in rates.items():
    print(f"{k}: {100 * v:.1f}% false positives (true effect zero)")

plt.bar(list(rates), list(rates.values()),
        color=["0.6", "#d6604d", "#67001f"])
plt.axhline(0.05, color="black", linestyle="--")
plt.ylim(0, 0.5)
plt.ylabel("False-positive rate (true effect is zero)")
plt.show()

Key takeaways

  • Data-dependent analysis choices inflate false-positive rates even without deliberate p-hacking.
  • A pre-stated hypothesis does not remove the forks. Pre-specifying the analysis does, as far as it goes.
  • Better still: analyze all reasonable paths together, for example with a multilevel model, rather than choosing one.

Source

Back to top