σ StatsDoge Causal inference workflows
12
Workflow·4 steps·branched

Heterogeneous effects with causal-forest double ML (EconML)

Source EconML — Microsoft Research (ALICE)
Summary by StatsDoge

Cross-fit nuisance models for E[Y|X,W] and E[T|X,W], then fit a forest on the residuals so the final τ(x) is Neyman-orthogonal. The forest's adaptive weights give pointwise confidence intervals on τ(x) — heterogeneity you can actually defend.

1

Input · what goes in

Outcome Y, treatment T, the effect-modifiers X you want to vary the effect over, and controls W to adjust for.

Show data format & exampleHide example

Format — outcome Y, treatment T, effect-modifiers X, controls W (one row per unit).

from econml.orf import DMLOrthoForest
est = DMLOrthoForest(n_trees=1000)
est.fit(Y, T, X=X, W=W)
tau = est.effect(X_test)        # τ(x) at new points
2

Pipeline · the recipe ⑂ has parallel branches

↑ Click any step in the diagram to read its logic, code, assumptions & discussion.

1
Data prep

Split features: effect-modifiers X vs controls W

Data preparation — shapes the raw inputs into what the estimator expects.

What happens here

Decide what the effect is allowed to vary over (X) and what is merely confounding to adjust for (W). The target is the CATE.

Formula
au(x)=\mathbb{E}ig[\,Y(1)-Y(0)\mid X{=}x\,ig]
Reads from the input data Feeds into the final output
Key code
# Y outcome, T treatment, X effect modifiers, W controls

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
2
Estimation

Partial out nuisance (Neyman-orthogonal DML)

The core estimate — where the causal quantity itself is computed.

What happens here

Cross-fit flexible models for E[Y|X,W] and E[T|X,W]; regress the residuals so first-stage error doesn't bias the effect.

Formula
ilde Y=Y-\hat\ell(X,W),\quad ilde T=T-\hat e(X,W),\quad ilde Y= heta(X)\, ilde T+\varepsilon
Reads from the input data Feeds into the final output
Key code
from econml.dml import CausalForestDML
est = CausalForestDML().fit(Y, T, X=X, W=W)

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
3
Heterogeneity

Forest-weighted local effect τ(x)

Heterogeneity — who is affected, and by how much, not just on average.

What happens here

A causal/orthogonal forest defines adaptive weights α_i(x); the effect at x solves a locally-weighted residual moment.

Formula
\hat heta(x)=\Big( extstyle\sum_i\alpha_i(x) ilde T_i^2\Big)^{-1} extstyle\sum_i\alpha_i(x) ilde T_i ilde Y_i
Reads from the input data Feeds into the final output
Key code
tau = est.effect(X_test)
est.feature_importances_

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
4
Inference

Confidence intervals for τ(x)

Uncertainty quantification — standard errors, intervals, and aggregation.

What happens here

Honest forests / bootstrap-of-little-bags give pointwise intervals — heterogeneity you can actually defend, not just a colourful plot.

Formula
\hat heta(x)\;\pm\;z_{1-\alpha/2}\,\hat\sigma(x)
Reads from the input data Feeds into the final output
Key code
lb, ub = est.effect_interval(X_test, alpha=0.05)

Reference / docs ↗

Discussion on this step (0)
  • No comments on this step yet — be the first.
3

Output · what you get

EconML's Orthogonal Random Forest recovers the heterogeneous effect τ(x) as a function of a covariate — the ORF estimate tracks the true effect closely.
Fig 1EconML's Orthogonal Random Forest recovers the heterogeneous effect τ(x) as a function of a covariate — the ORF estimate tracks the true effect closely.

Figures reproduced from EconML — Microsoft Research (ALICE) — unofficial community showcase; all credit to the original authors.

⚠️ Unofficial community showcase of econml. Not affiliated with the authors; all credit to them.

Double machine learning with a forest final stage: partial out nuisance with flexible learners, then read the conditional effect τ(x) — with valid confidence intervals.

Discussion (2)

  • 2

    CausalForestDML with honest intervals is my default for CATE now. The orthogonalization makes the first-stage choice forgiving.

  • 0

    Residual-on-residual plus forest weights — clean. How are you choosing the number of trees in practice?

    1

    Crank it until the intervals stabilise; 1–2k trees is usually plenty, and bootstrap-of-little-bags handles the inference.