Advanced Causality
Topic 07 covers experimental design and quasi-experimental methods (DiD, RDD, IV). This topic goes deeper into the causal inference framework: DAGs for formalizing causal assumptions, the potential outcomes framework for defining causal effects, and modern ML-based causal methods (double ML, causal forests) for estimating heterogeneous treatment effects at scale. These tools are essential for senior practitioners who must design, critique, and defend causal claims from observational data.
Key Takeaways
- A DAG (directed acyclic graph) makes causal assumptions explicit and testable — confounders, mediators, and colliders have different implications for identification strategy
- The backdoor criterion tells you which variables to condition on (and which NOT to) to identify a causal effect from observational data
- Never condition on a collider — it opens a spurious association between its causes (collider bias / Berkson's paradox)
- The potential outcomes framework defines the Average Treatment Effect (ATE) as $E[Y(1) - Y(0)]$ — the fundamental problem is that we never observe both potential outcomes for the same unit
- Double/debiased ML (DML) uses Neyman orthogonality to estimate treatment effects without parametric assumptions, with valid confidence intervals even when nuisance functions are estimated with ML
- Causal forests estimate heterogeneous treatment effects (CATE) — the effect varies by subgroup — enabling targeted policy and personalized interventions
1. DAGs and Structural Causal Models
A DAG (directed acyclic graph) has nodes = variables and directed edges = direct causal relationships. It is acyclic — no feedback loops in the static model.
Three Fundamental Structures
Chain (A → B → C): B mediates A's effect on C. Conditioning on B blocks the path.
Fork (A ← B → C): B confounds the A–C relationship. Conditioning on B blocks the spurious association.
Collider (A → B ← C): B is caused by both A and C. B is a collider. The path is blocked — A and C are independent. But conditioning on B opens this path and creates spurious dependence. This is collider bias.
d-Separation
Two nodes are d-separated (conditionally independent) given a set Z if every path between them is blocked by Z. Chains and forks are blocked by conditioning on the middle node; colliders are blocked by not conditioning on them — and are opened by conditioning.
Confounders vs. Mediators
- Confounder (fork): creates spurious association — should be adjusted for
- Mediator (chain): transmits the causal effect — should not be adjusted for if you want the total effect
2. Backdoor Criterion
A set Z satisfies the backdoor criterion relative to (X, Y) if:
- No node in Z is a descendant of X
- Z blocks every backdoor path between X and Y (paths with an arrow into X)
If Z satisfies the backdoor criterion, the causal effect of X on Y is identified by the adjustment formula:
$$P(Y \mid do(X=x)) = \sum_z P(Y \mid X=x,\, Z=z)\, P(Z=z)$$You can estimate the causal effect from observational data by conditioning on Z — via stratification, regression, or inverse probability weighting (IPW).
Worked Example: Education and Earnings
Does education (X) cause earnings (Y)?
- Confounder: parental income (C) affects both education access and earnings. Backdoor path: X ← C → Y. Solution: condition on C to block this path.
- Mediator: skills (M) is on the path X → M → Y. Do not condition on M if you want the total effect of education on earnings.
3. Potential Outcomes Framework
The Rubin Causal Model defines causal effects via potential outcomes:
- $Y_i(1)$: potential outcome for unit $i$ if treated
- $Y_i(0)$: potential outcome for unit $i$ if untreated
- Individual treatment effect: $\tau_i = Y_i(1) - Y_i(0)$
- Fundamental problem of causal inference: we only observe one potential outcome per unit; the other is counterfactual
Estimands
- ATE: $\tau_{\text{ATE}} = E[Y(1) - Y(0)]$ — average over the full population
- ATT: $\tau_{\text{ATT}} = E[Y(1) - Y(0) \mid T=1]$ — average among those who were treated
- CATE: $\tau(x) = E[Y(1) - Y(0) \mid X=x]$ — heterogeneous effect for subgroup $x$
Identification Assumptions
- Unconfoundedness / ignorability: $(Y(0), Y(1)) \perp T \mid X$ — no unmeasured confounders given X
- Overlap / positivity: $0 < P(T=1 \mid X) < 1$ — every unit has positive probability of treatment and control
- SUTVA: stable unit treatment value assumption — no interference between units, no hidden versions of treatment
4. Double/Debiased Machine Learning (DML)
Motivation: if we regress Y ~ T + X with LASSO, regularization shrinks the T coefficient toward zero along with the X coefficients — biasing the treatment effect estimate.
DML (Robinson 1988 / Chernozhukov et al. 2018) uses the partialing-out approach:
$$Y_i - E[Y \mid X_i] = \theta \cdot (T_i - E[T \mid X_i]) + \epsilon_i$$The residuals $\tilde{Y} = Y - \hat{E}[Y \mid X]$ and $\tilde{T} = T - \hat{E}[T \mid X]$ are computed by any ML model using cross-fitting (k-fold). Then $\theta$ is estimated by OLS regression of $\tilde{Y}$ on $\tilde{T}$.
Why it works: Neyman orthogonality — the target parameter $\theta$ is orthogonal to errors in the nuisance functions $E[Y \mid X]$ and $E[T \mid X]$ in a first-order sense. Small estimation errors in those functions don't propagate to bias in $\hat{\theta}$. Cross-fitting prevents overfitting from inflating nuisance predictions on the same data used to estimate $\theta$.
from sklearn.linear_model import LassoCV
from sklearn.model_selection import cross_val_predict
import numpy as np
# Step 1: Partial out confounders X from Y and T
Y_resid = Y - cross_val_predict(LassoCV(), X, Y, cv=5)
T_resid = T - cross_val_predict(LassoCV(), X, T, cv=5)
# Step 2: OLS on residuals — this is the DML estimate of theta
theta = np.dot(T_resid, Y_resid) / np.dot(T_resid, T_resid)
print(f"DML ATE estimate: {theta:.4f}")
# Using EconML for full inference with confidence intervals
from econml.dml import LinearDML
dml = LinearDML(model_y=LassoCV(), model_t=LassoCV(), cv=5)
dml.fit(Y, T, X=X)
print(dml.effect_inference(X).summary_frame())
5. Causal Forests and Heterogeneous Treatment Effects
Standard DML estimates the ATE — a single number. But treatment effects often vary by subgroup (heterogeneous treatment effects / CATE).
Causal forests (Wager & Athey, 2018) adapt random forests to estimate CATE. Each tree is grown to maximize heterogeneity in treatment effects rather than prediction accuracy. Key property: honesty — each tree uses a held-out subsample to fit leaf-level treatment effects, providing asymptotically valid confidence intervals.
from econml.grf import CausalForest
cf = CausalForest(n_estimators=500, min_samples_leaf=20, random_state=42)
cf.fit(X_train, T_train, Y_train)
# Estimate CATE for each test observation
cate = cf.predict(X_test) # shape: (n_test,)
cate_lb, cate_ub = cf.predict_interval(X_test, alpha=0.05) # 95% CI
# Find most responsive subgroup
top_quartile = X_test[cate > np.percentile(cate, 75)]
print(f"Average CATE (top quartile): {cate[cate > np.percentile(cate, 75)].mean():.4f}")
Business application: a promotional offer has ATE = +$5 revenue lift. But a causal forest shows CATE ranges from −$2 (high-value customers who would have bought anyway) to +$15 (price-sensitive mid-tier customers). Targeting only the mid-tier segment triples ROI.
6. Sensitivity Analysis
No observational study is immune to unmeasured confounding. Sensitivity analysis asks: how strong would an unmeasured confounder need to be to explain away the observed effect?
Rosenbaum bounds: parameterize by $\Gamma$ (odds ratio of treatment selection due to unmeasured confounder). At $\Gamma = 1$, there is no hidden bias. Find the smallest $\Gamma$ at which the conclusion reverses. If the effect is robust to $\Gamma = 2$, unmeasured confounders would need to double the odds of treatment selection to nullify the finding.
E-value: the minimum association (on the risk ratio scale) that an unmeasured confounder would need with both treatment and outcome to explain away the effect:
$$E\text{-value} = \hat{RR} + \sqrt{\hat{RR}(\hat{RR}-1)}$$Large E-values indicate robust findings — a confounder would need implausibly strong associations to explain away the result.
Practice Questions
Q1: What is a collider and why is conditioning on it dangerous?
A collider is a variable that is caused by two or more other variables on a path — arrows point into it from both sides (A → C ← B). In a DAG, a collider naturally blocks the path between A and B: they are independent unless we condition on C. When we condition on C (include it in a regression, stratify by it, or select a sample based on it), we open the path between A and B, inducing a spurious correlation even if A and B are causally unrelated.
Example (Berkson's paradox): in a hospital sample (conditioning on hospitalization), two independently-caused diseases appear negatively correlated because having one disease increases the probability of hospitalization even without the other.
Practical warnings: never adjust for a post-treatment variable (it may be a collider or mediator), and be cautious when analyzing selected samples — sample selection itself may be a collider.
Q2: Describe the Double ML estimator. Why doesn't regularization in ML models bias the treatment effect estimate?
Standard LASSO on Y ~ T + X shrinks the T coefficient toward zero along with all X coefficients — biasing the treatment effect. DML avoids this using the partialing-out approach:
- Use any ML model (LASSO, random forest) in a cross-fitting scheme to estimate $\hat{E}[Y \mid X]$ and $\hat{E}[T \mid X]$ — these are nuisance functions.
- Compute residuals $\tilde{Y} = Y - \hat{E}[Y \mid X]$ and $\tilde{T} = T - \hat{E}[T \mid X]$.
- Regress $\tilde{Y}$ on $\tilde{T}$ using OLS to get $\hat{\theta}$.
The key insight is Neyman orthogonality: $\theta$ is orthogonal to errors in the nuisance functions in a first-order sense, so small estimation errors in the nuisances don't propagate to bias in $\hat{\theta}$. Cross-fitting prevents overfitting from inflating nuisance predictions on the same data used to estimate $\theta$.
Q3: Your team estimates that a fee waiver offer increases product adoption by 20% (ATE). A colleague suggests the effect might be much larger for certain customer segments. How would you investigate?
Use causal forests (or DML with interaction terms) to estimate heterogeneous treatment effects:
- Fit a causal forest using pre-treatment customer features (tenure, product usage, demographics, past behavior) as X, the randomized treatment indicator T, and outcome Y.
- Predict CATE for each customer in the test set.
- Examine the CATE distribution — plot a histogram, identify the range and percentiles.
- Use causal forest feature importance to identify which features drive heterogeneity.
- Sort customers into quartiles by predicted CATE and compare average CATE per quartile.
- Report with confidence intervals — causal forests provide honest, asymptotically valid CIs.
- Prospective validation: re-run the experiment targeting only the highest-CATE segment and verify that the observed effect matches the predicted CATE.
Q4: You find a positive association between customer support calls and churn. A product manager concludes: "Support calls cause churn — let's reduce support capacity." What concerns do you raise and how do you analyze this properly?
This is a classic confounding problem. The likely DAG: poor product experience (C) causes both more support calls (X) and churn (Y). The observed X–Y correlation is largely driven by C.
Steps:
- Draw the DAG explicitly with the team — identify likely confounders (product quality, customer segment, acquisition channel, satisfaction scores).
- Apply the backdoor criterion — which variables should we adjust for?
- Use regression with confounder controls, propensity score methods, or DML for complex relationships.
- If possible, find a natural experiment or instrument (e.g., exogenous variation in support wait times due to staffing changes) as an IV.
More likely finding: after controlling for product experience, support calls reduce churn — customers who get help are less likely to leave. Reducing support capacity would worsen churn, not help it.
Action Items
- Draw a DAG with a confounder, a mediator, and a collider — identify which to condition on for each
- State the backdoor criterion formally and apply it to a worked example
- Define ATE, ATT, and CATE — know when each is the right estimand
- Explain the DML algorithm step-by-step and why it avoids regularization bias
- Know how causal forests differ from standard random forests
- Define the E-value and explain what a large E-value implies for observational study robustness