Simpson's Paradox: Algebra, Causality, and When to Stratify
Statistics & ExperimentsModel answerLast updated
Build a numeric reversal from scratch, derive the bias formula, connect it to causal graphs, and explain when the aggregate is the right answer versus when you must condition.
Aggregate vs. Subgroup: A Statistical Reversal
You are analyzing the results of a medical trial. A colleague hands you a summary table and says: "The new drug looks worse overall, but somehow it outperforms the control in every patient subgroup. How is that possible, and which number should we trust?"
Your task
-
Define the phenomenon. Explain in plain terms how a trend can hold in every subgroup yet reverse in the pooled data. State the two conditions a third variable must satisfy for this to happen.
-
Build a concrete numeric example. Construct a 2×2×2 table (two subgroups, two arms) where:
- The treatment arm has a higher success rate than control in both subgroups.
- The pooled treatment rate is lower than the pooled control rate. Use realistic numbers; round percentages are fine.
-
Derive the algebra. Write the pooled difference as a sum of a within-stratum term and a composition-bias term. Show what the bias term is a product of, and explain why the reversal happens when the bias term overwhelms and opposes the within-stratum effect.
-
Connect to causal structure. Using a directed acyclic graph (DAG), explain how the answer changes depending on whether the third variable is a confounder, a mediator, or a collider.
-
Describe practical remedies for the confounder case: stratification, direct standardization (g-formula), regression adjustment, and inverse propensity weighting. Note a key pitfall of odds ratios.
-
State when the aggregate is correct and when you must condition. Give at least one product/analytics example alongside the medical one.
What a strong answer looks like: concrete numbers, the algebraic decomposition written out, a clear causal argument for which estimand to report, and at least one common mistake called out explicitly.
Hints
Hint 1
Start by noticing that a pooled rate is a *weighted* average of stratum rates. The weights differ across arms when subgroup sizes are unequal — that's the engine of the reversal. Write the weights down before anything else.
Hint 2
The bias term is a product of two quantities: how unequally the subgroups are distributed across arms, and how strongly the subgroup predicts the outcome on its own. Ask yourself: what makes each factor zero, and why does randomization set one of them to zero?
Hint 3
The hardest part of the question is step 4. The same table is consistent with confounder, mediator, and collider graphs. The data cannot tell you which one applies — you need a subject-matter assumption. Name the graph structure first, then pick your estimand.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Definition
The phenomenon occurs when an association holds consistently within every subgroup of a dataset but flips direction — or disappears — once all the subgroups are combined. It is not a rounding artifact or a small-sample quirk; it persists with arbitrarily large data.
Two conditions must both hold for a third variable Z to produce this reversal:
- Z is associated with which arm a unit ends up in (it predicts treatment assignment).
- Z is also associated with the outcome, independent of treatment.
When both conditions hold, comparing pooled rates mixes the treatment effect with differences in subgroup composition across arms.
A concrete numeric example
Let Z = patient severity. Doctors tend to assign the new drug to sicker patients, who recover less often regardless of what they receive.
| Subgroup | Drug | Control |
|---|---|---|
| Mild | 18 / 20 = 90% | 160 / 200 = 80% |
| Severe | 60 / 200 = 30% | 4 / 20 = 20% |
| Pooled | 78 / 220 = 35.5% | 164 / 220 = 74.5% |
The drug wins by 10 percentage points in each subgroup. Control wins by 39 points overall.
The reason: 91% of drug recipients are severe patients (200 out of 220), while 91% of control recipients are mild patients. The drug arm is weighed down by the harder-to-treat group.
The algebraic decomposition
Let $p_{T1}, p_{T2}$ be the drug's recovery rates in the mild and severe subgroups, and $p_{C1}, p_{C2}$ the same for control. Let $w_T$ be the fraction of drug patients who are mild, and $w_C$ the same fraction for control.
Each pooled rate is a weighted average:
$$p_T = w_T p_{T1} + (1 - w_T) p_{T2}, \qquad p_C = w_C p_{C1} + (1 - w_C) p_{C2}$$
Subtracting and rearranging yields:
$$p_T - p_C = \underbrace{\bigl[w_T(p_{T1} - p_{C1}) + (1-w_T)(p_{T2} - p_{C2})\bigr]}{\text{within-subgroup effect}} + \underbrace{(w_T - w_C)(p{C1} - p_{C2})}_{\text{composition bias}}$$
Plugging in $w_T = 20/220 \approx 0.091$ and $w_C = 200/220 \approx 0.909$:
- Within-subgroup term: $0.091(0.10) + 0.909(0.10) = +0.10$
- Bias term: $(0.091 - 0.909)(0.80 - 0.20) = (-0.818)(0.60) \approx -0.491$
- Total: $0.10 - 0.491 \approx -0.391$ ✓
The bias term is the product of imbalance ($w_T - w_C$, how unevenly subgroups are distributed across arms) and prognostic strength ($p_{C1} - p_{C2}$, how much Z moves outcomes on its own). A reversal requires the bias term to exceed the within-subgroup effect in magnitude and carry the opposite sign.
This is exactly why randomization works: it drives $w_T \approx w_C$, collapsing the bias term to zero regardless of how predictive Z is.
Causal structure determines the right answer
The same table is consistent with three different DAGs, and each implies a different analysis.
Z is a confounder (Z → T, Z → Y, T → Y): severity drives both treatment choice and recovery. The path T ← Z → Y is an open backdoor path. By the backdoor criterion you must condition on Z. The causal effect is the stratified +10 points, not the pooled −39 points. In do-calculus: $P(Y \mid do(T)) = \sum_z P(Y \mid T, z),P(z)$, which is not the same as $P(Y \mid T)$.
Z is a mediator (T → Z → Y): the drug works partly by reducing severity scores, which improves survival. Conditioning on Z blocks part of the causal pathway. For the total effect, use the aggregate. Stratifying here estimates a direct effect — a different and narrower question.
Z is a collider (T → Z ← Y): conditioning on a collider opens a spurious association. Do not adjust. The aggregate is correct.
The key point most candidates miss: data alone cannot distinguish these three cases. Subject-matter knowledge or an explicit causal model must come first; then the choice of estimand follows.
Remedies when Z is a confounder
Stratification / Mantel–Haenszel. Report the effect within each subgroup and pool estimates using information-weighted averaging. Clean and interpretable when Z is categorical with few levels.
Direct standardization (g-formula). Apply each arm's subgroup-specific rates to a single reference distribution of Z. Using the overall population (50% mild, 50% severe as a neutral reference): Drug: $0.5(0.90) + 0.5(0.30) = 0.60$; Control: $0.5(0.80) + 0.5(0.20) = 0.50$. The standardized ATE is +0.10. Weighting by the treated population gives the ATT; weighting by the control population gives the ATC. The choice of reference population is a deliberate decision about the estimand.
Regression adjustment. Fit logit P(Y=1) = β₀ + β₁·T + β₂·Z, adding a T×Z interaction if effects vary by subgroup. Derive the marginal effect via g-computation: predict outcomes for every unit under T=1 and T=0 and average the difference. Key pitfall: odds ratios are non-collapsible — a conditional OR differs from a marginal OR even without any confounding, so comparing ORs across models with different covariate sets is misleading.
Inverse propensity weighting (IPW). Estimate $P(T \mid Z)$ and weight each unit by the inverse of its probability of receiving the treatment it actually received. This rebalances Z across arms and scales more gracefully to high-dimensional Z than stratification does.
All four methods rest on the same untestable assumptions: no unmeasured confounders, and positivity (every subgroup contains units in both arms).
When the aggregate is the right estimand
Use the pooled result when:
- Treatment was randomized — composition imbalance is chance variation, not systematic bias.
- Z is a mediator and you want the total causal effect.
- Z is a collider — conditioning would introduce bias.
- The question is descriptive or predictive: "What conversion rate did users in the treatment group actually see?" or "What revenue should we forecast given next quarter's traffic mix?"
Condition on Z when:
- Z is a pre-treatment confounder and the question is causal ("should we ship this feature?").
- Z is an effect modifier and downstream decisions are made separately per subgroup.
Product analytics version. A new checkout flow shows lower overall conversion than the old one during rollout. But it outperforms the control on both desktop and mobile. The explanation: mobile users convert at half the rate of desktop users, and the new flow rolled out first on mobile. Stratify by platform, or better, randomize within platform from the start.
Common mistakes
- Always stratify. Conditioning on a mediator or collider introduces bias rather than removing it.
- Pick the table that tells the story you want. Without a causal argument for which estimand is appropriate, choosing the more favorable number is cherry-picking.
- Treating this as a small-sample problem. The reversal holds with infinite data; more data does not fix a structural confound.
- Comparing conditional and marginal odds ratios as if they measure the same thing. They do not, even absent confounding.