Skip to content
StatsOtter A workspace for causal thinking
Method library WORKFLOW / 053
Research workflow/5 steps

Coarsened exact matching (CEM)

01
The method workspace

Follow the analysis.

Select a node to explore the method

Method mapInput → 5 steps → output
START WITHInput data
ARRIVE ATResults
Read step 01
Inside the methodReasoning, equations & implementation
Step 1 of 5
01
Data prep

Load cem and the LeLonde data

Data preparation — shapes the raw inputs into what the estimator expects.

What happens here

Load the package and the LL (LeLonde) dataset, and define the variables to drop from matching.

Reads fromNot specified Feeds into#2
Key code
# Install:  install.packages("cem")
library(cem)
data(LL)
todrop <- c("treated", "re78")

Reference / docs ↗

Discussion on this step (0)
StatsOtterDiscussion starter · Editorial note

Before using this step, make its assumptions and its output explicit. A useful peer note explains what you would check, what could go wrong, or what would change your interpretation.

Questions to explore
  1. Which assumption matters most here, and what evidence could challenge it?
  2. What would you check before passing this output to the next step?

Peer discussion

  • Bring your experience, a question, or a different perspective.
02
Data contract

Inputs & data

A data frame with a treatment indicator and covariates, plus optional coarsening (cutpoints/groupings) per covariate.

Show data format & exampleHide example
treated age sex income
1 34 F 52000
0 31 F 48000
1 60 M 75000
0 58 M 71000
03
Read the evidence

Results & interpretation

1 figure Workflow discussion 0
01FigureSATT on the CEM-matched sample with its 95% confidence interval.

Result figure rendered by StatsOtter from the package's documented example — unofficial community showcase; all credit to the original authors.

The estimate

\hat\tau=\sum_{\ell\in\mathcal L}\frac{n_\ell^{T}}{n^{T}}\big(\bar Y_\ell^{T}-\bar Y_\ell^{C}\big)

Context & interpretation

⚠️ Unofficial community showcase of cem (docs). Not affiliated with the authors — all credit to Gary King & coauthors; this summarizes public documentation.

What it does: CEM implements Coarsened Exact Matching, a monotonic-imbalance-bounding matching method that improves covariate balance between treated and control groups in observational studies. How it works: Each covariate is temporarily coarsened into substantively meaningful bins (e.g. age into decades), units are sorted into strata defined by all coarsened covariates, and only strata containing both treated and control units are retained. The original (uncoarsened) values are then used for analysis, with weights correcting for differing stratum sizes. Bounding imbalance on one variable never increases it on another (MIB property), and the user directly controls the balance/sample-size tradeoff via the coarsening. Assumptions: Unconfoundedness given observed covariates and common support; pruned units reduce the sample but improve balance. Output: matched strata, CEM weights, an imbalance measure, and effect estimates (commonly the ATT) on the matched sample.

What you get — Matched strata with CEM weights and an imbalance statistic, used to estimate treatment effects (e.g. ATT).

Example output

G0      G1
429     185
Matched Data
G0      G1
222     163

Linear regression model on CEM matched data:

SATT point estimate: 550.625110 (p.value=0.347096)
95% conf. interval: [-606.207019, 1707.457238]

Multivariate L1 distance after matching: 0.59

Number of strata: 162
Number of matched strata: 67

          G0  G1
All      429 185
Matched  222 163
Unmatched 207  22

Links: package · paper

Peer notes

Discuss the workflow (0)

  • No comments yet — start the conversation.
IN THE MARGINS

Peer discussion