What would you do if you had all the data?
Causes, samples and populations
Principle or heuristic
Advanced
Rubin’s first question.
What it is
Donald Rubin’s first question to anyone with a statistical problem: if you had all the data, with no missing values, the whole population and every potential outcome, what would you compute? The answer defines the estimand, the quantity you are trying to learn. Only after that is clear do the questions of sampling, missing data and modeling make sense.
Why it matters
Many analyses skip this step and go straight to a method: run a regression of y on treatment. Without a clear estimand you can’t tell whether the method answers the right question, or whether two analysts disagree about the data or about what they’re estimating. In causal inference, “all the data” includes potential outcomes that can never be observed together, and the question makes clear that the average treatment effect, the effect on the treated and the median effect are different targets.
How it works
In the potential-outcomes framework, each unit \(i\) has \(Y_i(0)\) and \(Y_i(1)\). With all the data, you could compute any of:
- the average treatment effect, \(\frac{1}{N}\sum_i [Y_i(1) - Y_i(0)]\);
- the effect on the treated, the same average taken over treated units;
- the share who benefit, \(\frac{1}{N}\sum_i \mathbb{1}[Y_i(1) > Y_i(0)]\).
Each is a well-defined function of the complete data, and they can differ a lot. Your actual data are a missing-data version of this complete table. Inference is about predicting the missing half.
Simulated example
Here is a population with both potential outcomes, visible only in simulation. Pick an estimand and compare its all-data value with what a randomized experiment that sees only half of each pair can 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, mean, median, fmt, pct} from "../js/stats.js"
viewof heterogeneity = Inputs.range([0, 2], {value: 1.2, step: 0.1, label: "Variation in individual effects"})
viewof selfSelect = Inputs.range([0, 1], {value: 0.6, step: 0.05, label: "Do people who benefit more choose treatment?"})
viewof seed = Inputs.range([1, 500], {value: 55, step: 1, label: "Random seed"})
units = {
const r = rng(seed);
return range(3000).map(i => {
const y0 = r.normal(0, 1), effect = 0.3 + heterogeneity * r.normal(0, 1);
const chooses = r() < 0.5 + selfSelect * Math.tanh(effect) / 2;
return {i, y0, y1: y0 + effect, effect, chooses, randomized: r() < 0.5};
});
}
estimands = [
{name: "Average effect (everyone)", value: mean(units.map(d => d.effect))},
{name: "Effect on those who choose treatment", value: mean(units.filter(d => d.chooses).map(d => d.effect))},
{name: "Median individual effect", value: median(units.map(d => d.effect))},
{name: "Share who benefit", value: units.filter(d => d.effect > 0).length / units.length}
]
rct = mean(units.filter(d => d.randomized).map(d => d.y1)) - mean(units.filter(d => !d.randomized).map(d => d.y0))
Plot.plot({
ariaLabel: "What would you do if you had all the data?: simulation chart",
ariaDescription: "Horizontal axis: Value computed from ALL the data (both potential outcomes). The chart updates with the controls above it, and the summary below the charts states the result in words.",
height: 220,
marginLeft: 250,
x: {label: "Value computed from ALL the data (both potential outcomes)", grid: true},
y: {label: null},
marks: [Plot.barX(estimands, {y: "name", x: "value", fill: "#2166ac"}), Plot.ruleX([0]), Plot.ruleX([rct], {stroke: "#d6604d", strokeWidth: 2, strokeDasharray: "4 3"})]
})# What would you do if you had all the data? Choosing the estimand.
1heterogeneity <- 1.2 # variation in individual effects
self_select <- 0.6 # do people who benefit more choose treatment?
2set.seed(55)
# Both potential outcomes, visible only in a simulation
y0 <- rnorm(3000)
effect <- 0.3 + heterogeneity * rnorm(3000)
3y1 <- y0 + effect
4chooses <- runif(3000) < 0.5 + self_select * tanh(effect) / 2
randomized <- runif(3000) < 0.5
5estimands <- c(
"Average effect (everyone)" = mean(effect),
"Effect on those who choose" = mean(effect[chooses]),
"Median individual effect" = median(effect),
"Share who benefit" = mean(effect > 0)
)
print(round(estimands, 2))
6rct <- mean(y1[randomized]) - mean(y0[!randomized])
cat(
"A randomized experiment estimates", round(rct, 2),
"(it targets the average effect)\n"
)
7hist(effect,
breaks = 50, col = "#2166ac", border = "white", main = "",
xlab = "Individual treatment effect", ylab = "People"
)
abline(v = estimands[1:3], col = c("black", "#d6604d", "#b8860b"), lwd = 2)
abline(v = rct, lty = 2)- 1
- The page’s controls: how much individual effects vary, and how strongly people who benefit more choose the treatment.
- 2
- Fixes the random numbers so the run is reproducible.
- 3
- With all the data, both potential outcomes are visible for everyone, which only a simulation allows.
- 4
- Who would choose the treatment on their own.
- 5
- Four different estimands you could want once you had all the data. They differ.
- 6
- What a randomized experiment estimates: the average effect over everyone, whether or not that was the question.
- 7
- The distribution of individual effects, with the estimands marked.
# What would you do if you had all the data? Choosing the estimand.
import numpy as np
import matplotlib.pyplot as plt
heterogeneity = 1.2 # variation in individual effects
self_select = 0.6 # do people who benefit more choose treatment?
rng = np.random.default_rng(55)
# Both potential outcomes, visible only in a simulation
y0 = rng.normal(size=3000)
effect = 0.3 + heterogeneity * rng.normal(size=3000)
y1 = y0 + effect
chooses = rng.uniform(size=3000) < 0.5 + self_select * np.tanh(effect) / 2
randomized = rng.uniform(size=3000) < 0.5
estimands = {"Average effect (everyone)": effect.mean(),
"Effect on those who choose": effect[chooses].mean(),
"Median individual effect": np.median(effect),
"Share who benefit": np.mean(effect > 0)}
for k, v in estimands.items():
print(f"{k}: {v:.2f}")
rct = y1[randomized].mean() - y0[~randomized].mean()
print(f"A randomized experiment estimates {rct:.2f} "
"(it targets the average effect)")
plt.hist(effect, bins=50, color="#2166ac")
for v, c in zip(list(estimands.values())[:3],
["black", "#d6604d", "#b8860b"]):
plt.axvline(v, color=c, linewidth=2)
plt.axvline(rct, color="black", linestyle="--")
plt.xlabel("Individual treatment effect")
plt.ylabel("People")
plt.show()Key takeaways
- Define the estimand as a function of the complete data before choosing a method.
- Different estimands (ATE, ATT, median, share benefiting) can be very different numbers.
- Treat inference as predicting the missing parts of the complete data.
Source
- Andrew Gelman, Philosophy of Bayesian statistics: my reactions to Cox and Mayo (2012).