What is Simpson paradox?
Simpson's paradox is when a trend appears in several groups but reverses or disappears when the groups are combined. It happens because a confounding variable is unevenly distributed across groups and is related to the outcome.
Classic example: a treatment appears to have a higher success rate overall, but within each severity level it actually performs better. The treatment group contains more mild cases, which inflates its overall rate.
df.groupby("severity").agg(success=("success", "mean"))
Implications: always examine the relevant subgroups and think about causal structure before aggregating. But do not automatically prefer the disaggregated view either, because conditioning on a collider or a mediator can create its own bias.
The lesson is that the unit of analysis and the adjustment set are modelling decisions that should follow from a causal diagram, not from whichever result looks better.