All imports used by the experiments are collected at the top of ch03_listings.py:
To see the gap between association and effect we need a simulator in which the truth is known. the companion book example uses three covariates drawn uniformly from . Treatment is assigned with , where is the logistic function and unless stated otherwise. The control outcome is and the effect is , so the true ATE is exactly . The same covariates and that make a unit more likely to be treated also raise its outcome. The term is deliberately nonlinear: it is a covariate effect that a linear adjustment cannot represent.
All imports used by the experiments are collected at the top of ch03_listings.py:
The naive difference in means estimates the ATE as 3.285 when the truth is 1.000. The bias is 2.285, and the standard deviation across data sets is only 0.128, so the estimator is not noisy; it is precisely wrong. More data will not help. Adding the covariates to a linear regression (the row “OLS on (T, X)”) reduces the bias to 1.567 but does not remove it, because the confounding runs partly through and the model is linear in . This is the common case in practice: adjustment with the wrong functional form leaves residual confounding that looks like a modest improvement.
The last four rows are all correct on average. They differ in variance. Outcome regression with the squared features (which contains the true basis) has standard deviation 0.051 and AIPW with fitted nuisances 0.052. Inverse-propensity weighting with the true propensity has 0.268, five times larger, and the self-normalized (Hajek) version has 0.177. The next two sections explain where those numbers come from.
Continue with the book
Explore the full treatment, worked examples, and exercises in Applied AI Under Uncertainty.
Companion article for Applied AI Under Uncertainty, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.
