← Homepage
Applied Data Science Lab · Causal Inference

Matching and Propensity Score Matching: The Practical Playbook

November 2, 2026
Author: Daniel Jordan Viray

You can't always run an experiment. Sometimes the data already exists, the treatment was already chosen — usually for a reason — and your job is to rebuild a fair comparison out of it. That's what matching does. This playbook walks through the whole job, step by step: spotting imbalance, measuring how different two patients are, finding good matches, checking that it worked, analyzing the outcome, and stress-testing the result — then doing the same thing, faster, with propensity scores.

One running example carries the whole post: diabetes patients who were prescribed either metformin, the standard older drug, or an SGLT2 inhibitor, the newer drug. Nobody flipped a coin. Doctors chose — and that choice is exactly the problem we have to solve.

01

Why matching? When you can't run a trial

The motivating factor for matching is that we can't always do a randomized controlled trial [randomized controlled trial, RCT]. Trials can be expensive, and sometimes they're unethical. If you want to understand the effect of smoking on lung cancer, you can't really ask people to smoke.

So instead we work with data that already exists. The treatment was already given, the outcomes already happened, and we're observing what took place. That's an [observational study]. Matching is how we build a treatment group and a control group out of that existing data — essentially, we try to recreate the fair comparison a trial would have given us.

The problem: the groups start out different

In a trial, random assignment doesn't control any patient's characteristics directly — it makes the distributions of background characteristics [covariates] the same in both groups, on average [in expectation]. A background characteristic that differs between the groups and affects the outcome is a [confounder], and it's what makes a raw comparison misleading.

In our diabetes example, look at baseline HbA1c — a measure of blood sugar over the past few months, taken before treatment. Patients on the newer SGLT2 drug tend to have higher baseline HbA1c than patients on metformin. Why? Because doctors tend to prescribe the newer drug to patients whose diabetes is more severe or less controlled. So if the SGLT2 group ends the study with higher HbA1c, is that the drug failing — or did that group simply start out sicker? With the raw data, you can't tell.

Treatment (SGLT2 inhibitor)   Control (metformin)

Before matching: the treatment group's baseline HbA1c is shifted to the right — they started out sicker (mean 8.9% vs. 8.1%). Toggle to After matching to see the goal: the two distributions sit almost on top of each other (mean 8.8% vs. 8.75%). Illustrative distributions built from the Table 1 values in Section 7.

The whole point of matching is to fix that: to control for the covariate when all we have is observational data — to get [covariate balance].

We do it by pairing each patient in the treatment group with a similar patient in the control group, and — this part matters — we do the matching before looking at the outcomes. We're blind to the outcomes while we build the groups, just like a trial is set up before anyone's outcome is known.

When there's simply nobody to match

Sometimes the matching process reveals that a treated patient has no similar patient in the control group. That patient has to be excluded — we can only include treated patients who plausibly could have been in the control group. The range of patients where both groups actually exist is called the [common support], and dropping patients outside it quietly changes who your answer applies to. Keep count of who you drop, and say so when you report results.

02

One covariate: imbalance, buckets, and a first match

Start simple, with a single covariate: baseline HbA1c. The problem that can occur is [covariate imbalance] — the distribution of the covariate we're trying to control for differs between the treatment and control groups.

A binary example makes it easiest to see. Suppose 80% of the treatment group are smokers and only 10% of the control group are. That's a big imbalance — and if smoking affects the outcome, a naive comparison of the groups mostly compares smokers to non-smokers, not drug to drug.

HbA1c is continuous, so to check its balance the same way, we bucket it into groups:

Baseline HbA1c groupRangeTreatment share (example)
Mild7.0% – 7.9%30%
Moderate8.0% – 8.9%40%
Severe9.0% and above30%

Bucketing a continuous covariate turns “are the distributions similar?” into a simple comparison of shares, group by group.

Now matching, in its simplest form: every patient in the treatment group gets a match from the control group with the same (or very similar) value of the covariate. Control patients who aren't matched are discarded from the analysis. If the treatment group is 30% mild, 40% moderate, 30% severe, the matched control group is built to be 30 / 40 / 30 as well. The covariate is now balanced — by construction.

03

Many covariates, fine balance, and who the effect is for

In reality there won't be one covariate to balance — there will be many. And there probably won't be a perfect control match for every treated patient. The idea is to get close enough that the distributions of the covariates are balanced between the groups, the way they would be in a trial.

Notice what a trial gives you, because it's the target: not identical patients, but groups that look the same as a whole. That's [stochastic balance] — the distributions (means, spreads, shapes) of the covariates are the same across the two groups, in expectation. You aren't matching clones; you're making the groups, in aggregate, statistically alike. In any one realized trial — or any one matched sample — small differences remain just by chance. Balance is a property we're aiming at, not a guarantee.

For example, say we also want to control for age. Now each treated patient needs a control patient who matches on HbA1c severity and is close in age — say, within ±3 years. That “within this much, and no more” rule is a [caliper], and we'll come back to calipers in Section 6.

Who is the effect for? The treated, usually

Look at what we just did: we took the treated group as given, and we built a control group that looks like them. So the combined matched sample has the covariate distribution of the treated group — and the effect we estimate is the effect of treatment on the treated:

ATT = E[ Y(1) − Y(0)  |  A = 1 ]
How to read it: for patients who actually got the treatment [A = 1], what's the average difference between the outcome they had on treatment [Y(1)] and the outcome they would have had without it [Y(0)]? The matched control patients stand in for that unobservable “would have had.” ATT is short for [average treatment effect on the treated].

That's different from the effect averaged over the entire population, treated and untreated alike — the [average treatment effect, ATE]. It's possible to match in a way that targets the ATE, but it's more involved and out of scope here. Most of the time in matching, we're estimating the ATT.

The assumption doing the heavy lifting

Matching only balances the covariates you measured. The claim that matching those is enough — that, once we condition on the measured covariates, treatment is as good as randomly assigned — is the [ignorability / no unmeasured confounding assumption]. It's an assumption, not something the data can prove. Section 9 is about stress-testing it.

Fine balance: exact as a group, without exact pairs

Sometimes you can't get an exact match for each individual patient — but you can still get the group distributions exactly right. That's [fine balance].

Consider four patients, controlling for HbA1c severity, smoking status, and age. We insist on an exact match on HbA1c severity. Patient 1 (treated) is severe, a smoker, age 40 — but the only severe control patient, Patient 2, is a non-smoker, age 25. Patient 4 is a smoker, age 40, like Patient 1 — but Patient 4's HbA1c is mild, so that pairing breaks our exact-severity rule. Patient 3 (treated) has the mirror-image problem.

PatientPairGroupHbA1c severitySmokingAge
1Match 1Treatment (SGLT2)Severe (10.5%)Smoker40
2Match 1Control (metformin)Severe (10.5%)Non-smoker25
3Match 2Treatment (SGLT2)Mild (7.2%)Non-smoker25
4Match 2Control (metformin)Mild (7.2%)Smoker40

Neither pair matches exactly on smoking or age. Now look at the two groups as a whole.

Match 1 with 2, and 3 with 4. Neither pair is an exact match — but in aggregate, both groups are identical on every covariate:

Share of groupTreatment (Patients 1 & 3)Control (Patients 2 & 4)
Severe / Mild HbA1c50% / 50%50% / 50%
Smoker / Non-smoker50% / 50%50% / 50%
Age 40 / Age 2550% / 50%50% / 50%

This is the statistical heart of the example: perfect balance on the [marginal distributions] — the overall percentage of smokers, of severe cases, of 40-year-olds in each group — while relaxing the [joint distribution]: no single pair is simultaneously Severe and Smoker and 40. Various statistical packages will construct a fine balance for you automatically.

04

How many matches? The bias–variance trade-off

Three common shapes:

Choosing between them is a [bias–variance trade-off]. The easiest way to feel it is picky quality vs. sample size.

Imagine 100 treated patients on the new drug and a big pool of 2,000 control patients on the old one. You're shopping in that pool to build a comparison group. Take one treated patient whose baseline HbA1c is 9.50%:

MatchControl's baseline HbA1cGap from 9.50%
1st closest9.50%0.00
2nd closest9.45%0.05
3rd closest9.35%0.15
4th closest9.20%0.30
5th closest9.05%0.45

Average of all five controls: 9.31% — a 0.19-point gap from the treated patient's 9.50%. That gap is leftover confounding [residual bias] sneaking back in.

1-to-1 matching: low bias, high variance. You only need the single best twin in the pool of 2,000, so the baseline difference is basically zero — almost no confounding bias. But you keep only 100 controls and discard 1,900. If that one matched control happens to be a fluke — they caught a bad flu, started an extreme diet — that noise lands at full weight on your estimate. Small sample, wider standard errors: high variance.

Many-to-1 matching: higher bias, lower variance. Use 5 controls per treated patient and you keep 500 controls instead of 100. Individual flukes average out and confidence intervals shrink. But matches 3, 4, and 5 are progressively worse — in a pool with more mild patients than severe ones, reaching deeper means grabbing healthier and healthier controls, and the bias that matching was supposed to remove creeps back.

Built directly from the five matches in the table above. The bias bar is the gap between 9.50% and the average HbA1c of the k controls used. The variance bar is relative: standard error shrinks roughly like 1/√k as the control group grows. It is an illustration of the shape of the trade-off, not a calculation for a real dataset.

05

Measuring distance between patients

To match, we first have to quantify how far apart each treated patient is from every control patient. The standard tool is a formula called the [Mahalanobis distance]:

Dij = √[ (xi − xj)T S−1 (xi − xj) ]
How to read it, piece by piece: xi and xj are the two patients, each written as a list [vector] of all their covariate values. (xi − xj) is just the difference on every covariate. S is the [covariance matrix] of the covariates — it records how spread out each covariate is and how they move together — and S−1 is what does the rescaling. In plain terms: a difference of 1 point only counts as “big” if patients normally differ by much less than that. A 1-point HbA1c gap is large; a 1-year age gap is nothing. Mahalanobis distance puts every covariate on a fair, spread-adjusted scale, and it also avoids double-counting two covariates that basically measure the same thing [correlation]. You don't compute this by hand — software does — but that's what it's doing.
Prove it — a tiny hand-check

Suppose, just to keep the arithmetic friendly, that HbA1c and age are uncorrelated, with standard deviations of 1.3 points and 10 years. Then Mahalanobis distance is simply the distance between the standardized differences. Patient A is (HbA1c 9.5, age 60).

  • Patient B is (8.2, 50): standardized differences are 1.3/1.3 = 1.0 and 10/10 = 1.0, so D = √(1² + 1²) = 1.41.
  • Patient C is (9.5, 40): standardized differences are 0 and 20/10 = 2.0, so D = √(0² + 2²) = 2.00.

So B is the closer match for A — even though C matches A exactly on HbA1c — because a 20-year age gap is two standard deviations, and that outweighs B's one-standard-deviation gap on each of two covariates. Raw, unscaled distances would have called the 20-year gap and the 1.3-point gap incomparable — which is exactly the problem the scaling solves.

One variation worth knowing: the [robust Mahalanobis distance] computes the distance from the ranks of the covariates instead of their raw values. The motivation is outliers: one extreme patient shouldn't be able to stretch the scale and distort everyone else's distances. Ranks cap how much any single value can pull.

Exact matches on the covariates you refuse to compromise on

If some covariates must match exactly — say, HbA1c severity group — there's a neat trick. Compute all the distances as usual, then add a rule: if two patients differ at all on a must-match covariate, set their distance to infinity. Those pairs will now never be chosen, whatever their other covariates look like. Exactness enforced by arithmetic.

06

Finding the matches: greedy, optimal, and calipers

Now that we have a distance between every treated patient and every control patient, we need an algorithm to actually pick the pairs. There are two families — greedy and optimal — and, in the real world, the control pool is usually much larger than the treatment group, which is what makes either of them feasible.

Greedy (nearest-neighbor) matching

  1. Randomly order the treated patients.
  2. Go down the list. For each treated patient, pick the control patient with the smallest distance.
  3. Once a control patient is used, remove them from the pool so they can't be matched again [matching without replacement].

For many-to-one matching, the same idea repeats: cycle through the treated list again to find each patient's second match, and so on — though software implementations differ in the details, so check your package's documentation for exactly what it does. In R, MatchIt is the standard package here.

The benefits: it's fast [computationally efficient] and easy to understand. The drawback: the order you process the treated patients in matters. Each individual pick is the best available at that moment, but taken together the pairs may not minimize the total distance across all matches — early patients can grab controls that would have been a much better fit for someone later, and late patients can be left with poor matches. Greedy is not [globally optimal].

Calipers: a maximum distance you'll tolerate

A [caliper] is a threshold: a maximum distance beyond which you refuse to match, full stop. During matching, if a treated patient's closest available control is farther away than the caliper, that treated patient is discarded rather than badly matched.

Calipers also help enforce the [positivity assumption]: every patient pattern in the study needs a genuine, non-zero chance of appearing in either group — formally, 0 < P(A = a | X) < 1 for every treatment value a (a = 0 and a = 1). For our binary treatment that's exactly the same statement as 0 < P(A = 1 | X) < 1, because the chance of being a control is whatever is left over: P(A = 0 | X) = 1 − P(A = 1 | X), so if the treatment chance sits strictly between 0 and 1, the control chance automatically does too. A treated patient with no control patient anywhere nearby is a warning sign that patients like them essentially never appear in the control group — that they had close to a zero chance of being there. The caliper turns that warning sign into an exclusion rule.

Optimal matching

Optimal matching flips the priority. Any individual treated patient might not get their single best control — but the sum of the distances across all matches, taken together, is as small as it can possibly be [globally minimized].

The cost is computation: in principle, the algorithm has to weigh combinations of pairings, and the size of the problem grows with the number of possible pairings — treated × control:

Possible pairingsExamplePractical verdict
100,000100 treated × 1,000 controlsLikely feasible
1,000,0001,000 treated × 1,000 controlsMay take a while — still feasible
1,000,000,000100,000 treated × 10,000 controlsProbably not feasible

Rules of thumb, not hard limits — real feasibility depends on the algorithm, the sparsity of the problem, and your machine. In R, the packages are optmatch and rcbalance.

Sparse optimal matching: split the problem

A practical compromise: split the dataset into subgroups — by region, by condition, by any variable it's sensible to match within — and run optimal matching inside each subgroup. With 10 roughly equal regions, the number of candidate pairings falls to about a tenth of the original problem (each region holds roughly 1/100 of the pairings, and there are 10 of them), and because the algorithm's runtime grows faster than the number of pairings, the time saving is even bigger than that. Smaller problems, same global-optimality idea inside each block.

07

Did it work? Checking balance

Matching is a claim — “the groups are now comparable” — and balance checking is how you show your work. The standard display is Table 1: the table (usually the first in a study, hence the name) that compares the covariate distributions of the two groups before and after matching.

Here is a Table 1 for our diabetes example. Read it across: before matching, the groups differ a lot — especially on baseline HbA1c, the very variable doctors used to choose the drug. After 1-to-1 matching, 212 of the 240 treated patients found a match (28 had no comparable control and were dropped — remember Section 1: say who was dropped), and every difference shrinks to near zero.

CovariateBefore matchingAfter matching
Treated (n=240)Control (n=960)|SMD|Treated (n=212)Control (n=212)|SMD|
Age, years — mean (SD)58.4 (10.2)54.9 (11.0)0.3357.9 (10.4)57.6 (10.6)0.03
Baseline HbA1c, % — mean (SD)8.9 (1.3)8.1 (1.2)0.648.8 (1.25)8.75 (1.22)0.04
BMI — mean (SD)32.4 (5.8)30.1 (5.4)0.4132.1 (5.6)31.9 (5.5)0.04
Smoker — %34%19%0.3532%31%0.02
Male — %52%47%0.1051%50%0.02
Severe baseline HbA1c (≥ 9%) — %46%22%0.5243%42%0.02

Illustrative Table 1 constructed for this example. Every SMD shown is the value the formula below produces from the means, SDs, and percentages in its row — check one by hand if you like (the prove-it box shows you how).

The standardized mean difference

The comparison number in each row is the [standardized mean difference, SMD]: the difference between the two groups' means, divided by a pooled standard deviation, so the result is in “standard deviation units” and comparable across covariates measured on completely different scales.

SMD = ( x̄treated − x̄control ) / √[ ( streated² + scontrol² ) / 2 ]
For a yes/no covariate [binary], the same idea uses proportions: SMD = (ptreated − pcontrol) / √[ ( ptreated(1−ptreated) + pcontrol(1−pcontrol) ) / 2 ]. Report the absolute value, |SMD|, when all you care about is the size of the imbalance.
Prove it — check the HbA1c row

Before matching: (8.9 − 8.1) / √[(1.3² + 1.2²)/2] = 0.8 / √[(1.69 + 1.44)/2] = 0.8 / √1.565 = 0.8 / 1.251 ≈ 0.64. ✓  After matching: (8.8 − 8.75) / √[(1.25² + 1.22²)/2] ≈ 0.05 / 1.235 ≈ 0.04. ✓

How to read an SMD — the widely used rule of thumb:

There is nothing magic about 0.1 — it's a convention, not a cliff edge. The point of the scale is that it means the same thing for age in years, HbA1c in percent, and smoking as a percentage.

The same picture, as a graph: the Love plot

Before matching   After matching   Dashed line = |SMD| 0.1

A [Love plot] (named for biostatistician Thomas Love) puts every covariate's |SMD| on one chart. Before matching, several covariates sit far to the right of the 0.1 line. After matching, every dot hugs zero. If a covariate is still out past the line, that's your to-do list for re-matching — you can see it at a glance, no table required.

Why not just run a t-test on each covariate?

You could test each covariate for a “statistically significant difference” — but significance answers the wrong question here, because a p-value mixes together how big a difference is with how much data you have. Put the two formulas side by side and the difference is visible:

SMD = ( x̄1 − x̄0 ) / spooled    |    t = ( x̄1 − x̄0 ) / ( spooled × √(1/n1 + 1/n0) )
The SMD divides by the standard deviation — the natural spread of the values from person to person, which stays roughly the same whether you sample 200 patients or 200,000. There is no sample size anywhere in the formula. The t-statistic divides by the standard error, which contains n — and shrinks toward zero as n grows. So with a big enough sample, a t-test will call a trivially small imbalance “significant,” and with a small sample it will wave through a large one. Balance is a property of this sample in front of you, not a claim about a population — so use the measure that only measures the difference itself: the SMD.
08

Analyzing the outcome after matching

The groups are built and balanced — and we still haven't looked at the outcomes. Now we do. Everything in this section respects the pairing: the matched pairs are the unit of the design, and the analysis has to act like it.

Binary outcome: permutation (randomization) tests

Let the outcome be: did the patient's HbA1c fall by 3 percentage points or more? Code it 1 for yes, 0 for no. Six matched pairs might look like this:

Matched pairTreated outcomeControl outcomePair type
100Concordant — same
211Concordant — same
301Discordant — different
410Discordant — different
501Discordant — different
611Concordant — same

Pairs where both patients have the same outcome are [concordant pairs]; pairs where they differ are [discordant pairs]. The treated group's total [test statistic] here is 0+1+0+1+0+1 = 3.

Now the permutation idea [also called a randomization test or exact test]. The null hypothesis is the sharp one: the treatment made no difference for anyone [Fisher's sharp null hypothesis]. If that's true, then within each pair, which patient happened to get the treatment was effectively a coin flip — so swapping the two outcome labels inside a pair changes nothing about what “no effect” looks like.

So: for each discordant pair, flip a coin. Heads, swap the pair's outcomes between treated and control; tails, leave them. (Concordant pairs need no flip — swapping identical values changes nothing.) Recompute the treated total. Do it again. And again — say 1,000 or 10,000 times. You build the distribution of the treated total in a world where treatment does nothing, and then ask: how unusual is the total we actually observed, 3?

Press the button. Each run flips a fair coin inside each of the 3 discordant pairs and recounts the treated total. The exact distribution is known for this tiny example — possible totals are 2, 3, 4, 5 with probabilities 1/8, 3/8, 3/8, 1/8 — so your simulation should land close to those shares.

A teaching moment hiding in this example: the observed total, 3, sits almost exactly in the middle of the no-effect distribution. For a two-sided test, “as or more extreme than 3 in either direction” covers essentially every possible outcome — the exact two-sided p-value is 1.0. Six pairs with this pattern contain no evidence of a treatment effect at all, and the permutation distribution shows you why at a glance, before any test is run.

In practice, for a binary outcome: McNemar's test

The permutation logic above is the theory. Day to day, for paired binary outcomes, you run [McNemar's test]. First collapse the pairs into a 2×2 summary — count pairs by (treated outcome, control outcome):

Control outcome = 1Control outcome = 0
Treated outcome = 121  (b)
Treated outcome = 02  (c)1

Only the discordant cells carry information about a treatment difference: b = 1 pair where only the treated patient had the outcome, c = 2 pairs where only the control patient did. McNemar's statistic, with the usual continuity correction, is (|b − c| − 1)² / (b + c) = (1 − 1)² / 3 = 0 — a p-value of 1.0, matching the permutation result above. In R: mcnemar.test(matrix(c(2, 2, 1, 1), nrow = 2)) — note that R fills matrices down columns, so that ordering reproduces this table.

Continuous outcome: paired comparisons

The same idea works for a continuous outcome — here, the change in HbA1c itself rather than a yes/no version of it:

Matched pairTreated: HbA1c changeControl: HbA1c changePair difference (Treated − Control)
1−1.8−1.1−0.7
2−2.6−1.4−1.2
3−0.9−1.2+0.3
4−3.1−1.0−2.1
5−1.5−0.8−0.7
6−2.2−1.6−0.6

Illustrative values. The effect estimate is the average of the pair differences: (−0.7 −1.2 +0.3 −2.1 −0.7 −0.6) / 6 = −5.0 / 6 ≈ −0.83 percentage points — on average, treated patients' HbA1c fell about 0.83 points more than their matched controls'. Check the arithmetic yourself; that's the prove-it habit.

You can permutation-test this too: flip the sign of each pair difference by coin flip, recompute the average, repeat, and see where −0.83 falls in the no-effect distribution. In practice, the everyday tool is the [paired t-test] on the pair differences — the same average difference, with a standard error computed from how much the pair differences vary.

Worth knowing exist — for further research

Other outcome models built for matched or clustered designs include [conditional logistic regression] (binary outcomes), a [stratified Cox model] (time-to-event outcomes), and [generalized estimating equations, GEE]. The common thread: the standard errors must account for the matched design. Analyzing matched data as if the patients were independent throws away the design you worked to build.

09

What matching can't fix: sensitivity analysis

Even after carefully matching on every confounder we can see — baseline HbA1c, smoking, age — an observational study still has a problem matching cannot solve: [unmeasured confounding / hidden bias]. There may be factors that influenced which drug a patient got and how they did, which were never captured in the data (or which we chose not to use).

Example: “patient motivation,” as expressed through diet and exercise habits. It's not in our dataset. But suppose providers tend to prescribe the SGLT2 inhibitor to patients they judge to be motivated — good diet, regular exercise. Then part of the SGLT2 group's better outcomes might be their habits, not the drug. Matching on everything we measured can't remove a variable we never measured.

[Sensitivity analysis] is the stress test that follows. At a high level it asks one question: how much hidden bias would there have to be for the result we observed to change? If it takes a lot of hidden bias to overturn the result, the study is robust. If a little would do it, the study is fragile — and we can measure “how much” mathematically.

The ideal world, inside one pair

Take one matched pair: Patient i got the new drug, Patient j got the standard drug, and on paper they're clinical twins — same baseline HbA1c, smoking status, age. Call their true (pre-treatment) probabilities of being prescribed the new drug πi and πj.

The sensitivity parameter: Γ (Gamma)

Since we can't measure the hidden factor, we instead bound how much it could have tilted things, using a multiplier called [Γ, the Rosenbaum sensitivity parameter]:

1/Γ  ≤  [ πi / (1 − πi) ] / [ πj / (1 − πj) ]  ≤  Γ
The middle term is a ratio of odds — Patient i's odds of treatment divided by Patient j's odds. Γ is a “hidden bias knob”: it caps how far apart those odds can be, inside any matched pair, because of unmeasured factors. Γ = 1 means no advantage either way (equal odds, a fair coin). Γ = 1.1 means one patient could have up to 1.1× the odds — about 10% higher odds, not 10% higher probability — of the other. Γ = 2 means up to double the odds. The bound is two-sided [the “sandwich”] because the hidden factor could have favored either patient: the ratio could be Γ or 1/Γ, and we don't know which.

What Γ means inside a single pair, in probability terms: with no hidden bias (Γ = 1), each of the two “twins” had a 50% chance of being the treated one. With hidden bias bounded by Γ, that chance for a given patient can range from 1/(1+Γ) up to Γ/(1+Γ). At Γ = 2, the split could secretly have been as lopsided as 33% / 67% instead of 50% / 50%.

How the stress test works in practice

We don't re-match anything. We keep the same pairs and repeat the outcome test, assuming the worst case: that the hidden bias is working entirely in the treatment's favor. As Γ rises from 1, the worst-case p-value rises with it — we're steadily allowing “maybe it was the hidden habits, not the drug” to explain more of the result. The value of Γ where the worst-case p-value crosses 0.05 — where the result stops being statistically significant — is the [tipping point].

A rough guide to reading a tipping point:

Tipping point ΓHow to read it
1.0 – 1.2Very fragile — even a tiny unmeasured bias could explain the result away
1.3 – 1.5Moderately sensitive
1.6 – 2.0Moderately robust — often considered a reassuring range
2.0 – 3.0Highly robust
Above 3.0Very robust

Treat this as a rough interpretive heuristic, not a universal scale: a Γ only means something relative to the confounding you did measure. The strongest reporting puts the tipping point next to the observed influence of known strong confounders — “an unmeasured factor would have to matter more than baseline HbA1c itself” is a claim a reader can actually judge.

Report it in plain language either way: “an unmeasured confounder would have to increase a patient's odds of receiving the new drug by 2.5-fold before it could invalidate our conclusion” is a sentence any decision-maker can weigh.

10

Propensity scores: one number instead of many covariates

Everything so far matched on the covariates themselves. There's a second route: match on one summary number per patient — the [propensity score], the probability that a patient with their particular covariate values receives the treatment:

π(x) = P( A = 1  |  X = x )
In practice we estimate it by fitting a [logistic regression] of treatment (1/0) on the covariates and taking each patient's predicted probability. A few lines of code — the logistic regression itself is a separate topic, covered in its own playbook.

Why is matching on this one number legitimate? Because of the propensity score's [balancing property]: among patients with the same propensity score, the distribution of covariates is the same in the treatment and control groups — stochastic balance, achieved through the score:

X  ⊥  A  |  π(X)
What this line says, intuitively: the symbol ⊥ means “is independent of” — knowing one tells you nothing about the other — and the bar | means “once we hold this fixed.” So read it as: once we hold the propensity score fixed — that is, once we look only at patients who all share the same score — knowing a patient's covariates tells you nothing more about whether they got treated. Inside that slice, treatment no longer tracks the covariates at all; who got treated behaves like a coin flip (a weighted one — see below). That's exactly why balance follows.

Written out as shares instead of symbols, the same property says:

P( X = x  |  A = 1, π(X) = p )  =  P( X = x  |  A = 0, π(X) = p )

Breaking down the notation (spreadsheet version)

Put together, the formula says: filter to patients who all share the same propensity score, and the share with any given covariate combination is the same in the treated group as in the control group.

Note carefully what it does not say: it does not say individual patients i and j have identical covariates (xi = xj). It's a statement about group distributions, not about pairs.

Wait — didn't fine balance relax the joint distribution?

Good catch, and yes — this really is different from fine balance, in an instructive way. Fine balance (Section 3) is something we construct in a matched sample: we enforced the marginal distributions exactly — same % smokers, same % severe, same % age 40 in each group — and we got that precisely by giving up on the joint pairing inside each pair. Look back at that table: the treated group's combinations were (severe, smoker, 40) and (mild, non-smoker, 25), while the control group's were (severe, non-smoker, 25) and (mild, smoker, 40). Marginals identical; joint combinations completely different.

The propensity balancing property is a stronger claim, but of a different kind. It isn't something we construct pair by pair — it's a fact about the population, at an exact propensity score: because x in the formula above is a whole combination of values, not one variable at a time, the equality covers the joint distribution too — in expectation. Two honest caveats keep that from being magic: (1) it holds at an exact score value, while real matching groups together patients with similar scores, so in a real matched dataset the balance — marginal and joint — is approximate, with the usual finite-sample wobble; and (2) it still says nothing about individual pairs being identical. Short version: fine balance = exact marginals, by construction, in your sample. Propensity balance = marginals and joints, in expectation, in the population at a fixed score — which your matched sample then approximates.

Why the coin-flip picture makes it intuitive

Filter the data to patients whose propensity score is 0.7, and picture 100 of them. Each of these patients had, by construction of the score, a 70% probability of receiving the treatment — as if, without looking at their outcomes, we walked down the rows flipping a coin weighted 70% heads / 30% tails, heads meaning “treated.” A weighted coin, flipped independently of everything else about the patient, cannot sort smokers into one group and non-smokers into the other — so, in expectation, the covariate mix is the same among the treated and the controls in this slice.

Two careful words in that paragraph matter. First, in expectation: a 0.7 score doesn't guarantee exactly 70 of the 100 patients were treated — the realized count bounces around 70 the way coin flips do. What the balancing property guarantees is the mechanism: treatment behaves like a (weighted) coin flip that doesn't depend on the covariates, so there is no systematic sorting. In a large group, the shares land close to equal; in a small one, expect wobble — the same fine print that applies to stochastic balance in a real randomized trial. Second, this works for joint combinations too, not just one covariate at a time: the coin doesn't know whether a patient is simultaneously “mild HbA1c, smoker, and young,” so that combination is also distributed evenly in expectation.

That's the whole mathematical permission slip: because balance is preserved through the score, matching on the score is matching on the covariates — compressed.

11

Propensity score matching in practice

How do we actually do it? First, look. Plot the distribution [histogram] of propensity scores, split by treatment group, and check the [overlap]:

How to read this chart: it's one chart, mirrored. Control patients (metformin) are plotted above the axis and treatment patients (SGLT2) below it, over the same propensity-score scale — so wherever you see bars on both sides at the same score, both groups exist there and matching is possible. Counts are illustrative patients per score bin. Good overlap: across most of the range, both sides have bars. Toggle to Poor overlap to see the problem case.

One pattern to expect in the good-overlap picture: the treated group's scores lean higher than the control group's. That isn't circular — the score is a pre-treatment prediction, built only from baseline covariates. It leans that way because the covariate patterns that make treatment likely (more severe disease, for instance) genuinely are more common among the patients who ended up treated. The score summarizes why the groups differed in the first place.

In the poor-overlap picture, look at the ends. Near a score of 0, there are (almost) only control patients: patients like them essentially never got the treatment. Near 1, only treated patients. Those regions are deterministic, and matching there would mean pretending a comparison exists where it doesn't — a violation of the positivity assumption from Section 6.

Trimming the tails

The fix is to restrict the study to the region where both groups exist — [trimming] to the common support. The simple version of the rule:

Cleaner, but not free: trimming changes the population your estimate describes, and if you trim a lot of treated patients, your ATT is now the effect on the matchable treated — which is exactly why we report who was dropped. (More refined overlap rules exist; the min/max rule is the transparent starting point.)

The logit transformation: stretching the scale

Sometimes nearly all the scores pile up near zero — for a rarely prescribed drug, a typical probability of treatment might be 0.01. Distances between scores like 0.008 and 0.02 are tiny on the probability scale even though one patient was two-and-a-half times as likely to be treated as the other. The fix is to match on the [logit transformation] of the score instead:

logit(p) = ln( p / (1 − p) )
The log of the odds. It stretches the cramped (0, 1) probability scale out across the whole real number line — small probabilities spread apart, and equal ratios of odds become equal distances. Matching and distance measurement get much better behaved on this scale.

Calipers on the propensity score

Same caliper idea as Section 6, now on the logit-of-score scale. The widely used rule of thumb: a caliper of 0.2 times the standard deviation of the logit of the propensity score. Fine-tune it — 0.1 for a tighter, pickier match; wider than 0.2 if you're discarding too many treated patients — and recognize the familiar trade-off underneath: a tighter caliper means fewer matches — the matches you keep are closer (less bias), but with fewer patients your estimate wobbles more (more variance), and more treated patients get discarded entirely. A wider caliper admits more potential matches — more patients, so less variance — but the extra matches are worse ones (more bias).

Once the propensity-score matches are made, everything from Sections 7–9 applies unchanged: check balance (on the original covariates, not just the score), analyze outcomes respecting the pairs, and run the sensitivity analysis.

The whole job, in code (R sketch) — the shape of a real run, to adapt, not to copy blindly:

# 1. Estimate propensity scores + match (logit-scale distance)
library(MatchIt)
m <- matchit(treated ~ baseline_hba1c + smoker + age + bmi + male,
             data = diabetes, method = "nearest", distance = "glm",
             link = "logit", ratio = 1,
             caliper = 0.2)          # 0.2 x SD of logit score (std.caliper)

# 2. Check balance BEFORE touching outcomes
summary(m)                          # SMDs, before vs after
plot(m, type = "love")              # the Love plot from Section 7

# 3. Analyze outcomes respecting the pairs
matched_data <- match.data(m)       # carries pair ids (subclass)
# binary outcome: mcnemar.test(...) on the pair table (Section 8)
# continuous outcome: paired t-test on pair differences (Section 8)

# 4. Stress-test: sensitivity analysis for hidden bias (Section 9)
# e.g. rbounds / sensitivitymv packages implement Rosenbaum bounds

Package names from the draft and standard practice: MatchIt for matching, optmatch / rcbalance for optimal matching. The order of the steps is the discipline: estimate, match, check balance, and only then look at outcomes.

12

The playbook, on one page

  1. Frame it. No trial is possible; the data are observational. Name the treatment, the control, the outcome — and the running example you'll judge everything against. Decide that you're estimating the effect on the treated [ATT] unless you deliberately target the whole population [ATE].
  2. List your confounders — before outcomes. Baseline variables that plausibly influenced both who got treated and how they did. Matching can only balance what you measured; the rest is Section 9's problem.
  3. Choose the matching route. Match on the covariates directly (Mahalanobis distance, exact constraints where a covariate is non-negotiable), or compress the covariates into a propensity score and match on its logit.
  4. Set the knobs, knowing the trade-off. One-to-one vs. many-to-one; greedy vs. optimal; a caliper that refuses bad matches. Every knob is a bias–variance choice: more matches = less variance, worse matches.
  5. Respect the support. Check overlap. Trim to common support, enforce positivity, count and report every patient you drop — your answer now describes the patients who remain.
  6. Check balance — outcomes still untouched. Table 1 and a Love plot. Target |SMD| < 0.1 on every covariate, and don't judge balance with p-values. Not balanced? Change the matching, not the standard.
  7. Analyze the outcome as a paired design. Permutation logic underneath; McNemar for binary outcomes, a paired t-test for continuous ones, matched-design standard errors throughout.
  8. Stress-test it. Sensitivity analysis: report the Γ tipping point — how strong an unmeasured confounder would have to be to overturn the result — next to the strength of the confounders you did measure.
  9. Report the whole trail. Who was dropped, what balance looked like before and after, the effect for the treated patients you actually kept, and how fragile it is. That trail is the credibility of an observational study.

Matching doesn't turn observational data into a randomized trial. It does something almost as useful: it makes the comparison honest — groups that start alike on everything you can see, an analysis that respects how they were built, and a stated price, in Γ, for everything you can't.