Tutorials › Propensity Score Matching and Instrumental Variables › Worked AIPW Calculation for a Binary Treatment

Doubly Robust Estimation · Tutorial 310 of 699

Worked AIPW Calculation for a Binary Treatment

Calculate a binary-treatment AIPW estimate by hand, interpret its components, and identify checks that matter before giving it a causal interpretation.

Advanced 10 min read

What You'll Learn

  • Write the AIPW estimator for the average treatment effect with binary treatment.
  • Calculate treated and control residual corrections using the appropriate outcome predictions.
  • Average individual contributions and interpret the estimate in outcome units.
  • Distinguish the AIPW estimate from the outcome-regression plug-in estimate.
  • Check the assumptions and data inputs needed for a causal interpretation.
  • Recognize how extreme propensity predictions can make a hand calculation unstable.

From Predictions to an AIPW Estimate

An augmented inverse-probability weighted (AIPW) calculation combines two kinds of predictions for each person: a propensity score, which is the predicted probability of receiving treatment given covariates, and two treatment-specific outcome predictions. The calculation then adds a residual correction for the outcome actually observed. Working through the contributions one person at a time makes the estimator easier to verify and helps reveal when a small number of observations dominate the result.

Let \(A_i\) indicate treatment for person \(i\), with \(A_i=1\) for treated and \(A_i=0\) for untreated. Let \(Y_i\) be that person’s observed outcome and \(X_i\) their covariates. Write \(Y_i(1)\) and \(Y_i(0)\) for the potential outcomes under treatment and control. The target is the average treatment effect (ATE), \(E[Y(1)-Y(0)]\), for the population represented by the data. The observed outcome is \(Y_i=A_iY_i(1)+(1-A_i)Y_i(0)\), by consistency.

Definition: For each person, let \(\hat e(X_i)\) be the predicted propensity score, and let \(\hat m_1(X_i)\) and \(\hat m_0(X_i)\) be the predicted mean outcomes under treatment and control. The AIPW contribution is the difference between the two predicted outcomes, plus a weighted residual correction for the outcome observed. The sample AIPW estimate is the average of these contributions.
$$ \hat\tau_{\mathrm{AIPW}} = \frac{1}{n}\sum_{i=1}^{n} \left[ \hat m_1(X_i)-\hat m_0(X_i) +\frac{A_i}{\hat e(X_i)}\{Y_i-\hat m_1(X_i)\} -\frac{1-A_i}{1-\hat e(X_i)}\{Y_i-\hat m_0(X_i)\} \right]. $$

The first part, \(\hat m_1(X_i)-\hat m_0(X_i)\), is the predicted treatment-control contrast for person \(i\). If that person was treated, the residual \(Y_i-\hat m_1(X_i)\) corrects the treated prediction; if untreated, \(Y_i-\hat m_0(X_i)\) corrects the control prediction. The indicators \(A_i\) and \(1-A_i\) ensure that only the residual from the observed treatment group is used. The propensity weights scale that residual correction. They do not create observations of the unobserved potential outcome.

For the estimate to have a causal interpretation, the standard identification conditions are required: consistency and no interference between people; conditional exchangeability, \((Y(1),Y(0))\) independent of \(A\) given \(X\); and positivity, \(0<P(A=1\mid X)<1\) for covariate values in the target population. In addition, the nuisance predictions must be estimated in a way that supports the desired statistical properties. The data table alone cannot establish exchangeability or rule out unmeasured confounding. For the arithmetic, check that every propensity prediction is strictly between zero and one and that predictions and outcomes refer to the same person and covariate values.

Why the Residual Correction Works

The structure of the estimator can be justified by considering its population counterpart. If the propensity model gives the true \(e(X)=P(A=1\mid X)\), then, conditional on \(X\), the expected treated residual correction is \(E[Y(1)-m_1(X)\mid X]\). The expected control correction before its minus sign is \(E[Y(0)-m_0(X)\mid X]\). Adding these to \(m_1(X)-m_0(X)\) gives \(E[Y(1)-Y(0)\mid X]\). Averaging over \(X\) gives the ATE.

$$ \begin{aligned} &E\left[ m_1(X)-m_0(X) +\frac{A}{e(X)}\{Y-m_1(X)\} -\frac{1-A}{1-e(X)}\{Y-m_0(X)\} \;\middle|\; X \right]\\ &=m_1(X)-m_0(X) +E[Y(1)-m_1(X)\mid X] -E[Y(0)-m_0(X)\mid X]\\ &=E[Y(1)-Y(0)\mid X]. \end{aligned} $$

This calculation uses consistency and exchangeability to relate observed residuals in each treatment group to the corresponding potential outcomes. Alternatively, if both outcome predictions equal their conditional means, the conditional expected residuals are zero, so the expected correction terms vanish. These population arguments explain the estimator’s augmentation; they do not guarantee that a particular small-sample estimate is stable or that the identification assumptions hold.

Worked Example: Calculating Every Contribution

Consider six hypothetical people. The outcome is a symptom score in points. The table gives the observed treatment, observed score, predicted propensity, and predictions under treatment and control.

Person\(A_i\)\(Y_i\) (points)\(\hat e(X_i)\)\(\hat m_1(X_i)\)\(\hat m_0(X_i)\)
1180.5074
2030.4062
3160.6085
4050.5074
51100.8096
6020.2552

For person 1, the predicted contrast is \(7-4=3\) points. Since this person was treated, use the treated residual \(8-7=1\), weighted by \(1/0.50=2\). The contribution is \(3+2(1)=5\) points. For person 2, the predicted contrast is \(6-2=4\); the control residual is \(3-2=1\), so the contribution is \(4-1/(1-0.40)=4-1.6667=2.3333\) points.

For person 3, the contribution is \(8-5+(6-8)/0.60=3-3.3333=-0.3333\) points. For person 4, it is \(7-4-(5-4)/(1-0.50)=3-2=1\) point. For person 5, it is \(9-6+(10-9)/0.80=3+1.25=4.25\) points. For person 6, the control residual is \(2-2=0\), so the contribution is \(5-2=3\) points.

Average the six contributions:

$$ \hat\tau_{\mathrm{AIPW}} = \frac{5+2.3333-0.3333+1+4.25+3}{6} = \frac{15.25}{6} = 2.542\text{ points}. $$

Under the stated causal assumptions, this is an estimated average treatment effect of 2.542 symptom-score points in the population represented by the data. The number is not the treatment effect for every person. For comparison, averaging the six predicted contrasts alone gives \((3+4+3+3+3+3)/6=3.167\) points, which is the outcome-regression plug-in estimate. The residual corrections shift the AIPW estimate away from that plug-in value in this sample.

Binary Outcomes and Risk Differences

The same calculation applies when \(Y\) is binary. In that case, the outcome predictions are predicted probabilities, and the ATE is measured as a risk difference. Each contribution can fall outside the interval from \(-1\) to \(1\); the AIPW contribution is a corrected estimating quantity, not an individual’s predicted probability or individual treatment effect.

Worked Example: AIPW With a Binary Outcome

Suppose four hypothetical people have a binary outcome, where 1 indicates that an event occurred. Their predictions and observed data are:

Person\(A_i\)\(Y_i\)\(\hat e(X_i)\)\(\hat m_1(X_i)\)\(\hat m_0(X_i)\)
1110.500.750.25
2000.500.600.20
3000.250.400.10
4010.750.800.30

Person 1 contributes \(0.75-0.25+(1-0.75)/0.50=1.000\). Person 2 contributes \(0.60-0.20-(0-0.20)/(1-0.50)=0.800\). Person 3 contributes \(0.40-0.10-(0-0.10)/(1-0.25)=0.4333\). Person 4 contributes \(0.80-0.30-(1-0.30)/(1-0.75)=-2.300\).

Thus the average contribution is \((1.000+0.800+0.4333-2.300)/4=-0.01667\). This small hypothetical sample produces an estimated risk difference of about \(-1.67\) percentage points. It does not establish that treatment reduces risk: the estimate is noisy, and its causal interpretation still depends on the assumptions. Person 4’s contribution is especially large in magnitude because the control residual is divided by \(1-0.75=0.25\).

Checks Before Reporting the Number

A hand calculation is useful partly because it exposes input and implementation errors. Before interpreting the result, check the following:

  • Prediction columns: \(\hat m_1(X_i)\) must be the prediction under treatment and \(\hat m_0(X_i)\) the prediction under control, for the same person’s covariates.
  • Observed residual: use \(Y_i-\hat m_1(X_i)\) for a treated person and \(Y_i-\hat m_0(X_i)\) for a control person. The other potential outcome is not observed and does not supply a residual.
  • Signs and denominators: the treated correction is added with denominator \(\hat e(X_i)\); the control correction is subtracted with denominator \(1-\hat e(X_i)\).
  • Score range and influence: scores must be strictly between zero and one. Very small \(\hat e(X_i)\) for a treated person, or very small \(1-\hat e(X_i)\) for a control person, can produce a large correction. Inspect the individual contributions rather than relying only on the final average.
  • Interpretation: retain the outcome’s units. A numerical estimate does not verify exchangeability, consistency, or positivity, and a small dataset may give an unstable estimate even when the arithmetic is correct.

The main alternatives answer related questions with different calculations. Outcome regression averages predicted contrasts and does not use these residual corrections. Inverse-probability weighting uses weighted observed outcomes without the outcome-model augmentation. AIPW combines the two components, but its finite-sample result can still be sensitive to extreme scores or inaccurate predictions. For inference, the estimate alone is not enough: a standard error and interval must use an appropriate variance procedure, including any clustering in the data.

Common mistake: “Person 4 was untreated, so I should correct with \(Y_i-\hat m_1(X_i)\), because the target includes the treated outcome.” This is wrong: \(Y_i\) is that person’s observed control outcome. The control residual is \(Y_i-\hat m_0(X_i)\), and it appears with the negative control correction. The treated prediction still enters the predicted contrast, but it cannot be paired with the observed control outcome to form a treated residual.

The introductory material on AIPW under correct and misspecified nuisance models gives the broader interpretation of the estimator’s two nuisance components. For a numerical calculation, the essential discipline is to compute and record each person’s full contribution before averaging; that makes sign, denominator, and influential-observation errors easier to locate.

Worked Example: Checking Which Residual Belongs in the Formula

For a final hypothetical dataset, three people have the following values: person 1 has \(A=1\), \(Y=7\), \(\hat e=0.50\), \(\hat m_1=6\), and \(\hat m_0=3\); person 2 has \(A=0\), \(Y=2\), \(\hat e=0.25\), \(\hat m_1=4\), and \(\hat m_0=2\); person 3 has \(A=0\), \(Y=4\), \(\hat e=0.50\), \(\hat m_1=5\), and \(\hat m_0=3\).

Person 1 is treated, so the contribution is \(6-3+(7-6)/0.50=5\). Person 2 is a control, and its control residual is zero, giving \(4-2-(2-2)/(1-0.25)=2\). Person 3 is also a control; its contribution is \(5-3-(4-3)/(1-0.50)=0\). The estimate is \((5+2+0)/3=2.333\) outcome units.

For person 3, incorrectly using the treated prediction in the residual would give \(5-3-(4-5)/0.50=4\), rather than 0. That discrepancy shows why the observed treatment status determines which outcome prediction belongs in the residual correction.

Check Your Understanding

Work through each item, then compare your result with the solutions below.

  1. A treated person has \(Y=9\), \(\hat e=0.60\), \(\hat m_1=8\), and \(\hat m_0=5\). Calculate the AIPW contribution.
  2. A control person has \(Y=2\), \(\hat e=0.25\), \(\hat m_1=6\), and \(\hat m_0=3\). Calculate the contribution.
  3. In a binary-outcome analysis, what units does the AIPW ATE use?
  4. Why can a control person with a propensity prediction close to one have a large contribution?
  5. Name the key causal identification assumptions needed to interpret the AIPW estimate as an ATE.

Solutions. (1) The predicted contrast is \(8-5=3\), and the treated correction is \((9-8)/0.60=1.6667\), so the contribution is \(4.667\) outcome units. (2) The contrast is \(6-3=3\), and the control correction is \(-(2-3)/(1-0.25)=+1.3333\), giving \(4.333\) outcome units. (3) It is a risk difference, expressed as a probability difference or percentage-point difference. (4) The control residual is divided by \(1-\hat e\), which is small when the score is close to one. (5) Consistency and no interference, conditional exchangeability given measured covariates, and positivity.

Clinical Biostats