Optimal one-to-one matching for causal inference and experimental design. High-level matching with balance diagnostics and 18 LAP algorithms.

View Package Documentation

I came into contact with linear assignment problems through matching pixels: pairing each pixel of one image with a pixel of another at the lowest total cost. Once a solver gave me an answer, I wanted a certificate that the answer was optimal. I realized I could get one by considering the dual, a weaker problem whose solution bounds the best possible cost; when the two meet, the matching is optimal. That check became verify_assignment(), and the solvers around it became couplr.

Today couplr does optimal one-to-one matching between two groups in R. It matches directly on covariates, without a propensity score model in between, which makes it useful for causal inference, experimental design, resource allocation and image processing.

The package offers two main matching functions: match_couples() for optimal matching with automatic preprocessing, multiple scaling methods, distance constraints, and blocking support; and greedy_couples() for fast approximate matching using sorted, row-best, or priority queue strategies (10-100x faster for large datasets). Use match_couples() for n < 5,000 where guaranteed optimality matters; switch to greedy_couples() for larger datasets prioritizing speed.

Balance diagnostics are built-in via balance_diagnostics() for assessing covariate balance using standardized differences, variance ratios, and KS tests, along with balance_table() for publication-ready output. For lower-level control, lap_solve() provides an interface to 18 linear assignment algorithms with automatic method selection, plus batch solving and K-best solutions via Murty’s algorithm.

Available on CRAN under MIT license.

install.packages("couplr")

Citation

Colling G (2026). couplr: Linear Assignment Problem Solver for Optimal Matching. doi:10.32614/CRAN.package.couplr

Gilles Colling

Gilles Colling

PhD student at University of Vienna. Physicist turned ecologist. R packages, spatial statistics, and computational ecology.