Skip to contents

Matches each treated unit to its nearest controls under \(\sqrt{(x_i-x_j)'S^{-1}(x_i-x_j)}\). The inverse covariance is what makes the distance invariant to linear rescaling of the covariates – Euclidean matching silently weights by whatever units the columns happen to be in.

Usage

morie_causal_mahalanobis_match(X, treat, k = 1, replace = TRUE, caliper = NULL)

Arguments

X

covariate matrix.

treat

0/1 treatment indicator.

k

matches per treated unit.

replace

allow a control to serve several treated units.

caliper

optional maximum distance; unmatched units are reported rather than force-matched.

Value

list with matches (0-based control indices, -1 where unmatched), distances, n_unmatched, reuse_max, mean_distance.

Details

Past roughly eight covariates the distances concentrate: the nearest control is barely nearer than an arbitrary one, and the matching stops meaning anything. Propensity-score matching is the answer there, and the function warns.

References

Rubin, D. B. (1980). Bias reduction using Mahalanobis-metric matching. Biometrics, 36(2), 293-298.

Examples

set.seed(1)
X <- matrix(rnorm(200), ncol = 2)
tr <- rbinom(100, 1, 0.4)
morie_causal_mahalanobis_match(X, tr)$n_unmatched
#> [1] 0