Tutorials › Econometrics (Graduate) › A Worked Comparison of Matching, IPW, and AIPW

Matching and Weighting Methods · Tutorial 653 of 952

A Worked Comparison of Matching, IPW, and AIPW

Work through three estimators of the average treatment effect on the same observational data, and assess what their estimates and diagnostics do—and do not—show.

Advanced 12 min read

What You'll Learn

  • State the assumptions needed to interpret the estimates as causal average treatment effects.
  • Calculate a one-nearest-neighbor matching estimate with replacement and a specified tie-breaking rule.
  • Compute Horvitz–Thompson IPW and AIPW estimates from observed outcomes and propensity scores.
  • Compare raw and weighted covariate balance and diagnose overlap.
  • Interpret plug-in uncertainty cautiously, especially with a very small sample.

Why Compare the Estimators on the Same Data?

Matching, inverse-probability weighting (IPW), and augmented inverse-probability weighting (AIPW) are different ways to use observed covariates to estimate a causal effect from observational data. Applying all three to the same data makes their differences visible: matching imputes missing potential outcomes from selected comparison units, IPW reweights observed outcomes, and AIPW combines weighting with outcome regression. Similar estimates are not proof that the assumptions behind causal interpretation hold.

The target here is the average treatment effect (ATE) for the units represented by the observed sample. Let \(T_i\) indicate treatment for unit \(i\), let \(X_i\) denote observed pretreatment covariates, and let \(Y_i(1)\) and \(Y_i(0)\) be that unit’s potential outcomes under treatment and control. The observed outcome is \(Y_i=T_iY_i(1)+(1-T_i)Y_i(0)\). The ATE is the average difference \(Y_i(1)-Y_i(0)\) across the target population; neither potential outcome pair is observed for any one unit.

Identification assumptions: A causal interpretation requires consistency (the observed outcome equals the potential outcome under the treatment received), no interference between units, conditional exchangeability \((Y(1),Y(0))\perp T\mid X\), and positivity \(0<P(T=1\mid X=x)<1\) for covariate values in the target population. These assumptions identify the ATE from observed data; diagnostics can assess aspects such as overlap and balance, but cannot establish exchangeability.

For this worked comparison, \(X\) is a binary pretreatment characteristic with values 0 and 1. All values and outcomes below are hypothetical. The treatment and control groups both contain units at each value of \(X\), so there is empirical overlap. The sample is deliberately small to keep each calculation inspectable; that also makes every numerical result fragile.

The Hypothetical Data and Its First Diagnostics

Unit\(X\)\(T\)Observed outcome \(Y\)
A018
B0110
C005
D1114
E1112
F109
G1011
H1013

The treatment propensity is \(e(x)=P(T=1\mid X=x)\). Its empirical estimate within each covariate stratum is \(\hat e(0)=2/3\) and \(\hat e(1)=2/5\). Both are strictly between zero and one, but the small stratum counts mean these estimates are imprecise. In the raw data, half the treated units have \(X=0\), compared with one quarter of controls. Thus the groups are not balanced on \(X\) before adjustment.

Worked Example: Checking Overlap and Raw Imbalance

There are four treated units and four controls. At \(X=0\), the treatment fraction is \(2/(2+1)=2/3\); at \(X=1\), it is \(2/(2+3)=2/5\). Both treatment states occur in each stratum, so there is no empirical positivity failure for these two observed values of \(X\). This does not rule out poor overlap on unmeasured covariates or imprecision in estimating the propensities.

Among treated units, the proportion with \(X=0\) is \(2/4=0.50\). Among controls, it is \(1/4=0.25\). The raw difference is \(0.50-0.25=0.25\), a 25-percentage-point imbalance. This calculation is a balance diagnostic, not a test of whether treatment assignment is unconfounded.

One-Nearest-Neighbor Matching

For clarity, use exact matching on \(X\), which is nearest-neighbor matching here because units in the same stratum have distance zero and units in different strata cannot serve as exact matches. Match with replacement: the same comparison unit may be selected more than once. When several opposite-treatment units are equally near, select the one with the earliest letter in the table. The rule selects exactly one neighbor per unit; it does not average outcomes over all tied neighbors.

To estimate the ATE, predict each unit’s unobserved potential outcome using its selected opposite-treatment neighbor. For a treated unit, subtract its matched control’s outcome from its observed outcome. For a control, subtract its observed outcome from its matched treated unit’s outcome. Average these \(n\) imputed individual contrasts. This is a particular matching estimator, and with replacement and ties its value can depend on the stated tie-breaking rule.

Matching estimator: If \(j(i)\) is the single selected nearest neighbor of unit \(i\) with the opposite treatment status, the ATE estimate is the sample average of \(Y_i-Y_{j(i)}\) for treated units and \(Y_{j(i)}-Y_i\) for controls. Every unit contributes one contrast; repeated use of a neighbor is allowed under matching with replacement.

Worked Example: Calculating the Matching Estimate

A and B are treated at \(X=0\), and C is the only control there. Both treated units match to C. Their estimated contrasts are \(8-5=3\) and \(10-5=5\). At \(X=1\), D and E are treated, while F, G, and H are controls. The tie rule selects F as the single neighbor for each treated unit, giving contrasts \(14-9=5\) and \(12-9=3\).

For the control units at \(X=0\), C matches to A, the earliest treated unit in its stratum, giving \(8-5=3\). At \(X=1\), F, G, and H each match to D, the earliest treated unit. Their contrasts are \(14-9=5\), \(14-11=3\), and \(14-13=1\). Thus the eight contrasts sum to \(3+5+5+3+3+5+3+1=28\), and the matching estimate is \(28/8=3.500\) outcome units.

The calculation uses one matched neighbor for every unit. For example, D and E both use F; neither uses the mean outcome of F, G, and H. Replacing F’s outcome with that group mean would define a different imputation procedure, not the one-nearest-neighbor estimator specified here.

IPW: Reweighting Observed Outcomes

The Horvitz–Thompson IPW estimator for the ATE weights each treated outcome by the inverse of its estimated treatment propensity and each control outcome by the inverse of its estimated probability of control. In this example, treated units at \(X=0\) receive weight \(1/(2/3)=1.5\); treated units at \(X=1\) receive weight \(1/(2/5)=2.5\). Control weights are \(1/(1-2/3)=3\) at \(X=0\) and \(1/(1-2/5)=5/3\) at \(X=1\).

Horvitz–Thompson IPW estimator: With estimated propensity \(\hat e(X_i)\), the ATE estimate is the sample average of \(T_iY_i/\hat e(X_i)-(1-T_i)Y_i/[1-\hat e(X_i)]\). This formula targets the ATE under the identification assumptions when the propensity model is correctly specified and the weights are well behaved.

Worked Example: Computing the IPW Estimate

The treated weighted outcome total is \(1.5(8+10)+2.5(14+12)=27+65=92\). The control weighted outcome total is \(3(5)+(5/3)(9+11+13)=15+55=70\). Their difference is 22. Dividing by the full sample size gives

$$ \hat\tau_{\mathrm{IPW}} =\frac{1}{8}(92-70) =\frac{22}{8} =2.750 \text{ outcome units}. $$

The weights also balance the observed binary covariate in this example. The total treated weight is \(3+5=8\), of which 3 is at \(X=0\); the total control weight is also \(3+5=8\), with 3 at \(X=0\). Each weighted group therefore has \(3/8\) of its weight at \(X=0\) and \(5/8\) at \(X=1\). Exact balance on this one covariate does not guarantee balance on other covariates or remove unmeasured confounding.

AIPW: Combining Outcome Regression and Weighting

AIPW augments the weighting calculation with outcome regression. Let \(m_t(x)=E[Y\mid T=t,X=x]\), estimated separately for treatment state \(t\). The sample AIPW estimator averages the predicted contrast \(m_1(X_i)-m_0(X_i)\), plus a weighted residual correction for the observed outcome in the treatment state actually received. Under the standard conditions, it is consistent if either the propensity model or the outcome-regression model is correctly specified, provided the other model is adequately controlled for the relevant estimation conditions. This double robustness does not protect against failure of both models or the causal identification assumptions.

AIPW estimator: For each unit, form \(m_1(X_i)-m_0(X_i)+T_i[Y_i-m_1(X_i)]/\hat e(X_i)-(1-T_i)[Y_i-m_0(X_i)]/[1-\hat e(X_i)]\). The AIPW estimate is the average of these \(n\) values.

Use saturated outcome regressions within the two \(X\) strata. The observed treated means are \(m_1(0)=9\) and \(m_1(1)=13\); the control means are \(m_0(0)=5\) and \(m_0(1)=11\). The predicted contrasts are therefore 4 at \(X=0\) and 2 at \(X=1\). The sample contains three units at \(X=0\) and five at \(X=1\).

Worked Example: Calculating the AIPW Estimate

The predicted contrast contributes \(4\) for each of A, B, and C, and \(2\) for each of D through H. The residual corrections for A and B are \(1.5(8-9)=-1.5\) and \(1.5(10-9)=1.5\); they sum to zero. C’s residual correction is zero because its outcome equals the stratum control mean.

For D and E, the corrections are \(2.5(14-13)=2.5\) and \(2.5(12-13)=-2.5\), again summing to zero. For F, G, and H the corrections are respectively \(-(9-11)/(3/5)=10/3\), \(-(11-11)/(3/5)=0\), and \(-(13-11)/(3/5)=-10/3\), which also sum to zero. The predicted contrasts sum to \(3(4)+5(2)=22\). Therefore the AIPW estimate is \(22/8=2.750\) outcome units.

Here the stratum-specific residual corrections cancel because each outcome mean was estimated from the same observations in that stratum. The estimate consequently equals the sample average of the two fitted stratum contrasts. That equality is a feature of this small saturated example, not a general identity between AIPW and outcome regression.

Comparing the Results and Their Uncertainty

MethodEstimate (outcome units)What drives the calculation here?Main caution
One-nearest-neighbor matching3.500Selected single opposite-treatment neighbors, with replacementTies and repeated matches can make the result sensitive to the matching rule
Horvitz–Thompson IPW2.750Observed outcomes weighted by inverse estimated propensitiesSmall estimated propensities can produce unstable, influential weights
AIPW2.750Predicted contrasts plus propensity-weighted residual correctionsDouble robustness does not remove identification or finite-sample problems

The matching estimate differs from both weighted estimates because the single-neighbor tie rule selects particular outcomes. All methods target the ATE under their assumptions, but they need not give the same finite-sample answer. The difference is not evidence by itself that one method is correct; it is a reason to examine modeling choices, diagnostics, and uncertainty.

Uncertainty must reflect how each estimate was constructed. For scale, the AIPW unit-level estimating values in this example are \(2.5, 5.5, 4, 4.5, -0.5, 16/3, 2,\) and \(-4/3\). Their sample standard deviation is about 2.584, giving the simple plug-in standard error \(2.584/\sqrt{8}\approx0.913\). A normal-approximation interval would be \(2.750\pm1.96(0.913)\), or about \([0.960,4.540]\) outcome units.

That interval is only an illustration of an influence-value calculation, not a dependable small-sample guarantee: the propensity and outcome models were both estimated from just eight observations, with sparse strata. IPW can be especially variable when estimated propensities are near zero or one. Matching inference must also account for the dependence created when a unit is reused as a neighbor; treating all matched contrasts as independent can give misleading uncertainty. The appropriate variance method depends on the estimator and its design, and routine bootstrap resampling can be problematic for matching.

What the Comparison Can—and Cannot—Establish

The raw imbalance in \(X\) is removed by the IPW weights in this example, and exact matching pairs units only within the same observed stratum. AIPW uses the same covariate in its propensity and outcome models. These facts describe adjustment for the measured covariate; they do not show that all confounders were measured, that the models generalize, or that a causal effect has been identified. In particular, empirical overlap means both treatment states appear in the observed strata; it is not proof of population positivity.

A careful comparison reports the estimator definition, the target population, the propensity and outcome models, the matching rule—including replacement and tie-breaking—and relevant diagnostics. It should also report uncertainty with its method and limitations. If estimates differ materially, investigate which observations, weights, or matches drive the discrepancy rather than selecting the estimate that best fits expectations.

  • Pitfall: averaging tied neighbors while calling the procedure one-nearest-neighbor matching. That changes the estimator. Specify a single-neighbor tie rule, or explicitly describe an averaging-over-neighbors procedure.
  • Pitfall: treating balance as proof of no confounding. Balance diagnostics address measured covariates; conditional exchangeability is an assumption about potential outcomes that the data alone cannot verify.
  • Pitfall: interpreting a small-sample plug-in interval as definitive. Estimated nuisance models, sparse strata, extreme weights, and reused matches can all make nominal uncertainty calculations unreliable.
Key takeaway: Matching, IPW, and AIPW are distinct estimators of a common causal target when their assumptions hold. A meaningful comparison makes their construction and diagnostics explicit, and treats agreement or disagreement as information to investigate—not as a substitute for identification or careful inference.

Check Your Understanding

Use the hypothetical data and definitions above to answer the following questions.

  1. Why does the matching calculation use F’s outcome, rather than the mean outcome of F, G, and H, for both treated units at \(X=1\)?
  2. Calculate the raw difference in the proportion with \(X=1\) between treated units and controls.
  3. What would be the control weight for a unit with \(X=1\), given \(\hat e(1)=2/5\)?
  4. Why do the residual corrections cancel within each stratum in this particular AIPW example?
  5. Does exact balance on \(X\) establish conditional exchangeability? Explain.
  6. Why can a standard error that treats reused matching contrasts as independent be misleading?
Clinical Biostats