The Pandora Principle
Causes, samples and populations
Principle or heuristic
Intermediate
Once you’ve considered a possible interaction or bias or confounder, you can’t un-think it.
What it is
Once a possible confounder, interaction or bias has been raised, you can’t honestly pretend you never thought of it. The box is open. You have to deal with it: adjust for it, model it or at least account for the uncertainty it creates. Gelman calls the malign converse the ostrich: avoiding thinking about a problem so you don’t have to address it.
Why it matters
This has an uncomfortable consequence. Careful analysts, who think of more possible problems, end up with wider uncertainty than careless ones who never asked. That can look like a penalty for diligence. But the careless analyst’s narrow interval was never justified. It came from not looking. Once you know a confounder might matter, reporting the unadjusted estimate with its unadjusted interval is ostrich behavior.
How it works
Suppose the treatment effect estimate is \(\hat\tau_A\) without adjusting for a possible confounder \(U\), and \(\hat\tau_B\) with it. Before \(U\) was considered, the analyst reported \(\hat\tau_A \pm 2\,\text{se}_A\). After considering \(U\), an honest summary has to include the uncertainty about which model is right. A simple version is a mixture of the two models’ sampling distributions, whose spread includes \((\hat\tau_A - \hat\tau_B)^2\). That box can’t be closed again.
Simulated example
A covariate \(U\) affects both treatment uptake and the outcome. Compare the ostrich’s report (ignore \(U\)), the adjusted estimate, and an honest interval that reflects uncertainty about whether \(U\) matters.
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, ols, fmt} from "../js/stats.js"
viewof confound = Inputs.range([0, 1.5], {value: 0.6, step: 0.05, label: "Strength of confounding by U"})
viewof pMatters = Inputs.range([0, 1], {value: 0.5, step: 0.05, label: "Your belief that U matters"})
viewof seed = Inputs.range([1, 500], {value: 67, step: 1, label: "Random seed"})
pandora = {
const r = rng(seed);
const rows = range(500).map(() => {
const u = r.normal(), z = r() < 1 / (1 + Math.exp(-confound * 1.5 * u)) ? 1 : 0;
return {u, z, y: 0.3 * z + confound * u + r.normal()};
});
const A = ols(rows.map(d => [d.z]), rows.map(d => d.y)), B = ols(rows.map(d => [d.z, d.u]), rows.map(d => d.y));
const mA = A.coef[1], sA = A.se[1], mB = B.coef[1], sB = B.se[1];
const mix = (1 - pMatters) * mA + pMatters * mB;
const varMix = (1 - pMatters) * (sA ** 2 + mA ** 2) + pMatters * (sB ** 2 + mB ** 2) - mix ** 2;
return [
{who: "Ostrich (never thought of U)", est: mA, lo: mA - 1.96 * sA, hi: mA + 1.96 * sA},
{who: "Adjusted for U", est: mB, lo: mB - 1.96 * sB, hi: mB + 1.96 * sB},
{who: "Honest (unsure whether U matters)", est: mix, lo: mix - 1.96 * Math.sqrt(varMix), hi: mix + 1.96 * Math.sqrt(varMix)}
];
}
Plot.plot({
ariaLabel: "The Pandora Principle: simulation chart",
ariaDescription: "Horizontal axis: Treatment effect estimate (95% interval). The chart updates with the controls above it, and the summary below the charts states the result in words.",
height: 200,
marginLeft: 230,
x: {label: "Treatment effect estimate (95% interval)", grid: true},
y: {label: null},
marks: [
Plot.ruleY(pandora, {y: "who", x1: "lo", x2: "hi", strokeWidth: 3, stroke: (d, i) => ["#d6604d", "#2166ac", "#1a9850"][i]}),
Plot.dot(pandora, {y: "who", x: "est", r: 5, fill: "currentColor"}),
Plot.ruleX([0.3], {stroke: "currentColor", strokeDasharray: "4 3"})
]
})# The Pandora Principle: once you think of a confounder, you can't unthink it.
1confound <- 0.6 # strength of confounding by U
p_matters <- 0.5 # your belief that U matters
2set.seed(67)
u <- rnorm(500)
3z <- rbinom(500, 1, plogis(confound * 1.5 * u)) # treatment depends on U
y <- 0.3 * z + confound * u + rnorm(500) # true effect 0.3
4A <- summary(lm(y ~ z))$coefficients["z", 1:2] # ignores U
5B <- summary(lm(y ~ z + u))$coefficients["z", 1:2] # adjusts for U
# Honest answer: a mixture of the two models, weighted by belief
6mix <- (1 - p_matters) * A[1] + p_matters * B[1]
sd_mix <- sqrt((1 - p_matters) * (A[2]^2 + A[1]^2) +
p_matters * (B[2]^2 + B[1]^2) - mix^2)
est <- rbind(
"Ostrich (never thought of U)" = A[1] + c(0, -1.96, 1.96) * A[2],
"Adjusted for U" = B[1] + c(0, -1.96, 1.96) * B[2],
"Honest (unsure whether U matters)" =
mix + c(0, -1.96, 1.96) * sd_mix
)
colnames(est) <- c("estimate", "lower", "upper")
print(round(est, 2)) # true effect: 0.3
par(mar = c(4, 14, 1, 1))
7plot(est[, 1], 3:1,
xlim = range(est), pch = 19, yaxt = "n", ylab = "",
xlab = "Estimated effect of z (95% interval)"
)
segments(est[, 2], 3:1, est[, 3], 3:1, lwd = 2)
axis(2, 3:1, rownames(est), las = 1, cex.axis = 0.8)
abline(v = 0.3, lty = 2)- 1
- The page’s controls: how strongly the unobserved variable U confounds, and how much you believe it matters.
- 2
- Fixes the random numbers so the run is reproducible.
- 3
- Treatment depends on U, and so does the outcome: U is a confounder.
- 4
- The ostrich estimate, which never thought of U.
- 5
- The estimate that adjusts for U. In real life U would be unmeasured, so this is the box that cannot be reopened.
- 6
- The honest answer once you have thought of U: a mixture of the two, weighted by how much you believe U matters, with the extra uncertainty that implies.
- 7
- The three estimates with their intervals. Having thought of U, you can’t go back to the ostrich’s narrow interval.
# The Pandora Principle: once you think of a confounder, you can't unthink it.
import numpy as np
import matplotlib.pyplot as plt
confound = 0.6 # strength of confounding by U
p_matters = 0.5 # your belief that U matters
rng = np.random.default_rng(67)
u = rng.normal(size=500)
z = rng.binomial(1, 1 / (1 + np.exp(-confound * 1.5 * u))) # depends on U
y = 0.3 * z + confound * u + rng.normal(size=500) # true effect 0.3
def ols(X, y): # coefficient and standard error for z (column 1)
X = np.column_stack([np.ones(len(y)), X])
beta, *_ = np.linalg.lstsq(X, y, rcond=None)
resid = y - X @ beta
s2 = resid @ resid / (len(y) - X.shape[1])
return beta[1], np.sqrt(s2 * np.linalg.inv(X.T @ X)[1, 1])
mA, sA = ols(z, y) # ignores U
mB, sB = ols(np.column_stack([z, u]), y) # adjusts for U
# Honest answer: a mixture of the two models, weighted by belief
mix = (1 - p_matters) * mA + p_matters * mB
sd_mix = np.sqrt((1 - p_matters) * (sA ** 2 + mA ** 2)
+ p_matters * (sB ** 2 + mB ** 2) - mix ** 2)
rows = {"Ostrich (never thought of U)": (mA, sA), "Adjusted for U": (mB, sB),
"Honest (unsure whether U matters)": (mix, sd_mix)}
for k, (m, s) in rows.items():
print(f"{k}: {m:.2f} ({m - 1.96 * s:.2f} to {m + 1.96 * s:.2f})")
for i, (k, (m, s)) in enumerate(rows.items()):
plt.errorbar(m, -i, xerr=1.96 * s, fmt="o", color="black")
plt.yticks([0, -1, -2], list(rows))
plt.axvline(0.3, color="black", linestyle="--")
plt.xlabel("Estimated effect of z (95% interval)")
plt.tight_layout()
plt.show()Key takeaways
- Once a potential bias has been raised, address it. Don’t un-think it.
- Diligence can widen uncertainty. That’s honesty, not a penalty.
- The ostrich’s narrow intervals come from not looking.
Source
- Andrew Gelman, The Pandora principle in statistics, and its malign converse, the ostrich (2017).