Causal Data Science for Business Analytics
Hamburg University of Technology
Monday, 15. June 2026
S07 went hunting for exogenous variation.
Today we have the opposite luxury: lots of covariates X, and a machine that predicts Y and D beautifully.
Can a black-box predictor hand us a causal effect — with honest error bars?

Same average-effect question as S06 — but the controls go nonparametric. Heterogeneity \(\tau(x)\) is next week.
The deliverable is not a point estimate — it is a point with calibrated uncertainty:
\[\sqrt{n}\,(\hat\tau - \tau) \;\xrightarrow{d}\; \mathcal{N}(0, V)\]
That one line demands three things at once:
A model that only predicts well delivers none of these for \(\tau\) — that is today’s problem.
Plug a flexible learner \(\hat g(X)\) into a naive estimator and two biases leak into \(\hat\tau\):
Regularization bias
To control variance, ML shrinks (lasso penalty, shallow trees). That shrinkage is correlated with \(D\) through \(X\) — so it leaks straight into \(\hat\tau\).
Overfitting bias
Evaluate the nuisance on the same rows used to fit it and the model has partly memorised its own noise — biasing \(\hat\tau\) and shrinking its SE.
ML nuisances converge at a slow \(n^{-1/4}\) rate; a naive plug-in inherits that rate for \(\tau\) — far too slow for a \(\sqrt{n}\) CI.

A shrunk \(\hat g(X)\) leaves structure in the residuals that is correlated with \(D\) — and that leftover slope masquerades as a treatment effect. Orthogonalizing + cross-fitting \(Y\) and \(D\) removes it.
| Symbol | LearnLoop | Role |
| \(D\) |
recommended (0/1)
|
treatment |
| \(Y\) |
exam_score
|
outcome |
| \(X\) | age, region, device, prior courses, baseline score, … | observed covariates |
A naive comparison says +14.03 points. But the recommender targets stronger learners — they would have scored higher anyway. The lift is confounded by \(X\), and the confounding runs through a nonlinear interaction (baseline score × prior courses) that a linear control won’t catch.
The DML recipe
Two ingredients do the real work: orthogonality (kills regularization bias) and cross-fitting (kills overfitting bias). The rest is plumbing.
To get the coefficient on \(D\) in \(Y \sim D + X\), you do not need the full regression. FWL says: it equals the slope of a residual-on-residual regression.
“Partial out \(X\), then read the slope.” We met this in S06 (matching) and S07 (2SLS purges \(D\)). Today we swap OLS for ML in the two partialling-out steps. (Frisch and Waugh 1933; Lovell 1963)
Don’t interpret every coefficient
In \(Y = \tau D + g(X) + \varepsilon\), only \(\tau\) is the target. The function \(g(X)\) is a nuisance — needed for estimation, never interpreted.
This split is liberating: we no longer need a correct, interpretable model of \(g\). We only need to predict it well enough to partial it out.
That is exactly the job ML is good at — and exactly why we can hand \(g\) to a black box without guilt.
Treatment enters linearly; the controls enter arbitrarily — that’s what partially linear means. (Robinson 1988)
\[Y = \tau\, D + g(X) + \varepsilon, \qquad \mathbb{E}[\varepsilon \mid D, X] = 0\] \[D = m(X) + \nu, \qquad \mathbb{E}[\nu \mid X] = 0\]
We partial out the two nuisances:
\[\hat\tau \;=\; \frac{\widehat{\text{Cov}}(\tilde Y,\ \tilde D)}{\widehat{\text{Var}}(\tilde D)}, \qquad \tilde Y = Y - \hat\ell(X),\quad \tilde D = D - \hat m(X)\]
Here \(\hat\ell(X) = \hat{\mathbb{E}}[Y\mid X]\) is the reduced-form outcome predictor — \(\ell = \tau\,m + g\), folding in the indirect path of \(X\) through \(D\). It is DoubleML’s ml_l (not the structural \(g\)).
OLS partials out \(X\) by a linear projection. Nothing requires that.
| Residualize with… | \(\hat{\mathbb{E}}[Y\mid X]\), \(\hat{\mathbb{E}}[D\mid X]\) |
|---|---|
| Linear regression | only linear/additive structure |
| Random forest, lasso, boosting, neural net | arbitrary nonlinearity + interactions |
In LearnLoop the confounding hides in a baseline-score × prior-courses interaction. A linear control misses it; a random forest catches it — and the residual-on-residual slope snaps onto the truth.

Left: treated learners sit higher partly because of \(X\). Right: after ML residualization, the slope of \(\tilde Y\) on \(\tilde D\) is ≈ 5.0 — the partialling-out estimate.
Score (moment function)
A score \(\psi(W;\tau,\eta)\) ties together the data \(W=(Y,D,X)\), the target \(\tau\), and the nuisances \(\eta=(\ell,m)\). Its moment — the population expectation — is zero at the truth: \(\;\mathbb{E}[\psi(W;\tau_0,\eta_0)]=0\), which pins down \(\tau_0\).
Every score here is linear in \(\tau\): \(\;\psi=\psi_a(W;\eta)\,\tau+\psi_b(W;\eta)\), so the root is closed-form, \(\hat\tau=-\mathbb{E}_n[\psi_b]/\mathbb{E}_n[\psi_a]\) (ML \(\hat\eta\) plugged in).
Partialling-out is an exact example of this:
\[\psi=(\tilde Y-\tau\tilde D)\,\tilde D=\underbrace{(-\tilde D^{2})}_{\psi_a}\,\tau+\underbrace{\tilde Y\tilde D}_{\psi_b}\;\Rightarrow\;\tau=\frac{\mathrm{Cov}(\tilde Y,\tilde D)}{\mathrm{Var}(\tilde D)}\]
The two ingredients: orthogonality (a property of this score) and cross-fitting (how \(\hat\eta\) enters it).
Orthogonality
A score is Neyman-orthogonal if slightly-wrong nuisance models barely move the estimate: its sensitivity to nuisance error is zero to first order — the linear (\(\delta\)) term cancels, leaving only a second-order (\(\delta^2\)) effect.
Formally, the moment \(\psi(W;\tau,\eta)\) has zero Gateaux derivative in the nuisance \(\eta=(\ell,m)\) at the truth:
\[\left.\partial_{\eta}\, \mathbb{E}\big[\psi(W;\tau_0,\eta)\big]\right|_{\eta=\eta_0} = 0\]
Consequence: the bias in \(\hat\tau\) depends on the product of the two nuisance errors, not their sum. Two slow \(n^{-1/4}\) errors multiply to \(n^{-1/2}\) — fast enough for a valid CI.

Perturb the nuisances by \(\delta\). The naive score cuts steeply through the truth (slope \(\ne 0\)). The orthogonal score is flat at \(\delta = 0\) — it only feels the error at second order.
The danger: if the same rows train the nuisance and enter the moment for \(\tau\), the model has seen its own noise.
The cross-fitting mantra
A unit must never be predicted by a model that was trained on it.
So we split the sample: fit \(\hat g, \hat m\) on other folds, predict the held-out fold, and rotate until every unit has an out-of-fold prediction. Out-of-fold predictions are independent of each unit’s own noise — the overfitting bias vanishes.

Five folds: each part is predicted by a model trained on the other four — so every unit is predicted out-of-sample exactly once, never by a model that saw it.
In LearnLoop the key knob is the forest’s mtry: too small and it can’t see the interaction — the estimate drifts. Tuning matters because the nuisance quality is what orthogonality leans on.

(a) non-orthogonal → shifted (regularization bias). (b) orthogonal, no cross-fit → over-dispersed (SE too small). (c) orthogonal + cross-fit → centered, correctly scaled \(\mathcal{N}(0,1)\).
Each unit has a per-unit score \(\psi_i=\psi(W_i;\tau,\hat\eta_{-k(i)})\) — its own out-of-fold nuisances — and it is linear in \(\tau\): \(\psi_i=\psi_{a,i}\,\tau+\psi_{b,i}\).
Set the average to zero and solve:
\[\mathbb{E}_n[\psi]=0\quad\Longrightarrow\quad \hat\tau=-\frac{\mathbb{E}_n[\psi_b]}{\mathbb{E}_n[\psi_a]}\qquad\text{(average the pieces, then divide).}\]
Robinson PLR — \(\psi_{a,i}=-\tilde D_i^{2},\ \psi_{b,i}=\tilde Y_i\tilde D_i\):\(\quad\hat\tau=\dfrac{\overline{\tilde Y\tilde D}}{\overline{\tilde D^{2}}}=\dfrac{\mathrm{Cov}(\tilde Y,\tilde D)}{\mathrm{Var}(\tilde D)}\).
Same crank everywhere — only \(\psi\) changes: AIPW (\(\psi_a=-1\)) makes \(\hat\tau=\overline{\psi_b}\) a plain average of scores; IV is a ratio of two averaged scores (Wald).
A good estimator is asymptotically linear: \(\hat\tau-\tau\approx\frac1n\sum_i\phi(W_i)\). The influence function \(\phi_i\) measures how much unit \(i\) tips the estimate; for DML it is the normalized score:
\[\phi_i=-\frac{\psi_i}{\mathbb{E}[\psi_a]}\ \ (\text{mean }0)\quad\Rightarrow\quad \sqrt{n}\,(\hat\tau-\tau)\xrightarrow{d}\mathcal N\!\big(0,\ \mathbb{E}[\phi^2]\big),\qquad \widehat{\mathrm{SE}}=\sqrt{\tfrac{\mathbb{E}_n[\psi^2]}{\mathbb{E}_n[\psi_a]^{2}\,n}}\]
Robinson: \(\phi_i=\dfrac{(\tilde Y_i-\tau\tilde D_i)\,\tilde D_i}{\mathrm{Var}(\tilde D)}\) — exactly the robust SE of the residual-on-residual regression. Same formula for PLR, AIPW, IV; only \(\psi,\psi_a\) change (AIPW \(\psi_a=-1\Rightarrow\widehat{\mathrm{SE}}=\sqrt{\widehat{\mathrm{Var}}(\psi_i)/n}\)).
DML in four steps
Memorise this: only the score \(\psi\) (step 1) changes across models (PLR, AIPW, IV) — steps 2–4 are identical. (Chernozhukov et al. 2018)
Throughout the course the effect is \(\tau\); the DML papers and the DoubleML package write it \(\theta\) (reported as coef) — same object.
Same two equations as PLR — but drop the linearity in \(D\):
\[Y=\mu(D,X)+\varepsilon, \qquad \mathbb{E}[\varepsilon\mid D,X]=0\] \[D=e(X)+\nu, \qquad \mathbb{E}[\nu\mid X]=0\]
Plug-in alone (\(\overline{\hat\mu_1-\hat\mu_0}\)) inherits the regularization bias → need an orthogonal score: AIPW.
\[\psi_i = \underbrace{\big[\hat\mu_1(X_i) - \hat\mu_0(X_i)\big]}_{\text{direct (outcome regression)}} + \underbrace{\frac{D_i\,(Y_i - \hat\mu_1)}{\hat e(X_i)} - \frac{(1-D_i)(Y_i - \hat\mu_0)}{1-\hat e(X_i)}}_{\text{bias correction (propensity-weighted residual)}}\]
\[\widehat{\text{ATE}} = \frac{1}{n}\sum_i \psi_i\]
The outcome model gives a first guess; the propensity-weighted residual repairs whatever the outcome model got wrong. (Robins, Rotnitzky, and Zhao 1994; Bang and Robins 2005)
The per-unit AIPW signal \(\psi_i\) (last slide) is the score’s \(\psi_b\); subtract \(\tau\) for the orthogonal score:
\[\psi=\psi_i-\tau\qquad\Longrightarrow\qquad \psi_b=\psi_i,\quad \psi_a=-1\]
Only the score changed — orthogonality (\(=\) double robustness, next) and cross-fitting carry over verbatim.
Two shots on goal
The AIPW estimate is consistent if either the outcome models \(\mu_1,\mu_0\) or the propensity \(e\) is correctly specified — you don’t need both.
Orthogonality is why: the score’s first-order sensitivity to each nuisance is zero, so an error in one is absorbed as long as the other holds. Double robustness is orthogonality, viewed from the modelling side.

Outcome model misspecified on purpose: Direct is biased (≈ 8.2), IPW-only is centered but noisy, AIPW is centered on 5 and tightest.
![Mirrored densities of the estimated propensity for treated vs control. They overlap across most of [0,1] but tails reach toward 0 and 1; a trimming band at [0.01, 0.99] is marked.](assets/overlap_hist.png)
AIPW divides by \(\hat e\) and \(1-\hat e\) — as \(\hat e\to 0,1\) the weights, and the variance, blow up. Always plot this first; then the question is calibrate or trim (next).
Three responses when AIPW weights \(1/\hat e\) explode as \(\hat e\to 0,1\):
| what it does to \(\hat e\) | estimand | use when | |
|---|---|---|---|
| Trim | drops units with \(\hat e\notin[\alpha,1-\alpha]\) | overlap-ATE \(\neq\) ATE | genuine non-overlap |
| Clip | caps \(\hat e\) at \([\alpha,1-\alpha]\), keeps units | full ATE, capped units biased | quick blunt guard |
| Calibrate | rescales \(\hat e\to\tilde e\) so \(\mathbb{E}[D\mid\tilde e]=\tilde e\) | full ATE, honest weights | ML over-confidence |
Only trim changes the question; clip & calibrate keep the full ATE — clip patches the symptom, calibrate fixes the cause. → Calibrate first. (Ballinari and Bearth 2024; Crump et al. 2009)

\(D\) is endogenous (\(u\) leaks in) — residualize on \(X\) and instrument with \(Z\) (exogeneity on \(Z\), not \(D\)):
\[Y=\tau D+g(X)+\varepsilon,\qquad \mathbb{E}[\varepsilon\mid Z,X]=0\] \[Z=r(X)+\nu,\qquad \mathbb{E}[\nu\mid X]=0\]
\[\psi=(\tilde Y-\tau\tilde D)\,\tilde Z=\underbrace{(-\tilde D\tilde Z)}_{\psi_a}\,\tau+\underbrace{\tilde Y\tilde Z}_{\psi_b}\]
PLR with one change — \(\psi_a=-\tilde D\tilde Z\) instead of \(-\tilde D^2\): instrument the residual. (Robinson 1988)
Step 3 — solve \(\mathbb{E}_n[\psi]=0\):
\[\hat\tau=-\frac{\mathbb{E}_n[\psi_b]}{\mathbb{E}_n[\psi_a]}=\frac{\mathrm{Cov}(\tilde Y,\tilde Z)}{\mathrm{Cov}(\tilde D,\tilde Z)}\qquad(\text{residualized 2SLS / Wald})\]
Step 4 — influence function \(\phi_i=-\psi_i/\mathbb{E}_n[\psi_a]\):
\[\phi_i=\frac{(\tilde Y_i-\tau\tilde D_i)\,\tilde Z_i}{\mathrm{Cov}(\tilde D,\tilde Z)},\qquad \widehat{\text{SE}}=\sqrt{\frac{\mathbb{E}_n[\psi^2]}{\mathbb{E}_n[\psi_a]^2\,n}}\]
Exactly the IV-robust SE — the same Step 4 as PLR/AIPW; only \(\psi,\psi_a\) change.
Drop the constant \(\tau\) — let \(D\) enter \(g\) arbitrarily; keep the instrument equation:
\[Y=g(D,X)+\varepsilon,\qquad \mathbb{E}[\varepsilon\mid Z,X]=0\] \[Z=r(X)+\nu,\qquad \mathbb{E}[\nu\mid X]=0\]
\[\psi=\underbrace{\Gamma^Y}_{\psi_b}+\underbrace{(-\,\Gamma^D)}_{\psi_a}\,\tau,\qquad \Gamma^Y=\text{AIPW}(Z\!\to\!Y),\ \ \Gamma^D=\text{AIPW}(Z\!\to\!D)\]
AIPW with a ratio: \(\psi_a=-\Gamma^D\) (AIPW had \(-1\)). (Chernozhukov et al. 2018)
Each signal is an AIPW pseudo-outcome (weighted by the instrument propensity \(r\)):
\[\Gamma^Y=\big[\mu(1,X)-\mu(0,X)\big]+\frac{Z\,(Y-\mu(1,X))}{r}-\frac{(1-Z)(Y-\mu(0,X))}{1-r}\] \[\Gamma^D=\big[p(1,X)-p(0,X)\big]+\frac{Z\,(D-p(1,X))}{r}-\frac{(1-Z)(D-p(0,X))}{1-r}\]
Step 3 — solve: \(\ \hat\tau_{\text{LATE}}=-\dfrac{\mathbb{E}_n[\psi_b]}{\mathbb{E}_n[\psi_a]}=\dfrac{\mathbb{E}_n[\Gamma^Y]}{\mathbb{E}_n[\Gamma^D]}\) — ITT \(\div\) complier share.
Step 4 — influence function: \(\ \phi_i=\dfrac{\Gamma^Y_i-\tau\,\Gamma^D_i}{\mathbb{E}_n[\Gamma^D]},\qquad \widehat{\text{SE}}=\sqrt{\dfrac{\mathbb{E}_n[\psi^2]}{\mathbb{E}_n[\psi_a]^2\,n}}\)
Same Step 4 machinery; identification (relevance, exclusion, monotonicity) is inherited from S07.
DML assumes \(X\) is enough — it never proves it (orthogonality won’t save you from an unmeasured confounder). So, exactly as in S06, we ask: how strong would an unobserved confounder have to be to overturn the finding? (Cinelli and Hazlett 2020)
Omitting a confounder \(U\) biases the estimate by the product of two errors — and which treatment object \(\alpha\) appears depends on the score:
\[\text{bias}=\mathbb{E}\big[\,\underbrace{(g_0-\hat g)}_{\text{outcome-reg. error}}\;\underbrace{(\alpha_0-\hat\alpha)}_{\text{treatment-side error}}\,\big],\qquad g=\mathbb{E}[Y\mid D,X]\]
| treatment-side \(\alpha\) | so \(cf_d\) is… | |
|---|---|---|
| DML-PLR / -PLIV | residual \(\tilde D\) (∝ the coefficient) | a plain partial \(R^2\) — just sensemakr |
| DML-AIPW / IRM / IIVM | Riesz representer \(D/e-(1-D)/(1-e)\) | the Riesz-norm increase — new |
\(cf_y\) is always a genuine outcome \(R^2\); only the treatment dial changes with the score.
Auto-DML: for a general target, learn the Riesz representer \(\alpha\) from data — the orthogonal correction follows, no hand-derived propensity inversion. (Chernozhukov, Newey, and Singh 2022; Chernozhukov et al. 2021)
Cauchy–Schwarz turns that product into magnitudes × correlation:
\[|\text{bias}|=\underbrace{|\rho|}_{\text{alignment}}\cdot\underbrace{\sqrt{cf_y}}_{\text{outcome}}\cdot\underbrace{\sqrt{\tfrac{cf_d}{1-cf_d}}}_{\text{treatment}}\cdot\,S\]
\(\rho=0\) → no bias even if \(U\) is strong; \(\rho=\pm1\) → maximum bias. We report the worst case \(\rho=1\), so we argue only about strength — and the robustness value (RV) is the strength (at \(\rho=1\)) that drives the bound to 0. (Chernozhukov et al. 2026)

Across the plausible region the bound stays positive — overturning the effect needs a confounder about twice as strong as everything we measured.
The AIPW/IRM ATE (DoubleMLIRM): \(cf_d\) is the Riesz-norm dial. A PLR/PLIV effect would give the plain-sensemakr version.
Next week (S09): stop averaging the score \(\psi_i\) and start projecting it on \(X\) — heterogeneous effects \(\tau(x)\), meta-learners, causal forests. DML also powers DiD in Part V. (Chang 2020)
| Thank you for your attention! | |
|
|
Causal Data Science for Business Analytics | 8. Double Machine Learning