Tutorials › Econometrics (Graduate) › Nearest-Neighbor Matching for Treatment Effects

Matching and Weighting Methods · Tutorial 634 of 952

Nearest-Neighbor Matching for Treatment Effects

Construct one-to-one nearest-neighbor matches and calculate treatment-effect estimates while keeping the matched population and estimand distinct.

Advanced 11 min read

What You'll Learn

  • Define nearest-neighbor matches using distance between estimated propensity scores.
  • Construct one-to-one matches without replacement when nearest matches are unique.
  • Calculate the average paired difference for a matched sample.
  • Distinguish the average treatment effect from the average treatment effect on the treated.
  • Explain how unmatched units can change the population an estimate describes.
  • Identify why propensity-score proximity alone does not guarantee covariate balance.

Why Match Units?

In an observational study, treated and control units can differ in their measured covariates before treatment. A raw difference in their average outcomes can therefore reflect both treatment and those differences. Nearest-neighbor matching constructs pairs that are close on a chosen measure of observed covariates, often an estimated propensity score. The paired outcome differences can then be averaged to estimate a causal effect for a clearly specified matched population.

Matching does not create random assignment. Its causal interpretation still depends on assumptions about treatment assignment and the units retained in the analysis. It is also important to distinguish the average treatment effect (ATE), which averages effects over a target population, from the average treatment effect on the treated (ATT), which averages effects among treated units. Matching rules determine which units contribute to an estimate; they do not make those targets interchangeable.

Setup and Matching Rule

For unit \(i\), let \(T_i\) be the treatment indicator, with \(T_i=1\) for a treated unit and \(T_i=0\) for a control. Let \(Y_i(1)\) and \(Y_i(0)\) denote 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)\). Let \(X_i\) be the measured pretreatment covariates, and let \(\hat e_i\) be the estimated propensity score for unit \(i\), calculated from those covariates.

Definition: In nearest-neighbor matching on the estimated propensity score, a treated unit is matched to the eligible control unit with the smallest absolute score distance, \(|\hat e_i-\hat e_j|\). A one-to-one match pairs one treated unit with one control unit. In this tutorial, matches are made without replacement: once a unit is paired, it cannot be used in another pair. Examples have unique nearest matches, so no tie rule is needed.

For an ATT analysis, treated units are the anchors: each treated unit is paired with its nearest available control. If there are more treated units than controls, some treated units cannot be matched under this one-to-one rule. For an ATE analysis, construct a set of treated-control pairs for the population the analysis intends to represent. With equal numbers of matched units, each pair contributes one treated and one control outcome. Any unmatched units are excluded from this paired analysis, so the resulting estimate directly describes the matched sample; extrapolating it to a broader population requires additional justification.

A standard causal interpretation requires consistency (the observed outcome equals the potential outcome under the treatment actually received), no interference between units, and conditional independence of treatment and potential outcomes given measured covariates. It also requires overlap: units in the target population must have a positive probability of receiving either treatment level. These assumptions support identification; matching is a way to construct a comparison, not a substitute for them. In practice, close estimated scores do not prove that all relevant covariates are balanced.

ATT: Match Treated Units to Controls

Worked Example: Estimating the ATT

Suppose a hypothetical study records a binary outcome measured in points and has the following estimated scores and observed outcomes. The treated units are matched in the displayed order, and controls are not reused.

UnitTreatmentEstimated scoreObserved outcome (points)
T1Treated0.2012
T2Treated0.4518
T3Treated0.7020
C1Control0.188
C2Control0.4013
C3Control0.6215
C4Control0.8517

For T1, the control score distances are 0.02, 0.20, 0.42, and 0.65, so T1 matches C1. For T2, C1 is already used; the remaining distances are 0.05 to C2, 0.17 to C3, and 0.40 to C4, so T2 matches C2. T3 then matches C3, at distance 0.08 rather than 0.15 to C4.

The paired differences, treated outcome minus control outcome, are \(12-8=4\), \(18-13=5\), and \(20-15=5\) points. The matched ATT estimate is their average:

$$ \widehat{\tau}_{ATT,\mathrm{matched}} =\frac{1}{3}\sum_{i\in\mathcal{T}_m}(Y_i-Y_{j(i)}) =\frac{4+5+5}{3} =\frac{14}{3} \approx 4.667\text{ points}. $$

Here, \(\mathcal{T}_m\) is the set of matched treated units and \(j(i)\) is the control paired with treated unit \(i\). Because all three treated units were matched, the estimate targets the ATT for these treated units, subject to the causal assumptions and the adequacy of the matches. It is an estimated average effect, not a claim that every treated unit gained 4.667 points.

ATE: Average Differences in a Matched Sample

The ATE for a target population is the average of \(Y_i(1)-Y_i(0)\) over units in that population. In an observational sample, both potential outcomes are not observed for any one unit. Matching supplies a comparison outcome from a nearby unit in the other treatment group. For a one-to-one matched sample with \(M\) pairs, the paired estimator is the mean of the \(M\) treated-minus-control outcome differences.

Estimator: For matched pairs \((i_m,j_m)\), where \(i_m\) is treated and \(j_m\) is control, the matched-sample estimate is \(\hat{\tau}_{m}=\frac{1}{M}\sum_{m=1}^{M}(Y_{i_m}-Y_{j_m})\). It estimates an average effect for the population represented by those matched pairs. It estimates the population ATE only when the matched sample and identifying assumptions justify that target.

Worked Example: Estimating an ATE in a Matched Sample

Consider a different hypothetical study with three treated units and three controls. Each treated unit has a unique nearest control, and the pairs cover the sample the investigators define as their target population.

PairTreated scoreTreated outcome (points)Control scoreControl outcome (points)
10.25140.2210
20.52170.5615
30.78220.7418

The score distances are 0.03, 0.04, and 0.04, respectively. The paired outcome differences are \(14-10=4\), \(17-15=2\), and \(22-18=4\) points. Thus:

$$ \hat{\tau}_{m} =\frac{(14-10)+(17-15)+(22-18)}{3} =\frac{10}{3} \approx 3.333\text{ points}. $$

This is an estimated average effect for the population represented by these three matched pairs. Calling it an estimate of the ATE for a larger population requires that the matched pairs appropriately represent that population and that the causal assumptions hold. Matching all sampled units does not by itself establish that broader representativeness.

Why the ATT and ATE Can Look the Same

When every treated unit is matched and each matched pair receives equal weight, the ATT estimate and the matched-pair estimate have the same arithmetic: both average the treated-minus-control differences across those pairs. Their interpretations can still differ. The ATT refers to effects among treated units; an ATE refers to effects over a specified target population. The two targets coincide only under conditions that make the matched treated units representative of that target, or when the target is explicitly defined as the matched population.

The distinction becomes especially important when some units are excluded. A treated-unit matching procedure may retain treated units that have close controls and omit those without suitable comparisons. The estimate then describes the matched treated units, not automatically all treated units. Likewise, a matched sample selected from both groups is not automatically representative of the full study population. State the target population alongside the estimate.

What Matching Does—and Does Not—Establish

The propensity score is a balancing score under the relevant conditions: at the true score, treatment assignment is independent of measured covariates conditional on that score when assignment is conditionally independent given those covariates. In finite samples, however, matching on an estimated score generally produces approximate rather than exact balance. A small score distance is not a guarantee that every covariate is close, especially if the score model is poorly specified or the sample is limited. Balance should be assessed directly; the later material on covariate balance diagnostics develops that task.

The no-replacement rule also has practical consequences. A control that is a good match for one treated unit is no longer available for another. Matching order can therefore affect the pairs, particularly when several units compete for the same controls. The examples used a stated order and unique nearest matches so the arithmetic is unambiguous. More elaborate approaches address replacement, ties, distance restrictions, and alternative matching designs separately.

1
Specify the target.
Decide whether the goal concerns effects for treated units, the full population, or a matched subset.
2
Choose the score distance and matching rule.
Here, distance is the absolute difference in estimated propensity scores, with one-to-one matches and no replacement.
3
Form pairs and identify exclusions.
Record each pair and any unmatched units; exclusions determine which population the paired estimate can describe.
4
Average paired outcome differences.
Compute treated outcome minus control outcome for every pair, then take their mean and interpret it for the stated target.

Common Mistake

A frequent error is to conclude, “The treated and control units have similar estimated propensity scores, so the estimate is the population ATE.” Score proximity alone does not establish that conclusion. Matching can leave covariate differences, omit units, or represent only a restricted subset. The correction is to report the matched estimate with its target population, inspect covariate balance, and justify any claim that it represents the full ATE. If treated units without close controls are excluded, an ATT estimate based on the remaining pairs is not automatically the ATT for all treated units.

Key takeaway: Nearest-neighbor matching creates comparisons, not randomization. Calculate the mean of the paired treated-minus-control differences, then interpret it for the population represented by those pairs and only under explicit causal assumptions.

Check Your Understanding

Use the matching rule and target-population distinctions from this tutorial.

  1. A treated unit has score 0.31. Two available controls have scores 0.27 and 0.38. Which is the nearest match, and what is the score distance?
  2. Three matched pairs have treated-minus-control differences of 2, 5, and \(-1\) points. Calculate the paired estimate.
  3. Why does a matched-pair estimate not automatically estimate the ATE for the entire study population?
  4. If some treated units have no available controls under one-to-one matching without replacement, which treated population does the resulting paired estimate directly describe?
  5. When ATT and matched-sample ATE estimates use exactly the same pairs with equal weights, why can their numerical values agree while their interpretations differ?
Clinical Biostats