Tutorials › Propensity Score Matching and Instrumental Variables › Worked Binary-Outcome TMLE Example

Doubly Robust Estimation · Tutorial 324 of 699

Worked Binary-Outcome TMLE Example

Work through how a logistic fluctuation updates initial outcome predictions and yields a targeted average treatment effect for a small binary-outcome dataset.

Advanced 11 min read

What You'll Learn

  • State the causal assumptions needed to interpret a binary-outcome TMLE as an ATE.
  • Calculate the clever covariate and specify the offset logistic fluctuation.
  • Solve and check the empirical targeting equation using a small dataset.
  • Use both targeted potential-outcome predictions to calculate the plug-in ATE.
  • Diagnose numerical and conceptual errors in a hand calculation.
  • Compare the finite-sample TMLE estimate with g-computation and AIPW.

From Initial Fits to a Targeted ATE

For a binary treatment and binary outcome, TMLE turns initial estimates of the treatment mechanism and outcome regression into an estimate of the average treatment effect (ATE). The calculation has a useful discipline: first fit the nuisance quantities, then update the outcome predictions using the observed outcomes, and finally average the updated predictions under treatment and control. The update is designed to satisfy an empirical estimating equation; it is not an arbitrary adjustment to make predicted outcomes look plausible.

This tutorial works through that calculation for a small, hypothetical dataset. The arithmetic is deliberately explicit: a plausible-looking fluctuation coefficient is not enough. The fitted predictions must also satisfy the targeting equation, and the ATE must use predictions under both treatment levels for every individual.

Definition: Let \(A\in\{0,1\}\) be treatment, \(Y\in\{0,1\}\) the outcome, and \(W\) measured covariates. Write \(g(W)=P(A=1\mid W)\) for the propensity score and \(\bar Q(a,W)=E(Y\mid A=a,W)\) for the initial outcome regression. The binary-outcome TMLE uses the clever covariate \(H(A,W)=A/g(W)-(1-A)/(1-g(W))\) in a logistic fluctuation of \(\bar Q(A,W)\). The resulting targeted outcome regression is \(\bar Q^*(a,W)\), and the sample plug-in ATE is \(\hat\psi_{\mathrm{TMLE}}=n^{-1}\sum_{i=1}^n\{\bar Q^*(1,W_i)-\bar Q^*(0,W_i)\}\).

The causal interpretation requires consistency, conditional exchangeability \(Y(a)\perp A\mid W\), and positivity: \(0<P(A=1\mid W)<1\) for covariate values in the target population. The observations are assumed independent for the simple calculation here. These are assumptions about the data-generating process, not facts established by fitting the models. In practice, estimated propensities very near zero or one can make the clever covariate large and the update unstable.

The Logistic Targeting Step

For each observed individual, the initial fitted probability is \(\bar Q(A_i,W_i)\). The fluctuation model treats its logit as an offset and estimates one coefficient, \(\epsilon\), on the clever covariate:

$$ \operatorname{logit}\{\bar Q_\epsilon(A_i,W_i)\} = \operatorname{logit}\{\bar Q(A_i,W_i)\} +\epsilon H(A_i,W_i), \qquad \bar Q_\epsilon=\operatorname{expit}\{\operatorname{logit}(\bar Q)+\epsilon H\}. $$

There is no additional intercept in this fluctuation. For the Bernoulli log-likelihood, differentiating with respect to \(\epsilon\) gives the score \(\sum_i H(A_i,W_i)\{Y_i-\bar Q_\epsilon(A_i,W_i)\}\). When the fluctuation likelihood has a finite interior maximum (equivalently, a finite score root), the fitted coefficient solves the empirical targeting equation:

$$ \sum_{i=1}^n H(A_i,W_i)\{Y_i-\bar Q^*(A_i,W_i)\}=0. $$

After estimating \(\epsilon\), apply the same coefficient to each individual’s predictions under both possible treatment levels. In particular, the relevant covariate for a counterfactual prediction is \(H(a,W_i)=a/g(W_i)-(1-a)/(1-g(W_i))\), not necessarily the clever covariate for the treatment actually received.

Justification: The Bernoulli log-likelihood contribution is \(Y_i\log \bar Q_\epsilon+(1-Y_i)\log(1-\bar Q_\epsilon)\). Its derivative with respect to \(\epsilon\) is \(H_i\{Y_i-\bar Q_\epsilon\}\), by the chain rule for the logistic link. Setting the summed derivative to zero gives the targeting equation. This explains why checking that equation is a direct check of the fitted logistic fluctuation.

Worked Example: A Four-Observation Binary-Outcome TMLE

Consider four hypothetical individuals with one covariate pattern each. The initial fits and observed data are shown below. The initial outcome predictions under the received treatment are specified with enough precision to check the numerical update; the other-treatment predictions are 0.3000. The table rounds the propensity score and initial predictions for readability.

Individual\(A_i\)\(Y_i\)\(g(W_i)\)\(\bar Q(1,W_i)\)\(\bar Q(0,W_i)\)Initial prediction observed
1110.25000.42200.30000.4220
2000.50000.30000.25000.2500
3100.12690.11680.30000.1168
4000.50000.30000.25000.2500

For a transparent numerical check, the initial predictions were constructed so that at \(\epsilon=0.15729\), the observed-treatment predictions are approximately \(0.57806,\ 0.19570,\ 0.31350,\ 0.19570\). For example, individual 1 has \(H_1=1/0.25=4\), so its initial logit is chosen as \(\operatorname{logit}(0.57806)-4(0.15729)\), giving an initial probability of about 0.4220. Individuals 2 and 4 have \(H=-2\); individual 3 has \(H\) approximately \(1/0.1269=7.8802\). Their initial logits are set the same way, subtracting \(\epsilon H_i\) from the target logit.

The score equation can be checked directly. With outcomes \(1,0,0,0\), the four terms are approximately \(4(1-0.57806)\), \((-2)(0-0.19570)\), \(7.8802(0-0.31350)\), and \((-2)(0-0.19570)\). Their sum is \(1.68776+0.39140-2.47045+0.39140\approx0.00011\), up to rounding. A numerical solution is therefore \(\hat\epsilon\approx0.15729\), which rounds to \(0.1573\). The corresponding first prediction rounds to 0.5781 at four decimal places; the other three round to 0.1957, 0.3135, and 0.1957. Keeping extra digits in the score check avoids mistaking rounding differences for a failure of the equation.

Now predict each individual’s outcome under both treatment levels. For individual 1, \(H(0,W_1)=-1/(1-0.25)=-1.3333\), so the targeted control prediction is \(\operatorname{expit}\{\operatorname{logit}(0.3000)-1.3333(0.15729)\}\approx0.2579\). Its targeted treatment prediction is 0.57806. For individual 2, \(H(1,W_2)=2\), giving a targeted treatment prediction \(\operatorname{expit}\{\operatorname{logit}(0.3000)+2(0.15729)\}\approx0.3699\); its targeted control prediction is 0.19570. Individual 4 has the same two predictions. For individual 3, \(H(0,W_3)=-1/(1-0.1269)\approx-1.1453\), giving a targeted control prediction of about 0.2636; its targeted treatment prediction is 0.31350.

The plug-in ATE is the average of the four treatment-control contrasts: \((0.57806-0.2579+0.3699-0.19570+0.31350-0.2636+0.3699-0.19570)/4\approx0.1796\). Thus the estimated average treatment effect is about 0.180, or 18.0 percentage points in the outcome probability scale. It is not the average of the observed outcomes, nor is it obtained by comparing only the treated and control individuals.

Worked Example: A Symmetric Fluctuation With an Exact Root

Suppose four hypothetical individuals have \(g(W_i)=0.5\), initial outcome predictions of 0.5 under both treatment levels, and observed pairs \((A_i,Y_i)=(1,1),(1,0),(0,0),(0,0)\). The clever covariates are \(2,2,-2,-2\). Let \(q_T=\operatorname{expit}(2\epsilon)\) and \(q_C=\operatorname{expit}(-2\epsilon)=1-q_T\). The targeting score is \(2(1-q_T)+2(0-q_T)-2(0-q_C)-2(0-q_C)=6-8q_T\). Setting it to zero gives \(q_T=6/8=0.75\), so \(2\hat\epsilon=\operatorname{logit}(0.75)=\log(3)\) and \(\hat\epsilon=0.5493\). Then \(q_C=0.25\), and the plug-in ATE is \(0.75-0.25=0.5000\), or 50 percentage points. Substituting back gives score \(6-8(0.75)=0\), confirming the update.

Worked Example: Checking One Record’s Update

For a treated individual with \(g(W)=0.20\), \(Y=1\), and initial treated prediction \(\bar Q(1,W)=0.4000\), the clever covariate is \(H=1/0.20=5\). If a fitted fluctuation coefficient is \(\epsilon=0.1000\), then \(\bar Q^*=\operatorname{expit}\{\operatorname{logit}(0.4000)+0.1000(5)\} =\operatorname{expit}(-0.4055+0.5000)\approx0.5236\). This record contributes \(5(1-0.5236)=2.382\) to the empirical score. That contribution is not supposed to be zero by itself: the fitted coefficient makes the sum of contributions across the sample zero. A large contribution can signal that this observation has substantial influence on the targeting step.

Checks, Alternatives, and Limitations

A practical hand calculation should check the following before interpreting the ATE:

  • Propensity range: every fitted \(g(W_i)\) must be strictly between zero and one. Values near the boundaries create large clever covariates and can make the update sensitive to a few observations.
  • Targeting equation: recompute each \(H_i(Y_i-\bar Q^*_i)\) using unrounded predictions, then sum. A materially nonzero sum suggests a wrong sign, an incorrect coefficient, or a numerical fitting problem.
  • Both intervention predictions: calculate \(\bar Q^*(1,W_i)\) and \(\bar Q^*(0,W_i)\) for every individual. Using observed-treatment predictions alone does not produce the plug-in ATE.
  • Probability scale: the logistic update keeps predictions between zero and one, but that fact does not guarantee adequate overlap, correct nuisance estimation, or a credible causal interpretation.

G-computation estimates the ATE by averaging predictions from an outcome model under each treatment level, without this targeting step. AIPW combines outcome predictions and propensity-weighted residuals. TMLE also uses both nuisance fits, but its fluctuation updates the outcome regression and preserves the probability scale for binary outcomes. In finite samples, TMLE and AIPW need not give identical estimates. Neither the targeting equation nor the bounded predictions repair unmeasured confounding, severe positivity violations, or poor nuisance fits. Their large-sample guarantees require the relevant identification and regularity conditions; double robustness is not a promise of good performance in every small sample.

Common mistake: A learner may report a coefficient that looks close to a numerical root, round all fitted probabilities early, and then claim the score is zero. The correction is to retain full precision during fitting and score evaluation, report rounded values only afterward, and verify the summed score using the unrounded predictions. Also distinguish the observed-treatment predictions used in that score from the two counterfactual predictions required for the ATE.

Check Your Understanding

Answer each question, then compare with the brief solutions below.

  1. If \(g(W)=0.25\) and \(A=1\), what is \(H(A,W)\)?
  2. In the symmetric worked example, what score value results from using \(q_T=0.70\) and \(q_C=0.30\)?
  3. Why must the plug-in ATE use both \(\bar Q^*(1,W_i)\) and \(\bar Q^*(0,W_i)\) for each individual?
  4. Does a zero empirical targeting score establish conditional exchangeability? Explain.

Solutions. (1) \(H=1/0.25=4\). (2) The score is \(6-8(0.70)=0.4000\), so this is not the fitted root. (3) The ATE is the sample average of each individual’s predicted treatment outcome minus predicted control outcome; observed-treatment predictions alone do not supply both terms. (4) No. The zero score is an empirical property of the fitted fluctuation, while exchangeability is an untestable causal identification assumption about treatment assignment and potential outcomes conditional on \(W\).

Clinical Biostats