Tutorials › Propensity Score Matching and Instrumental Variables › Common TMLE Implementation Errors

Doubly Robust Estimation · Tutorial 321 of 699

Common TMLE Implementation Errors

Learn to audit a TMLE implementation from its clever covariate and fluctuation scale through its targeted predictions and final plug-in estimate.

Advanced 12 min read

What You'll Learn

  • Construct the signed clever covariate for a binary-treatment ATE and identify what goes wrong when an arm is omitted.
  • Check whether the fluctuation update is on the correct link scale for the outcome.
  • Distinguish initial outcome predictions from predictions after targeting.
  • Verify that a targeting score equation is supported by the fitted model and a finite interior maximum.
  • Apply cross-validation consistently when nuisance predictions are out of fold.
  • Diagnose implementation errors with numerical checks and clear failure rules.

Why Implementation Details Matter

TMLE combines an initial estimate of the outcome regression with an update designed to reduce bias for a particular estimand. This targeting step is precise: its covariate, link scale, and predictions must correspond to the estimand and model being fitted. A program can return plausible-looking probabilities and still fail to carry out the intended update—for example, if it targets only one treatment arm or reports the initial regression as though it had been targeted.

This tutorial focuses on practical checks for the binary-treatment average treatment effect (ATE). Let \(A\in\{0,1\}\) be treatment, \(W\) measured covariates, and \(Y\in\{0,1\}\) the outcome. Write \(g(W)=P(A=1\mid W)\) for the propensity score and \(Q(a,W)=E(Y\mid A=a,W)\) for the outcome regression. The target is \(\psi=E\{Q(1,W)-Q(0,W)\}\), interpreted as the population average causal effect under consistency, conditional exchangeability given \(W\), and positivity: \(0<g(W)<1\) for covariate values in the target population. Estimating it also requires suitable nuisance estimation and sampling conditions; targeting does not repair unmeasured confounding or a violation of positivity.

Definition: For the binary-treatment ATE, the signed clever covariate is \(H(A,W)=A/g(W)-(1-A)/\{1-g(W)\}\). A logistic fluctuation with coefficient \(\epsilon\) updates the observed-treatment prediction as \(\operatorname{logit}Q^*(A,W)=\operatorname{logit}Q(A,W)+\epsilon H(A,W)\). The targeted plug-in estimate is the sample average of \(Q^*(1,W)-Q^*(0,W)\), not the average of the observed-treatment predictions.

Audit the Clever Covariate Before Fitting

The two terms in \(H(A,W)\) represent the two treatment arms. For a treated observation, \(H=1/g(W)\); for a control observation, \(H=-1/\{1-g(W)\}\). The negative sign is part of the ATE contrast. A frequent coding error is to use only \(A/g(W)\). That quantity is zero for every control, so it cannot contribute the residual information needed to target the control mean.

A useful first diagnostic is to compute the covariate for a treated and a control observation by hand, then compare those values with the values passed to the fluctuation fit. Also check that propensity predictions are aligned to the same rows as \(A,Y,W\), are probabilities rather than logits, and are strictly between zero and one. Clipping extreme estimated propensities may sometimes be a prespecified numerical or statistical choice, but it changes the fitted covariates and should be recorded; it does not establish that positivity holds.

Worked Example: Finding an Omitted Control-Arm Term

Suppose one treated observation has \(g(W)=0.25\), \(Y=1\), and initial observed-treatment prediction \(Q(A,W)=0.30\). A control observation has \(g(W)=0.25\), \(Y=0\), and \(Q(A,W)=0.20\). Compute their signed clever covariates and their contributions to the logistic fluctuation score at \(\epsilon=0\).

For the treated observation, \(H=1/0.25=4\), and its score contribution is \(H\{Y-Q(A,W)\}=4(1-0.30)=2.8\).

For the control observation, \(H=-1/(1-0.25)=-1.3333\), and its contribution is \((-1.3333)(0-0.20)=0.2667\). The two contributions sum to \(3.0667\). If the implementation instead uses \(A/g(W)\), the control covariate and its score contribution are both set to zero. That is not the ATE fluctuation: it has discarded the control-arm residual contribution.

Check the Scale of the Update

For binary outcomes, the usual fluctuation is logistic with the initial prediction as an offset. It moves the prediction on the log-odds scale, then transforms it back to a probability. Adding \(\epsilon H\) directly to a probability is a different model: it can produce values outside \([0,1]\) and is not the logistic fluctuation. Conversely, using a logit update for an unbounded continuous outcome without a suitable bounded-outcome model is a scale mismatch. The fluctuation model must match the outcome scale and the procedure being implemented.

Worked Example: Logistic Offset Versus Probability-Scale Addition

For an observation with initial probability \(Q(A,W)=0.20\), suppose \(H(A,W)=2\) and a fitted fluctuation coefficient is \(\epsilon=0.10\). Calculate the updated probability under the logistic fluctuation and compare it with the incorrect probability-scale addition.

The initial logit is \(\log\{0.20/(1-0.20)\}=\log(0.25)=-1.3863\). The offset update adds \(\epsilon H=0.20\), giving a new logit of \(-1.1863\). Therefore, \[ Q^*(A,W)=\operatorname{expit}(-1.1863) =\frac{1}{1+\exp(1.1863)} \approx 0.234 \] as a probability.

Adding \(0.20\) directly to the initial probability would give \(0.20+0.20=0.40\). That is not the specified logistic update; the difference is substantial. The value \(0.234\) follows from the assumed \(\epsilon\) and \(H\); it does not by itself show that \(\epsilon=0.10\) is the coefficient the data would estimate.

Keep Initial, Targeted, and Counterfactual Predictions Distinct

The initial regression predictions \(Q(1,W_i)\) and \(Q(0,W_i)\) are inputs to the update. The targeted predictions \(Q^*(1,W_i)\) and \(Q^*(0,W_i)\) are the updated quantities used in the plug-in estimate. For the signed, one-parameter logistic fluctuation, compute both counterfactual predictions using the same fitted \(\epsilon\): \[ \operatorname{logit}Q^*(1,W_i)=\operatorname{logit}Q(1,W_i)+\epsilon/g(W_i), \qquad \operatorname{logit}Q^*(0,W_i)=\operatorname{logit}Q(0,W_i)-\epsilon/\{1-g(W_i)\}. \] Do not update only the prediction corresponding to the observed treatment and then treat it as though both counterfactual predictions were available. Each individual contributes both targeted counterfactual predictions to the plug-in ATE.

Different valid fluctuation parameterizations exist. For example, an arm-specific update can use separate coefficients and arm-specific clever covariates. Its predictions and coefficient structure differ from a one-parameter signed update. Code should implement one stated parameterization consistently: the covariate, the fitted coefficient or coefficients, the counterfactual update, and the final estimate must all match. Combining the covariate from one parameterization with the prediction formula from another is not a harmless change in notation.

Worked Example: Computing the ATE From Targeted Predictions

Suppose two equally weighted individuals have \(g(W_i)=0.50\). Their initial predictions are \(Q(1,W_1)=0.20,\ Q(0,W_1)=0.40\) and \(Q(1,W_2)=0.60,\ Q(0,W_2)=0.30\). For illustration, take a coefficient \(\epsilon=0.10\) from a completed fluctuation fit. Compute the initial and targeted plug-in ATEs.

Because \(g=0.50\), the treated prediction logit increases by \(0.10/0.50=0.20\), while the control prediction logit decreases by \(0.10/(1-0.50)=0.20\).

For individual 1, the targeted treated prediction is \(\operatorname{expit}\{\operatorname{logit}(0.20)+0.20\} =\operatorname{expit}(-1.1863)\approx0.234\). The targeted control prediction is \(\operatorname{expit}\{\operatorname{logit}(0.40)-0.20\} =\operatorname{expit}(-0.6055)\approx0.353\).

For individual 2, the targeted treated prediction is \(\operatorname{expit}\{\operatorname{logit}(0.60)+0.20\} =\operatorname{expit}(0.6055)\approx0.647\). The targeted control prediction is \(\operatorname{expit}\{\operatorname{logit}(0.30)-0.20\} =\operatorname{expit}(-1.0473)\approx0.260\). Thus the targeted estimate is \[ \hat\psi^*=\frac{(0.234-0.353)+(0.647-0.260)}{2} =\frac{-0.119+0.387}{2}=0.134. \] The initial plug-in estimate is \[ \hat\psi=\frac{(0.20-0.40)+(0.60-0.30)}{2} =\frac{-0.20+0.30}{2}=0.050. \] The change from \(0.050\) to \(0.134\) is consistent with the specified update. This example treats \(\epsilon=0.10\) as supplied; it is not a claim that this value solves the score equation for these two observations.

What the Score Check Does—and Does Not—Establish

For a Bernoulli outcome and the logistic offset model, let \(Q_\epsilon(A,W)=\operatorname{expit}\{\operatorname{logit}Q(A,W)+\epsilon H(A,W)\}\). The derivative of the log likelihood with respect to \(\epsilon\) is \[ \frac{\partial \ell(\epsilon)}{\partial\epsilon} =\sum_{i=1}^{n}H(A_i,W_i)\{Y_i-Q_\epsilon(A_i,W_i)\}. \] Consequently, if the likelihood has a finite interior maximizer, its derivative there is zero and the empirical targeting equation holds: \[ \frac{1}{n}\sum_{i=1}^{n}H(A_i,W_i)\{Y_i-Q^*(A_i,W_i)\}=0. \] This is a useful implementation check: evaluate the score using the same rows, covariates, and targeted observed-treatment predictions used in the fit. It should be close to zero up to numerical tolerance when the stated conditions hold.

A zero score is not guaranteed. A finite maximizing coefficient may fail to exist, including under separation. For instance, consider one treated observation with \(Y=1\), one control observation with \(Y=0\), initial predictions both \(0.50\), and propensity scores both \(0.50\). Their signed covariates are \(2\) and \(-2\). At every finite \(\epsilon\), the treated fitted probability is below 1 and the control fitted probability is above 0, so both likelihood contributions increase as \(\epsilon\) increases. The likelihood approaches its supremum as \(\epsilon\) tends to positive infinity; no finite coefficient attains it and the finite score is not zero. A program that reports convergence merely because an optimizer stopped is not evidence of a finite interior solution.

When a fit fails or the coefficient grows without bound, record the failure and inspect the score, fitted probabilities, and optimizer status. A penalty or other numerical safeguard may be used only if it is explicitly specified and appropriate to the analysis; it changes the fitting procedure, so do not report the unmodified score equation as exactly solved. Likewise, extreme clever covariates can signal practical positivity problems. Truncation or stabilization should be documented rather than silently inserted as a coding fix.

Cross-Validation and a Compact Audit

In cross-validated TMLE, predictions used for targeting and estimation must respect the chosen fold structure. If nuisance fits generate out-of-fold predictions, retain the row-to-fold mapping and use the designated out-of-fold predictions consistently; do not accidentally replace them with in-sample predictions in one step of the calculation. The targeting fit, counterfactual predictions, and aggregation must follow the particular cross-validated TMLE construction being used. Mixing fold-specific predictions with an unrelated full-sample update can yield a number without implementing that estimator.

Before interpreting an estimate, check the following in order:

  • Confirm the treatment coding, outcome coding, row alignment, and definition of the target population.
  • Recompute \(H(A_i,W_i)\) for selected treated and control observations; check both signs and both denominators.
  • Verify the offset is on the intended scale, and confirm all binary-outcome predictions remain probabilities after transformation.
  • Check that the fluctuation fit returned a finite estimate and inspect convergence and score diagnostics rather than relying only on a software success flag.
  • Generate both targeted counterfactual predictions for each target-population row, then calculate the plug-in contrast from those predictions.
  • Keep cross-validation folds and prediction provenance intact; compare the reported estimate with a separately coded calculation from stored predictions.

TMLE's targeting step is distinct from simply reporting the initial outcome-regression estimate and from AIPW's direct use of an influence-function correction. Those approaches can be compared as separate estimators, but neither is a reason to skip the TMLE update when reporting a TMLE estimate. Targeting also does not guarantee good finite-sample behavior: poor overlap, unstable nuisance fits, or a failed fluctuation can remain consequential. Variance estimation and confidence intervals require their own procedures and are not established just by a successful targeting score check.

Key takeaway: An implementation is coherent only when its clever covariate, fluctuation scale, fitted coefficient, targeted counterfactual predictions, and plug-in estimand all belong to the same specified TMLE. A plausible final number cannot substitute for checking those links.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. For a control observation with \(g(W)=0.20\), what is the signed clever covariate? What error results from using \(A/g(W)\) alone?
  2. A binary-outcome fluctuation adds \(\epsilon H=0.15\) to the initial logit. If the initial probability is \(0.50\), what is the targeted probability? Why is \(0.65\) not the logistic-update result?
  3. Why can a numerical optimizer fail to produce a finite coefficient even when the likelihood appears to improve steadily?
  4. What predictions enter the plug-in ATE after targeting, and what should be checked when the nuisance fits are cross-validated?

Solutions. (1) \(H=-1/(1-0.20)=-1.25\). Using \(A/g(W)\) sets the control covariate to zero and omits its contribution. (2) The initial logit is zero, so the updated probability is \(\operatorname{expit}(0.15)=1/(1+\exp(-0.15))\approx0.537\). The value \(0.65\) comes from adding on the probability scale, not updating on the logit scale. (3) Separation can make the likelihood increase toward a supremum as the coefficient tends to infinity, without attaining a finite maximum; convergence status alone does not prove a finite solution. (4) Use both targeted predictions \(Q^*(1,W_i)\) and \(Q^*(0,W_i)\) for each target-population row, then average their differences. Preserve the fold mapping and consistently use the predictions and targeting procedure specified for the cross-validated estimator.

Clinical Biostats