Answer
What is propensity score matching, and when should you use it?
The short answer
A propensity score is a person's estimated probability of receiving a treatment, given their measured characteristics. Matching each treated person to an untreated person with a similar score builds a comparison group that resembles the treated group on those characteristics, which you confirm with balance checks. It removes bias only from confounders you measured.
What the propensity score is
In observational data, the people who got a treatment usually differ from those who did not: they may be older, sicker or more motivated. A raw comparison of outcomes mixes the treatment effect with those differences. The propensity score is the probability of being treated given the measured covariates, usually estimated with a logistic regression of treatment on those covariates.
Its key property, shown by Rosenbaum and Rubin (1983), is that it is a balancing score: among people with the same propensity score, the measured covariates have the same distribution in the treated and untreated groups. So instead of matching on age, severity, smoking and every other covariate at once, you can match on one number.
Two assumptions do the heavy lifting. No unmeasured confounding: every variable that affects both treatment and outcome is in the model. Overlap: every kind of person had some chance of being in either group, so there are comparable controls to find. Include confounders and predictors of the outcome in the score model, but not variables affected by the treatment, and avoid variables that predict treatment without affecting the outcome, because they make matching harder without removing bias.
How matching works, step by step
- Estimate each person's propensity score, usually by logistic regression.
- Match each treated person to the untreated person with the closest score, usually on the logit scale. Common choices are 1:1 nearest-neighbour matching without replacement and a caliper: a maximum allowed distance, often 0.2 standard deviations of the logit of the score (Austin, 2011).
- Drop treated people with no control inside the caliper and controls that were never used.
- Check balance in the matched sample. If it is poor, change the score model or the matching settings and check again, all before looking at outcomes.
- Estimate the effect by comparing outcomes in the matched sample, using methods that respect the pairing.
Matching controls to treated people estimates the average treatment effect on the treated (ATT): the effect among the kind of people who actually received the treatment. If the caliper drops some treated people, the estimate describes the matched ones, which is worth saying in the write-up.
This page differs from controlling for variables in regression, where the covariates go into the outcome model. Matching does the adjustment at the design stage, before any outcome is analysed, and it makes the comparison group visible so you can check it.
Checking balance with standardized mean differences
The goal of the score model is balance, not prediction, so judge it by how similar the matched groups are, not by its accuracy or AUC. The usual measure is the standardized mean difference (SMD) for each covariate: the difference in group means divided by a pooled standard deviation. Keeping the same denominator before and after matching makes the two values comparable. An absolute SMD below 0.1 is a widely used rule of thumb for good balance; also compare variances and look at the distributions of key covariates.
Do not use significance tests for balance. Matching shrinks the sample, so p-values rise even when imbalance does not change, and balance is a property of the sample in hand, not of a population.
See it in R and Python
This simulation gives 1,000 people a treatment that is more likely for older, sicker people and for smokers. All three also raise the outcome, and the true treatment effect is exactly 2. The code fits the propensity model with glm, matches greedily on the logit of the score without any matching package, checks balance, and compares the naive, matched and regression estimates. The Python version fits the same unpenalized logistic regression by Newton-Raphson, the algorithm glm uses, and gives the same coefficients as R on the same data.
R
set.seed(7)
n <- 1000
age <- rnorm(n, 50, 10)
severity <- rnorm(n)
smoker <- rbinom(n, 1, 0.3)
# Sicker, older patients and smokers are more likely to get the treatment
treat <- rbinom(n, 1, plogis(-1 + 0.05 * (age - 50) + 0.8 * severity + 0.5 * smoker))
# The true treatment effect is 2 for everyone
y <- 2 * treat + 0.1 * age + 1.5 * severity + smoker + rnorm(n, sd = 2)
d <- data.frame(y, treat, age, severity, smoker)
# 1. Propensity score from a logistic regression of treatment on the confounders
ps_fit <- glm(treat ~ age + severity + smoker, family = binomial, data = d)
round(coef(ps_fit), 3)
lps <- predict(ps_fit) # logit of the propensity score
# 2. Greedy 1:1 nearest-neighbour matching without replacement, caliper 0.2 SD
caliper <- 0.2 * sd(lps)
tr <- which(treat == 1); tr <- tr[order(-lps[tr])]
co <- which(treat == 0); free <- rep(TRUE, length(co))
pairs <- matrix(NA, 0, 2)
for (i in tr) {
dist <- ifelse(free, abs(lps[co] - lps[i]), Inf)
j <- which.min(dist)
if (dist[j] <= caliper) { pairs <- rbind(pairs, c(i, co[j])); free[j] <- FALSE }
}
c(treated = length(tr), matched = nrow(pairs))
# 3. Balance: standardized mean differences (full-sample pooled SD)
smd <- function(v, t_idx, c_idx) {
(mean(v[t_idx]) - mean(v[c_idx])) / sqrt((var(v[treat == 1]) + var(v[treat == 0])) / 2)
}
covs <- d[, c("age", "severity", "smoker")]
round(rbind(before = sapply(covs, smd, which(treat == 1), which(treat == 0)),
after = sapply(covs, smd, pairs[, 1], pairs[, 2])), 3)
# 4. Effect estimates: naive, matched (ATT), regression adjustment
diffs <- y[pairs[, 1]] - y[pairs[, 2]]
round(c(naive = mean(y[treat == 1]) - mean(y[treat == 0]),
matched = mean(diffs),
regression = coef(lm(y ~ treat + age + severity + smoker))[["treat"]]), 3)
round(as.vector(t.test(diffs)$conf.int), 3) # 95% CI from the matched pairs
Python
import numpy as np
from scipy import stats
rng = np.random.default_rng(7)
n = 1000
age = rng.normal(50, 10, n)
severity = rng.normal(size=n)
smoker = rng.binomial(1, 0.3, n)
# Sicker, older patients and smokers are more likely to get the treatment
eta = -1 + 0.05 * (age - 50) + 0.8 * severity + 0.5 * smoker
treat = rng.binomial(1, 1 / (1 + np.exp(-eta)))
# The true treatment effect is 2 for everyone
y = 2 * treat + 0.1 * age + 1.5 * severity + smoker + rng.normal(0, 2, n)
# 1. Propensity score: unpenalized logistic regression by Newton-Raphson (as glm does)
X = np.column_stack([np.ones(n), age, severity, smoker])
b = np.zeros(4)
for _ in range(25):
p = 1 / (1 + np.exp(-X @ b))
b = b + np.linalg.solve(X.T @ (X * (p * (1 - p))[:, None]), X.T @ (treat - p))
print(np.round(b, 3))
lps = X @ b # logit of the propensity score
# 2. Greedy 1:1 nearest-neighbour matching without replacement, caliper 0.2 SD
caliper = 0.2 * lps.std(ddof=1)
tr = np.flatnonzero(treat == 1)
tr = tr[np.argsort(-lps[tr], kind="stable")]
co = np.flatnonzero(treat == 0)
free = np.ones(len(co), dtype=bool)
pairs = []
for i in tr:
dist = np.where(free, np.abs(lps[co] - lps[i]), np.inf)
j = np.argmin(dist)
if dist[j] <= caliper:
pairs.append((i, co[j]))
free[j] = False
pairs = np.array(pairs)
print("treated:", len(tr), "matched:", len(pairs))
# 3. Balance: standardized mean differences (full-sample pooled SD)
def smd(v, t_idx, c_idx):
pooled = np.sqrt((v[treat == 1].var(ddof=1) + v[treat == 0].var(ddof=1)) / 2)
return (v[t_idx].mean() - v[c_idx].mean()) / pooled
for name, v in {"age": age, "severity": severity, "smoker": smoker}.items():
before = smd(v, treat == 1, treat == 0)
after = smd(v, pairs[:, 0], pairs[:, 1])
print(name, round(before, 3), round(after, 3))
# 4. Effect estimates: naive, matched (ATT), regression adjustment
diffs = y[pairs[:, 0]] - y[pairs[:, 1]]
coef = np.linalg.lstsq(np.column_stack([X, treat]), y, rcond=None)[0]
print("naive:", round(y[treat == 1].mean() - y[treat == 0].mean(), 3),
"matched:", round(diffs.mean(), 3), "regression:", round(coef[4], 3))
half = stats.t.ppf(0.975, len(diffs) - 1) * diffs.std(ddof=1) / np.sqrt(len(diffs))
print(round(diffs.mean() - half, 3), round(diffs.mean() + half, 3)) # 95% CI
(Intercept) age severity smoker
-3.305 0.046 0.895 0.279
treated matched
324 294
age severity smoker
before 0.399 0.814 0.071
after 0.091 0.031 -0.066
naive matched regression
3.551 2.031 2.000
[1] 1.700 2.363
The figures come from one seeded run of the R code. Python uses a different random number generator, so its figures differ slightly, but they show the same pattern.
- Matching found partners for most treated people: 294 of the 324 were matched within the caliper; the rest had no control with a close enough score.
- Balance improved where it was needed. The SMD for severity fell from 0.814 to 0.031 and for age from 0.399 to 0.091. Smoking was already balanced (0.071) and stayed so (โ0.066); matching does not shrink every SMD, which is why you check each one.
- The naive comparison is badly biased. The raw difference in means is 3.551, against a true effect of 2.
- The matched estimate recovers the effect: 2.031, with a 95% CI from the paired differences of [1.700, 2.363]. Regression adjustment gives 2.000 here, because its linear model happens to be exactly right.
The paired t interval is a simple choice that ignores the fact that the score was estimated. For real analyses, a dedicated package such as MatchIt in R handles matching, balance tables and recommended standard errors, such as cluster-robust errors by matched pair.
Matching, weighting or regression adjustment?
- Matching is transparent and easy to explain, and it enforces overlap by discarding people without a counterpart. The cost is lost data and, with a caliper, a slightly different target population.
- Inverse probability weighting keeps everyone. Weighting treated people by 1/e and controls by 1/(1 โ e), where e is the propensity score, estimates the average effect in the whole population; weights of 1 for treated people and e/(1 โ e) for controls estimate the ATT. Scores near 0 or 1 create huge weights and unstable estimates.
- Regression adjustment uses all the data and is efficient when the outcome model is right, but it extrapolates silently into regions where one group has no data, and nonlinear effects or interactions it leaves out cause bias.
- Doubly robust methods combine a propensity model with an outcome model and stay consistent if either one is correctly specified. Matching followed by regression on the matched sample is a simple version of the same idea.
Matching on the propensity score is not the only kind of matching. Some authors (King and Nielsen, 2019) argue that pruning on the score can increase imbalance and prefer matching directly on the covariates, for example Mahalanobis distance or coarsened exact matching. Whatever you choose, the balance check is what tells you whether it worked.
What propensity scores cannot fix
- Unmeasured confounding. The score balances only what went into it. If an unrecorded factor such as frailty drives both treatment and outcome, matching leaves that bias untouched. A sensitivity analysis shows how strong such a confounder would need to be to explain away the result.
- Poor overlap. If the treated and untreated scores barely overlap, matching discards most of the sample, and any method is extrapolating.
- Bad covariates. Adjusting for a variable measured after treatment, or one caused by both treatment and outcome, can create bias rather than remove it.
- A misspecified score model. If balance is poor, add interactions or nonlinear terms and check again.
How to report propensity score matching in APA style (7th edition)
Describe the score model and its covariates, the matching method, the caliper, how many people were matched and dropped, balance before and after, and the effect estimate with its confidence interval and estimand. Using the R output above:
"Propensity scores were estimated with logistic regression on age, severity and smoking status. Using 1:1 nearest-neighbour matching without replacement and a caliper of 0.2 standard deviations of the logit of the score, 294 of 324 treated participants were matched. After matching, all absolute standardized mean differences were below 0.10. In the matched sample, the estimated average treatment effect on the treated was 2.03 points, 95% CI [1.70, 2.36]."
Standardized mean differences can exceed 1, so keep the leading zero. Give a balance table with one row per covariate and SMDs before and after matching, and name the software and its version in the method section.
Related tools and guides
- APA 7 formatter for regression
- What does it mean to control for a variable in regression?
- Which statistical test should I use?
- The MatchIt package on CRAN
- Propensity score matching (Wikipedia)
More answered questions
- Moderation vs mediation: what is the difference, and how do you report each?
- Can you test the exclusion restriction of an instrumental variable?
- What does it mean to control for a variable in regression?
Working with your own data?
General answers only go so far. Send us your situation and we'll reply by email within two business days.
Ask your questionWritten by AskStats with AI assistance. This is general information, not advice for your specific data or study. When the results matter, check your approach with a qualified statistician.