Explorations in causal inference using the potential outcomes (Rubin) framework, based on the Mixtape Sessions by Scott Cunningham.
For each individual i, there exist two potential outcomes:
- Y_i(0): outcome under no treatment (control)
- Y_i(1): outcome under treatment
The individual treatment effect (ITE) is delta_i = Y_i(1) - Y_i(0). The fundamental problem of causal inference is that we can never observe both potential outcomes for the same individual.
- ATE (Average Treatment Effect): E[Y(1) - Y(0)] -- the population-level average causal effect
- ATT (Average Treatment Effect on the Treated): E[Y(1) - Y(0) | D=1]
- ATU (Average Treatment Effect on the Untreated): E[Y(1) - Y(0) | D=0]
The Simple Difference in Outcomes (SDO) between treated and untreated groups decomposes as:
SDO = ATE + Selection Bias + Heterogeneous Treatment Effect Bias
where:
- Selection Bias = E[Y(0)|D=1] - E[Y(0)|D=0] (systematic differences in baseline outcomes)
- HTE Bias = (1 - pi)(ATT - ATU) (difference in treatment effect between groups)
Realized outcomes follow: Y_i = (1 - D_i) * Y_i(0) + D_i * Y_i(1), where D_i is the treatment indicator.
Simulates 100,000 individuals with normally distributed potential outcomes (Y(0) ~ N(9.4, 4), Y(1) ~ N(10, 4)) and compares two assignment mechanisms:
- Perfect Doctor: assigns treatment only to individuals who would benefit (delta > 0). This introduces severe selection bias because the doctor uses information about potential outcomes.
- Random Assignment: assigns treatment to the first 50% of individuals. Eliminates selection bias by construction.
| Parameter | Perfect Doctor | Random Assignment |
|---|---|---|
| ATE | ~0.60 | ~0.60 |
| ATT | ~4.71 | ~0.56 |
| ATU | ~-4.27 | ~0.64 |
| Selection Bias | ~-4.50 | ~0.05 |
| SDO | ~0.22 | ~0.62 |
Under the perfect doctor, the SDO (0.22) is far from the true ATE (0.60) because of large selection bias. Under random assignment, the SDO closely approximates the true ATE.
Replicates analysis from Thornton (2008) -- a randomized experiment in Malawi studying whether financial incentives increase the likelihood of learning HIV test results.
- Control group (no incentive): ~33.9% picked up HIV test results
- Treatment group (any incentive): ~78.9% picked up HIV test results
- Treatment effect: ~45 percentage points increase in pickup rate
- The OLS coefficient on the incentive indicator is highly significant (p < 0.001)
This demonstrates that even small financial incentives can have a substantial effect on health-seeking behavior.
mixtape_sessions/lab1.ipynb-- Potential outcomes framework simulationmixtape_sessions/thornton lab.ipynb-- Thornton HIV experiment replication


