Causal Inference: From Correlation to Causation
Module: Machine Learning | Difficulty: Advanced
Potential Outcomes
Rubin Causal Model
Fundamental problem: we observe only one potential outcome.
Do-Calculus (Pearl)
Instrumental Variables
Propensity Score
import numpy as np
from sklearn.linear_model import LogisticRegression
class IPW:
def __init__(self):
self.propensity = LogisticRegression()
def fit(self, X, T):
self.propensity.fit(X, T)
def estimate_ATE(self, X, T, Y):
e = self.propensity.predict_proba(X)[:, 1]
e = np.clip(e, 0.01, 0.99)
ate = np.mean(T * Y / e - (1-T) * Y / (1-e))
return ate
Research Insight: Machine learning can estimate heterogeneous treatment effects (CATE) using methods like causal forests and meta-learners. The key challenge is that ML optimizes prediction, not causal estimation, leading to confounding bias.