Causal Methods
CHAPTER 07
AIPW

AIPW

Augmented inverse probability weighting combines an outcome regression model and a propensity score model into a doubly robust estimator of the ATE, consistent if either nuisance model is correctly specified.[1] Achieves semiparametric efficiency when both converge at fast enough rates.

IDENTIFICATION SETUP
01: Double robustness

The AIPW estimator is consistent if either the outcome model Q̂(W, X) or the propensity score model ê(X) is correctly specified, not both. This is the key advantage over IPW (which needs only ê) or outcome regression (which needs only Q̂).

02: The DR score

For each unit, the doubly robust pseudo-outcome Ψᵢ augments the outcome regression prediction with an inverse-probability-weighted residual. The ATE is simply the mean of Ψ across units, and it stays consistent if either nuisance model is right, not necessarily both. Regressing Ψ on X rather than averaging it is what turns the same score into a CATE estimator, the DR learner.

03: Semiparametric efficiency

When both nuisance models converge at rate n^{−1/4}, the AIPW estimator achieves the semiparametric efficiency bound, the smallest asymptotic variance possible for any estimator of the ATE under conditional ignorability.

AIPW SCORE CONSTRUCTION

XCovariatesQ̂E[Y | A, W]êE[A | W]ΨDR scoreATEAverage of Ψconsistent if Q̂ or ê is correct
Q̂(W,X)Outcome regression: predicted Y given treatment and covariates
ê(X)Propensity score: predicted probability of treatment
ΨDR pseudo-outcome: augments Q̂ with IPW residual correction
ATEMean of Ψ, consistent if Q̂ or ê is correctly specified
Doubly robust pseudo-outcome (per unit i)
Ψᵢ = Q̂(1, Xᵢ) − Q̂(0, Xᵢ) + Wᵢ(Yᵢ − Q̂(1,Xᵢ)) / ê(Xᵢ) − (1−Wᵢ)(Yᵢ − Q̂(0,Xᵢ)) / (1−ê(Xᵢ))
ATE = mean(Ψ)  ·  regressing Ψ on X instead yields a CATE, the DR learner[4]
ASSUMPTIONS
Conditional ignorabilityrequired

Given X, treatment is independent of potential outcomes. Double robustness relaxes the requirement that one model is correctly specified, but it does not relax this fundamental identification assumption.

HOW TO TEST

Theoretical argument. The same unobserved confounding concern as IPW or matching applies here.

Overlaprequired

Every unit must have a nonzero probability of treatment. The IPW correction term in the DR score divides by ê(X) and 1−ê(X), values near 0 or 1 produce extreme weights that inflate variance and bias.

HOW TO TEST

Inspect cross-fitted propensity score distribution. Trim units with PS < 0.05 or > 0.95. Report sensitivity to the trimming threshold.

At least one nuisance model correctrequired

Double robustness guarantees consistency if either Q̂ or ê is correctly specified. If both are misspecified, AIPW is biased. In practice, using flexible ML for both models substantially reduces the risk of misspecification.

HOW TO TEST

Check nuisance model fit via cross-validated RMSE (Q̂) and AUC (ê). Use multiple learner types and inspect sensitivity of the ATE to learner choice.

Nuisance rate conditionsrecommended

For semiparametric efficiency, both nuisance models must converge at rate n^{−1/4}. This is satisfied by lasso and random forests under regularity conditions. Cross-fitting ensures this rate condition applies to the final estimator.

HOW TO TEST

Use flexible ML learners. Compare ATE across learner types. Large differences suggest one or both nuisance models are not converging fast enough.

DATA REQUIREMENTS

Binary treatment

AIPW in its standard form handles binary treatment W ∈ {0, 1}. Extensions exist for multi-valued and continuous treatments via generalized propensity scores, but the implementation is substantially more complex.

Sufficient overlap

AIPW is more sensitive to overlap violations than IPW because the augmentation term amplifies extreme weights. Trim or clip propensity scores before estimation and always report the trimming threshold.

Sample size

Cross-fitting requires enough observations in each fold for stable nuisance estimates. A minimum of ~500 observations is practical. With very small samples, consider a single cross-fit split or targeted learning (TMLE).

01_data_prep.R
library(tidyverse)

data <- read_csv("observational_data.csv")

# AIPW convention: Y = outcome, A = treatment, W = covariates
Y <- data$outcome
A <- data$treatment
W <- data |>
  select(age, income, education, region, employment,
         starts_with("covar_")) |>
  as.data.frame()

# Check overlap, AIPW is sensitive to extreme propensity scores
ps_model <- glm(A ~ ., data = W, family = binomial)
ps <- fitted(ps_model)

# Flag extreme scores
cat("PS < 0.05:", sum(ps < 0.05), "\n")
cat("PS > 0.95:", sum(ps > 0.95), "\n")

# Trim to common support if needed
keep <- ps > 0.05 & ps < 0.95
cat("Units retained after trimming:", sum(keep), "/", length(keep), "\n")
ESTIMATION

Two routes to the same estimate. The first computes the doubly robust pseudo-outcome explicitly,[1] which is worth doing once so the score stops being a black box. The second reaches the identical AIPW score through DoubleML's interactive regression model, which handles the cross-fitting for you.[3] Funk et al. (2011) is the applied introduction written for health researchers.[2]

AIPW: EXPLICIT PSEUDO-OUTCOME

02_aipw.R
library(AIPW)
library(SuperLearner)

# AIPW with SuperLearner for nuisance functions
# SuperLearner ensembles multiple learners via cross-validation

sl_libs <- c("SL.ranger", "SL.glmnet", "SL.mean")

aipw_obj <- AIPW$new(
  Y = Y,
  A = A,               # binary treatment
  W = W,               # covariate data frame
  Q.SL.library = sl_libs,       # outcome model E[Y|A,W]
  g.SL.library = sl_libs,       # propensity model E[A|W]
  k_split = 5,               # 5-fold cross-fitting
  verbose = TRUE
)

aipw_obj$
  stratified_fit()$             # fit nuisance models
  summary()                     # ATE and RR estimates

# ATE with 95% CI
aipw_obj$result

AIPW VIA THE DOUBLEML IRM SCORE

03_doubleml_irm.R
library(DoubleML)
library(mlr3)
library(mlr3learners)

# The same AIPW score via DoubleML's IRM (Interactive Regression Model).
# IRM's ATE score IS the doubly robust score computed above,
# with cross-fitting and inference handled for you.

dml_data <- DoubleMLData$new(
  data = cbind(W, outcome = Y, treatment = A),
  y_col = "outcome",
  d_cols = "treatment",
  x_cols = colnames(W)
)

irm <- DoubleMLIRM$new(
  data = dml_data,
  ml_g = lrn("regr.ranger", num.trees = 200),      # E[Y|D,X]
  ml_r = lrn("classif.ranger", predict_type="prob"), # E[D|X]
  n_folds = 5,
  score = "ATE",      # uses doubly robust / AIPW score
  normalize_ipw = TRUE  # stabilized weights
)

irm$fit()
irm$summary()
irm$confint()
DIAGNOSTICS

Nuisance model fit

Cross-validated RMSE for the outcome model and AUC for the propensity model. Poor fit in either nuisance model degrades the DR estimator, if both are misspecified, double robustness is no protection.

Propensity score overlap

Overlay histograms of cross-fitted PS for treated and control. Substantial non-overlap or extreme scores near 0 or 1 indicate trimming is needed. The IPW correction amplifies extreme PS values.

EIF mean check

The efficient influence function (EIF) should have mean zero if the nuisance models are well-specified. A nonzero mean indicates systematic bias, typically from a misspecified outcome or propensity model.

Sensitivity to trimming

Re-estimate the ATE at different propensity trimming thresholds (0.01, 0.05, 0.10). Stable ATE across thresholds supports robustness; instability indicates the estimate depends heavily on extreme-PS units.

04_diagnostics.R
library(AIPW)
library(tidyverse)

# 1. Nuisance model fit, check Q and g model performance
# For AIPW objects: access cross-fitted predictions
summary(aipw_obj)   # reports nuisance model performance by fold

# 2. Overlap / propensity score distribution
ps <- aipw_obj$obs.est$g.pred  # cross-fitted PS estimates
hist(ps, breaks = 40,
     main = "Cross-fitted propensity scores",
     xlab = "P(A=1|W)")
abline(v = c(0.05, 0.95), lty = 2, col = "red")

# 3. Efficient influence function (EIF) diagnostics
# The EIF should have mean zero and be uncorrelated with X
eif <- aipw_obj$obs.est$aipw.eif1
cat("EIF mean:", round(mean(eif), 5), "\n")
# If far from zero, nuisance models are misfitting

# 4. Sensitivity to propensity trimming
for (trim in c(0.01, 0.05, 0.10)) {
  keep <- ps > trim & ps < 1 - trim
  cat("Trim:", trim, "| N:", sum(keep),
      "| ATE:", round(mean(eif[keep]), 4), "\n")
}
OUTPUT INTERPRETATION

My AIPW ATE differs from IPW: which should I trust?

AIPW is generally preferred. If both nuisance models are well-specified, AIPW is more efficient than IPW. If the propensity model is misspecified, the outcome model augmentation in AIPW provides a correction that IPW lacks. The AIPW estimate is consistent under a weaker requirement, you need either model right, not both.

What does it mean for one nuisance model to be 'correctly specified'?

In a nonparametric setting, a model is correctly specified if it converges to the true conditional expectation as sample size grows. With flexible ML learners, random forests, lasso, this is plausible under smoothness or sparsity conditions. It does not require the model to be exactly right in small samples, only that it gets better with more data.

Which nuisance model is actually doing the work?

Double robustness protects you if one model is wrong, but it does not tell you which one was. Compare the AIPW estimate against a pure outcome-regression estimate (g-computation) and a pure weighting estimate (IPW) on the same data. If AIPW sits close to one and far from the other, the near one is carrying the estimate, and the far one is the misspecified half worth investigating.

Should I use AIPW, DML, or causal forest for my analysis?

Use AIPW when you want a doubly robust ATE estimate and interpretability of which model is doing the work. Use DML (PLR) when treatment is continuous or you want the Neyman-orthogonal framework explicitly. Use causal forest when HTE is the primary interest and you want nonparametric CATE estimates with honest confidence intervals. For a rigorous analysis, estimate all three and compare, agreement across methods strengthens credibility.

REFERENCES
[1]

Doubly robust estimation in missing data and causal inference models

Bang, H. & Robins, J. M. (2005)

Biometrics, 61(4), 962–973

doi →
[2]

Doubly robust estimation of causal effects

Funk, M. J., Westreich, D., Wiesen, C., Stürmer, T., Brookhart, M. A. & Davidian, M. (2011)

American Journal of Epidemiology, 173(7), 761–767

doi →
[3]

Double/debiased machine learning for treatment and structural parameters

Chernozhukov, V., Chetverikov, D., Demirer, M., Duflo, E., Hansen, C., Newey, W. & Robins, J. (2018)

The Econometrics Journal, 21(1), C1–C68

doi →
[4]

Towards optimal doubly robust estimation of heterogeneous causal effects

Kennedy, E. H. (2023)

Electronic Journal of Statistics, 17(2), 3008–3049

doi →

Built as a learning tool and working reference for developing knowledge and coding practices across causal inference and causal ML. The author is actively building expertise, and therefore this should not be taken as an authoritative source. Drafted with assistance from Claude (Anthropic) for prose, code scaffolding, and reference checking; method selection, technical claims, and every citation above were reviewed by the author.