Cross-fit \(\hat\alpha\) from rieszreg plus a cross-fit outcome regression \(\hat\mu\) are the two ingredients of a one-step / DML / TMLE estimator for any linear-functional estimand. This page builds both estimators on the Lalonde NSW dataset in ~50 lines.
Data: Lalonde NSW (treated) + CPS (controls)
The Dehejia-Wahba dataset: NSW-treated job-trainees vs CPS observational controls, outcome re78 (1978 earnings). The standard covariates are age, education, race, marital status, schooling, and pre-period earnings.
The data come from the causaldata package. It is in the workspace’s docs dependency group, so install with uv sync --all-packages --all-extras --all-groups (see Install).
Split the rows into 5 folds. For each fold, fit the outcome model \(\hat\mu\) and the Riesz learner \(\hat\alpha\) on the other four folds. Then predict on the held-out fold at the observed treatment and at \(A = 1\) and \(A = 0\). Every prediction used below comes from models that never saw that row.
The efficient influence function for ATE is \(\mathrm{IF}(O) = m(\hat\mu)(Z) + \hat\alpha(Z)\,(Y - \hat\mu(Z))\), with \(m(\hat\mu)(Z) = \hat\mu(1, X) - \hat\mu(0, X)\). Average it for \(\hat\psi\); its sample variance gives the SE.
psi_ATE = -2139.10
SE = 230.09
95% CI = [-2590.08, -1688.13]
The experimental NSW-only ATE benchmark is roughly $1,794 (Dehejia-Wahba 1999); the NSW-treated vs CPS-controls comparison drifts further from that benchmark when covariates fail to absorb the experimental-vs-observational gap.
TMLE
TMLE solves the same EIF=0 estimating equation as one-step but does it by targeting\(\hat\mu\): fit a one-parameter fluctuation \(\mu^\star(\cdot) = \hat\mu(\cdot) + \epsilon \hat\alpha(\cdot)\) on a “clever covariate” \(\hat\alpha\) to drive the empirical mean of \(\hat\alpha(O)(Y - \mu^\star(O))\) to zero, then take the plug-in \(\hat\psi = (1/n) \sum \mu^\star(1, X) - \mu^\star(0, X)\). For continuous \(Y\) the targeting is a single linear regression of the outcome residual on \(\hat\alpha\).
The targeting step also needs \(\hat\alpha\) at \(A=1\) and \(A=0\). The cross-fitting loop above already produced them (alpha_1, alpha_0).
psi_TMLE = -2016.33
SE = 230.25
95% CI = [-2467.63, -1565.03]
For continuous \(Y\), one-step and TMLE point estimates coincide to \(O_p(n^{-1})\). TMLE’s plug-in is a parameter of an updated regression, which preserves bounds (e.g. probabilities stay in \([0, 1]\) for binary outcomes via the logistic-fluctuation variant — replace the OLS targeting step with a logistic-link single-covariate GLM on the bounded outcome).
Other estimands
The pattern generalizes verbatim. Swap the estimand factory and the \(m(\hat\mu)(Z)\) formula:
Estimand
\(m(\hat\mu)(Z)\)
Riesz factory
ATT
\(A(\hat\mu(1, X) - \hat\mu(0, X))\), then divide by \(\hat{P}(A=1)\)
ATT(...)
TSM at \(a^\star\)
\(\hat\mu(a^\star, X)\)
TSM(level=a_star)
Additive shift \(\delta\)
\(\hat\mu(A + \delta, X) - \hat\mu(A, X)\)
AdditiveShift(delta)
Worked examples for each: rieszboost/examples/ (tsm.py, nhefs_shift.py, lee_schuler/binary_dgp.py).