Sherlock's Guide to Causal Inference Foundations
Greetings, inquirer! As Sherlock, the AI detective from Trailblazer Labs, I'll unravel the mysteries of causality with precision. Causal inference lets us answer: "What would have happened if...?" We'll cover the essentials step-by-step, then tie it with a tiny worked example. Think of this as deducing the culprit (causal effect) from clues (data).
1. Potential Outcomes Framework (Rubin Causal Model)
Causality is about counterfactuals: comparing outcomes under treatment vs. no treatment.
-
Notation:
- ( Y(1) ): Potential outcome if treated (( D=1 )).
- ( Y(0) ): Potential outcome if not treated (( D=0 )).
- Observed: ( Y = Y(1) ) if ( D=1 ), else ( Y(0) ).
-
Average Treatment Effect (ATE): ( \mathbb{E}[Y(1) - Y(0)] ) (population average).
-
Average Treatment Effect on Treated (ATT): ( \mathbb{E}[Y(1) - Y(0) \mid D=1] ).
-
Fundamental Problem: We never observe both ( Y(1) ) and ( Y(0) ) for the same unit (Neyman-Rubin-Yao).
Goal: Identify (recover) these from observables like ( \mathbb{E}[Y \mid D=1] - \mathbb{E}[Y \mid D=0] ) (naive difference, biased by selection).
2. DAGs and d-Separation (Pearl's Causal Graphs)
Directed Acyclic Graphs (DAGs) visualize causal structure:
- Nodes: Variables (e.g., Treatment ( D ), Outcome ( Y ), Confounder ( C )).
- Arrows: Causal effects.
d-Separation: Tests conditional independence.
- Blocks paths: Colliders (head-to-head, open only if conditioned on), Chains/Forks (blocked by conditioning).
- Backdoor Criterion: Condition on a set ( Z ) that blocks all backdoor paths (from ( D ) to ( Y ) via common causes) → ( Y \perp D \mid Z ) → Adjust via regression/stratification.
- Frontdoor Criterion: For mediators, if no confounders between them.
Example DAG: ( C \to D \to Y ), ( C \to Y ) (confounding). Block backdoor ( C ).
3. Identification Strategies
Move from association to causation via assumptions/designs.
| Strategy | Intuition | Key Formula/Setup | Strong Assumptions |
|---|
| RCT (Randomized Controlled Trial) | Randomize ( D ) → No confounders. | ATE = ( \mathbb{E}[Y \mid D=1] - \mathbb{E}[Y \mid D=0] ). | Randomization (ignorability: ( Y(0),Y(1) \perp D )). |
| IV (Instrumental Variables) | ( Z ) affects ( D ) (relevance), but only ( Y ) via ( D ) (exclusion). | Wald: ( \frac{\mathbb{E}[Y \mid Z=1] - \mathbb{E}[Y \mid Z=0]}{\mathbb{E}[D \mid Z=1] - \mathbb{E}[D \mid Z=0]} ) (LATE for compliers). | Relevance, exclusion, monotonicity, no defiers. |
| DiD (Difference-in-Differences) | Parallel trends: Treated/Control trends match pre-treatment. | ( [\mathbb{E}[Y_{post} \mid D=1] - \mathbb{E}[Y_{pre} \mid D=1]] - [\mathbb{E}[Y_{post} \mid D=0] - \mathbb{E}[Y_{pre} \mid D=0]] ). | Parallel trends, no anticipation. |
| RD (Regression Discontinuity) | Treatment at cutoff ( c ) (e.g., score ≥ c gets ( D=1 )). Local effect. | Local polynomial regression around ( c ): ( \lim_{x \to c^+} \mathbb{E}[Y \mid X=x] - \lim_{x \to c^-} \mathbb{E}[Y \mid X=x] ). | Continuity (no jumps except via ( D )), no manipulation. |
| Matching | Pair treated/untreated with similar covariates ( X ) (e.g., propensity score ( p(X) = P(D=1 \mid X) )). | ATT ≈ ( \mathbb{E}[ (Y(1) - \mathbb{E}[Y(0) \mid p(X), D=1]) \mid D=1 ] ). | Conditional independence: ( Y(0),Y(1) \perp D \mid X ); overlap. |
4. Assumptions and Threats
All strategies rest on untestables—violate them, and bias creeps in.
- Confounding: ( U \to D, U \to Y ) (unobserved). Threatens all but perfect RCTs/IVs.
- Interference (SUTVA violation): Spillovers (one unit's treatment affects another's outcome). Threatens unit-level independence.
- Measurement Error:
| Type | Effect | Fix |
|---|
| Classical (in ( Y ), mean 0) | Attenuates effect. | IV or multiple measures. |
| In ( D ) | Bias toward zero or away. | Validation data. |
| In ( X ) (confounder) | Confounding worsens. | Bounds/sensitivity. |
Other threats: Attrition (selection), spillover, multiple treatments.
5. Sensitivity Analysis
Robustness checks:
- Rosenbaum Bounds: For matching, how much hidden confounding to flip sign?
- E-value: Strength of unobserved confounder to explain away effect.
- Simulation: Perturb assumptions (e.g., violate parallel trends by 10%).
- Tools:
sensemakr (R), Partial (Python).
6. Reporting
Be transparent like a detective's log:
- State estimand (ATE/ATT/LATE?).
- Design diagram (DAG + strategy).
- Estimate ± SE, CI (95%).
- Assumptions listed + tests (balance, placebo).
- Sensitivity: Tables/graphs.
- Example: "ATT = 2.5 (SE=0.8), p<0.01. Robust to 30% parallel trends violation."
Tiny Worked Example: Job Training on Wages
Setup: Does training (( D )) raise wages (( Y ))? ( n=200 ), confounder age ( C ). True ATE=5 (but naive diff=3, confounded).
DAG: Age → Training, Age → Wages, Training → Wages.
Data Snippet (simulated):
| Group | Age | Wages | N |
|---|
| Treated | 35 | 25 | 100 |
| Control | 30 | 22 | 100 |
Naive: 25-22=3 (younger controls drag down).
Strategy: Matching on Age (Propensity Score).
- Estimate ( p(Age) = P(D=1 \mid Age) ) via logit.
- Match each treated to similar control (e.g., nearest neighbor).
- Matched: Treated Wages=25 (Age=35), Matched Control=23 (Age=35). ATT=2? Wait, simulate properly.
Worked Calc (Simple Stratification, Backdoor):
- Strata by Age tertiles. Adjust: ( \hat{ATE} = \sum \frac{N_{strata}}{N} (\bar{Y}{1,s} - \bar{Y}{0,s}) ).
- Tertile1 (young): Treated=24, Control=21 → diff=3.
- Tertile2: 25-23=2.
- Tertile3 (old): 26-24=2. Weighted ATE≈2.3 (still biased? Assume partial).
Better: RCT Simulation Insight: Randomize → ATE=25-20=5. True!
Threat: Confounding by motivation ( U ) (unobs). Sensitivity: E-value=1.8 (obs confounder 1.8x stronger explains it away).
Report: "Matching ATT=2.5 (SE=1.0, 95% CI [0.5,4.5]). Parallel placebo test passes. Robust to 50% confounding (Rosenbaum p=0.12)."
There—causality deduced! Questions, Watson? 🔍