-
-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy path35-matching-methods.Rmd
More file actions
2973 lines (2005 loc) · 162 KB
/
Copy path35-matching-methods.Rmd
File metadata and controls
2973 lines (2005 loc) · 162 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Matching Methods {#sec-matching-methods}
Matching is a strategy that aims to eliminate, or at least minimize, potential sources of bias by constructing treatment and comparison groups with similar observed characteristics. By doing so, any observed differences in outcomes between these groups can be attributed more confidently to the treatment itself rather than to other factors. In observational research, matching is frequently combined with [Difference-in-Differences] (DiD) techniques to address issues of selection bias, particularly when multiple pre-treatment outcomes are available.
> Matching is defined as "any method that aims to equate (or "balance") the distribution of covariates in the treated and control groups." [@stuart2010matching, pp. 1]
Matching is particularly useful when:
- Outcomes are **not yet observed**, such as in follow-up studies, and you want to construct balanced treatment/control groups.
- Outcomes **are available**, but you wish to **reduce model dependence** and **improve robustness**.
> Conceptually, matching can also be viewed through the lens of **missing data**, since we never observe both potential outcomes $(Y_i^T, Y_i^C)$ for any unit. Hence, this topic closely relates to [Imputation (Missing Data)].
## Introduction and Motivation
### Why Match?
In many observational studies, researchers do not have the luxury of randomization. Subjects (people, firms, schools, etc.) typically select or are selected into treatment based on certain observed and/or unobserved characteristics. This can introduce systematic differences (selection bias) that confound causal inference. Matching attempts to approximate a randomized experiment by "balancing" these observed characteristics between treated and non-treated (control) units.
- **Goal:** Reduce model dependence and clarify causal effects by ensuring that treated and control subjects have sufficiently comparable covariates.
- **Challenge:** Even if matching achieves balance in observed covariates, any **unobserved** confounders remain a threat to identification (i.e., Matching is only a selection observables identification strategy). Matching does not magically fix bias from unobserved variables.
To understand why causal inference is difficult in observational studies, consider:
$$
\begin{aligned} E(Y_i^T | T) - E(Y_i^C | C) &= E(Y_i^T - Y_i^C | T) + \underbrace{[E(Y_i^C | T) - E(Y_i^C | C)]}_{\text{Selection Bias}} \\ \end{aligned} $$
- The term $E(Y_i^T - Y_i^C | T)$ is the **causal effect** (specifically the ATT).
- The term $E(Y_i^C | T) - E(Y_i^C | C)$ reflects **selection bias** due to systematic differences in the untreated potential outcome across treated and control groups.
Random assignment ensures:
$$ E(Y_i^C | T) = E(Y_i^C | C) $$
which eliminates selection bias. In observational data, however, this equality rarely holds.
Matching aims to mimic randomization by **conditioning on covariates** $X$:
$$ E(Y_i^C | X, T) = E(Y_i^C | X, C) $$
For example, propensity score matching achieves this balance by conditioning on the **propensity score** $P(X)$:
$$ E(Y_i^C | P(X), T) = E(Y_i^C | P(X), C) $$
(See [Propensity Scores](#sec-propensity-scores) for further discussion.)
The [Average Treatment Effect] (ATE) under matching is typically estimated as:
$$ \frac{1}{N_T} \sum_{i=1}^{N_T} \left(Y_i^T - \frac{1}{N_{C_i}} \sum_{j \in \mathcal{C}_i} Y_j^C\right) $$
where $\mathcal{C}_i$ denotes the matched controls for treated unit $i$.
Standard Errors in Matching
- Matching does not have a closed-form standard error for the ATE or ATT.
- Therefore, we rely on bootstrapping to estimate uncertainty.
> **Note**: Matching tends to yield larger standard errors than [OLS][Ordinary Least Squares] because it reduces the effective sample size by discarding unmatched observations.
------------------------------------------------------------------------
### Matching as "Pruning"
Matching can be thought of as "**pruning**" (a **preprocessing** step) [@king2017balance]. The goal is to **prune** unmatched or poorly matched units before conducting analysis, reducing model dependence.
Without Matching:
- Imbalanced data → Model dependence → Researcher discretion → Biased estimates
With Matching:
- Balanced data → Reduces discretion → More credible causal inference
+-----------------------+------------------------+----------------------+
| Balance of Covariates | Complete Randomization | Fully Exact Matching |
+=======================+========================+======================+
| **Observed** | On average | Exact |
+-----------------------+------------------------+----------------------+
| **Unobserved** | On average | On average |
+-----------------------+------------------------+----------------------+
: Degree of Balance Across Designs
Fully blocked or exactly matched designs are not just *as good as* a complete randomization on these criteria, they dominate it. Imbalance is reduced because covariates are forced into alignment rather than left to chance; model dependence falls because the analyst is no longer using regression to paper over baseline differences; efficiency and statistical power rise because residual variation is no longer eaten by group differences; bias from observable heterogeneity is eliminated by construction rather than averaged away; the resulting estimates are more robust to specification choices; and the up-front design cost typically pays itself back in cleaner inference and a smaller required sample.
------------------------------------------------------------------------
### Matching with DiD
Matching can be fruitfully combined with DiD when multiple pre-treatment periods are available. Such designs can help correct for selection bias under certain assumptions:
- When selection bias is symmetric around the treatment date, standard DID (implemented symmetrically around the treatment date) remains consistent [@chabe2015analysis].
- If selection bias is asymmetric, simulations by @chabe2015analysis show that symmetric DID still outperforms matching alone, although having more pre-treatment observations can improve matching performance.
In short, matching is not a universal solution but often provides a helpful preprocessing step before conducting DiD or other causal estimation methods [@smith2005does].
------------------------------------------------------------------------
## Key Assumptions
Matching relies on the standard set of assumptions underpinning [selection on observables](#sec-selection-on-observables), also known as the back-door criterion (see [Assumptions for Identifying Treatment Effects]). When these assumptions hold, matching can yield valid estimates of causal effects by constructing treated and control groups that are comparable on observed covariates.
1. **Strong** [Conditional Ignorability Assumption] (Unconfoundedness)
Also known as the **no hidden bias** or **ignorability** assumption:
$$
(Y(0), Y(1)) \perp T \big| X
$$
This implies that, conditional on covariates $X$, treatment assignment is independent of the potential outcomes. In other words, there are no unobserved confounders once we adjust for $X$.
- This assumption is not testable, but it is more plausible when all relevant confounders are observed and included in $X$.
- It is often satisfied approximately when unobserved covariates are highly correlated with the observed ones.
- If unobserved variables are unrelated to $X$, you can:
- Conduct sensitivity analysis to test the robustness of your estimates.
- Apply design sensitivity techniques: If unobserved confounding is suspected, methods such as [@heller2009split]'s design sensitivity approaches or bounding approaches (e.g., the `rbounds` R package) can be used to test how robust findings are to hidden bias.
> This is the cornerstone assumption of matching: without it, causal inference from observational data is generally invalid.
------------------------------------------------------------------------
2. [Overlap (Positivity) Assumption] **(Common Support)**
$$
0 < P(T=1 \mid X) < 1 \quad \forall X
$$
This condition ensures that, for every value of the covariates $X$, there is a positive probability of receiving both treatment and control.
- If this assumption fails, there are regions of covariate space where either treatment or control units are absent, making comparison impossible.
- Matching enforces this assumption by discarding units outside of the region of common support.
> This pruning step is both a strength and a limitation of matching: it improves internal validity at the cost of generalizability.
------------------------------------------------------------------------
3. [Stable Unit Treatment Value Assumption] (SUTVA)
SUTVA requires that:
- The potential outcomes for any individual unit do not depend on the treatment assignment of other units.
That is, there are **no interference or spillover effects** between units.
- Mathematically, $Y_i(T_i)$ depends only on $T_i$, not on $T_j$ for any $j \neq i$.
- Violations can occur in settings like:
- Education (peer effects)
- Epidemiology (disease transmission)
- Marketing (network influence)
> In cases with known spillover, efforts should be made to reduce interactions or explicitly model interference.
------------------------------------------------------------------------
Summary of Assumptions for Matching
+------------------------------+-------------------------------------------------------------------------------------+----------------------------------------------+
| Assumption | Description | Notation |
+==============================+=====================================================================================+==============================================+
| **Conditional Ignorability** | No hidden confounding after conditioning on covariates | $(Y(0), Y(1)) \perp T \mid X$ |
+------------------------------+-------------------------------------------------------------------------------------+----------------------------------------------+
| **Overlap (Positivity)** | Each unit has a non-zero probability of treatment and control assignment | $0 < P(T=1 \mid X) < 1$ |
+------------------------------+-------------------------------------------------------------------------------------+----------------------------------------------+
| **SUTVA** | No interference between units; one unit's outcome unaffected by another's treatment | $Y_i(T_i)$ unaffected by $T_j$ for $j \ne i$ |
+------------------------------+-------------------------------------------------------------------------------------+----------------------------------------------+
These three assumptions form the foundation for valid causal inference using matching methods.
------------------------------------------------------------------------
## Framework for Generalization
With the assumptions in place, the next step is to fix notation that will let us write the matching estimand precisely and reason about which average effect (ATE versus ATT) a particular procedure recovers.
Let:
- $P_t$, $P_c$: treated and control populations
- $N_t$, $N_c$: random samples drawn from $P_t$, $P_c$
- $\mu_i$, $\Sigma_i$: means and covariance matrices of the $p$ covariates in group $i \in \{t, c\}$
- $X_j$: vector of covariates for individual $j$
- $T_j \in \{0, 1\}$: treatment indicator (1 = treated, 0 = control)
- $Y_j$: observed outcome
- Assume $N_t < N_c$ (i.e., more controls than treated)
The conditional treatment effect is:
$$
\tau(x) = R_1(x) - R_0(x), \quad \text{where } R_1(x) = E[Y(1) \mid X = x], \quad R_0(x) = E[Y(0) \mid X = x]
$$
If we assume **homogeneous treatment effects**, then $\tau(x) = \tau$ for all $x$ (this is a homogeneity assumption on the treatment effect, not the parallel-trends assumption from [DiD](#sec-difference-in-differences), which is a separate restriction on counterfactual *time trends*). If the homogeneity assumption is relaxed, we can still estimate an **average** effect over the distribution of $X$.
### Common Estimands
- [Average Treatment Effect] (ATE): Average causal effect across all units.
- [Average Treatment Effect on the Treated] (ATT): Causal effect for treated units only.
------------------------------------------------------------------------
## Steps for Matching
Implementing a matching analysis is a four-step pipeline: pick a way to measure how close two units are, choose an algorithm to pair them up, check that the resulting comparison group is actually balanced, and only then estimate the treatment effect. The three ingredients below, a propensity score, a distance metric, and a covariate set assumed to satisfy ignorability, recur across the steps that follow.
- Propensity score: summarizes $P(T=1|X)$
- Distance metric: measures similarity
- Covariates: assumed to satisfy ignorability
### Step 1: Define "Closeness" (Distance Metrics)
Matching requires a distance metric to define similarity between treated and control units.
#### Variable Selection Guidelines
- Include as many pre-treatment covariates as possible to support conditional ignorability.
- Avoid post-treatment variables, which introduce bias.
- Be cautious with variables (e.g., heavy drug users) highly correlated with the outcome (e.g., heavy drinkers) but not treatment (e.g., mediators).
- If variables are uncorrelated with both treatment and outcome, the cost of inclusion is small.
#### Distance Measures
+----------------------------+----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
| Method | Formula | Notes |
+============================+====================================================+==========================================================================================================================================+
| **Exact Matching** | $D_{ij} = 0$ if $X_i = X_j$, else $\infty$ | Only feasible in low dimensions; can be relaxed via [Coarsened Exact Matching] |
+----------------------------+----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
| **Mahalanobis Distance** | $D_{ij} = (X_i - X_j)' \Sigma^{-1}(X_i - X_j)$ | $\Sigma$ (var-covar matrix of $X$) from control group if ATT is of interest or pooled if ATE is of interest; sensitive to dimensionality |
+----------------------------+----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
| **Propensity Score** | $D_{ij} = |e_i - e_j|$ | Where $e_k$ is the estimated propensity score $P(T=1 \mid X_k)$ for unit $k$. |
| | | |
| | | Advanced: **Prognostic scores** [@hansen2008prognostic] require modeling $E[Y(0)|X]$, so they depend on the outcome model. |
+----------------------------+----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
| **Logit Propensity Score** | $D_{ij} = |\text{logit}(e_i) - \text{logit}(e_j)|$ | More stable in tails of distribution |
+----------------------------+----------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
> Tip: in high dimensions, exact and Mahalanobis matching perform poorly. Combining Mahalanobis with propensity score calipers can improve robustness [@rubin2000combining].
Advanced methods for longitudinal setting:
- Marginal Structural Models: for time-varying treatments [@robins2000marginal]
- Balanced Risk Set Matching: for survival analysis [@li2001balanced]
------------------------------------------------------------------------
### Step 2: Matching Algorithms
The choice of matching algorithm shapes a familiar trade-off. Aggressive algorithms that demand near-exact agreement on every covariate (for instance, exact matching or fine [Coarsened Exact Matching](#sec-cem)) deliver sharp balance but can prune away most of the sample, leaving an estimand that applies to a narrow slice of the population and inflating variance. Permissive algorithms (such as nearest-neighbor matching on a single propensity score) retain more units and yield estimates with smaller standard errors, but residual imbalance can leak into bias. Researchers should think of each algorithm as picking a point on this balance versus sample retention frontier; the [`MatchingFrontier`](#sec-matching-methods) tooling discussed later makes that frontier explicit. The algorithms below differ chiefly in how they navigate that frontier.
1. Nearest Neighbor Matching
Nearest-neighbor matching is the workhorse default. Each treated unit is paired with the closest available control under a chosen distance metric, producing an intuitive matched sample that mimics a pair-randomized experiment. It is easy to implement and analyze, but its quality depends entirely on the underlying distance metric and the supply of controls. When controls are scarce or covariates are many, "closest" can still be far, and the bias-variance trade-off becomes acute.
- Greedy matching: fast, but suboptimal under competition for controls.
- Optimal matching: minimizes global distance across all pairs.
- Ratio matching (k:1): useful when controls outnumber treated; choose $k$ using trade-off between bias and variance [@rubin1996matching].
- With vs. without replacement:
- With replacement: improves matching quality, but requires frequency weights for analysis.
- Without replacement: simpler, but less flexible.
2. Subclassification, Full Matching, and Weighting
These methods generalize nearest-neighbor approaches by assigning fractional weights. Rather than discarding controls that fail to find a partner, every unit receives a weight that reflects its similarity to units in the other group. The result is a softer form of pruning that often retains the entire sample, trading some interpretability of "matched pairs" for efficiency. Weighting estimators are particularly attractive when the target estimand is the [ATE](#sec-counterfactual-estimators) rather than the [ATT](#sec-counterfactual-estimators), since they use information from both treated and control units symmetrically.
- Subclassification: partition into strata based on propensity score (e.g., quintiles).
- Full Matching: each treated unit is matched to a weighted group of controls (and vice versa) to minimize average within-set distance.
- Weighting: weighting techniques use propensity scores to estimate the ATE. However, if the weights are extreme, the resulting variance may be inflated (not due to the underlying probabilities, but due to the estimation procedure itself). To address this issue, researchers can employ (1) weight trimming or (2) doubly robust methods when using propensity scores for weighting or matching.
- Inverse Probability of Treatment Weighting (IPTW): $$
w_i = \frac{T_i}{\hat{e}_i} + \frac{1 - T_i}{1 - \hat{e}_i}
$$
- Odds weighting: $$
w_i = T_i + (1 - T_i)\frac{\hat{e}_i}{1 - \hat{e}_i}
$$
- Kernel weighting: smooth average over control group (popular in economics).
- Trimming and Doubly-Robust Methods: reduce variance due to extreme weights.
3. Assessing Common Support
- Use propensity score histograms to visualize overlap.
- Units outside the convex hull of $X$ (i.e., unmatched regions) can be discarded.
- Lack of overlap indicates that some comparisons are extrapolations, not empirical matches.
------------------------------------------------------------------------
### Step 3: Diagnosing Match Quality
#### Balance Diagnostics
Matching aims to balance the covariate distributions between treated and control units. A well-matched sample satisfies:
$$
\tilde{p}(X \mid T=1) \approx \tilde{p}(X \mid T=0)
$$
where $\tilde{p}$ is the empirical distribution.
1. Numerical Checks
- Standardized differences in means (most common): should be $< 0.1$
- Standardized difference of propensity scores: should be $< 0.25$ [@rubin2001using]
- Variance ratio of propensity scores: between 0.5 and 2.0 [@rubin2001using]
- Variance of residuals after regression on propensity score (treated vs. control) for each covariate
> Avoid using p-values as diagnostics: they conflate balance with statistical power and are sensitive to sample size.
2. Graphical Diagnostics
- Empirical Distribution Plots
- Quantile-Quantile (QQ) Plots
- Love Plots: summarize standardized differences before/after matching
------------------------------------------------------------------------
### Step 4: Estimating Treatment Effects
1. After Matching
- With k:1 matching with replacement, use weights to adjust for reuse of controls.
- Use regression adjustment on matched samples to improve precision and adjust for residual imbalance.
2. After Subclassification or Full Matching
- ATT: weight subclass-specific estimates by number of treated units.
- ATE: weight by total units per subclass.
3. Variance Estimation
Must reflect uncertainty in both:
1. The matching procedure (sampling and distance calculation) (Step 3)
2. The outcome model (regression, difference-in-means, etc.) (Step 4)
Often estimated via bootstrapping.
------------------------------------------------------------------------
## Special Considerations
1. Handling Missing Data
- Use generalized boosted models or multiple imputation [@qu2009propensity].
2. Violation of Ignorability
Strategies when unobservables bias treatment:
- Use pre-treatment measures of outcome
- Compare multiple control groups
- Conduct sensitivity analysis:
- Quantify correlation between unobserved confounders and both treatment and outcome to nullify the observed effect
------------------------------------------------------------------------
## Choosing a Matching Strategy
No single matching algorithm dominates across applications. The right choice depends on the target estimand (see [counterfactual estimators](#sec-counterfactual-estimators)), the ratio of treated to control units, the dimensionality and type of covariates, and where the analyst wants to land on the balance versus sample retention trade-off. The guidance below sketches sensible defaults and is best read alongside the [balance checks](#sec-balance-checks) used to validate any choice.
### Based on Estimand
- ATE: use IPTW or full matching
- ATT:
- If many controls ($N_c > 3N_t$): k:1 nearest neighbor without replacement
- If few controls: subclassification, full matching, or odds weighting
### Based on Diagnostics
- If balanced: proceed with regression on matched samples
- If imbalance on few covariates: Mahalanobis matching on those
- If imbalance on many covariates: Try k:1 matching with replacement
### Selection Criteria
- Minimize standardized differences across many covariates
- Especially prioritize prognostic covariates
- Minimize number of covariates with large ($>0.25$) imbalance [@diamond2013genetic]
Matching is not one-size-fits-all. Choose methods based on the target estimand, data structure, and diagnostic results.
A short translation of the algorithmic choices into applied guidance: reach for [propensity score](#sec-propensity-scores) methods when covariates are many but the propensity model is plausibly well specified and the target is a population estimand; reach for [Mahalanobis distance](#sec-mahalanobis) when covariates are few, continuous, and well measured, and when emulating a fully blocked design is the priority; reach for [Coarsened Exact Matching](#sec-cem) when the analyst wants transparent, ex ante control over imbalance and is willing to coarsen continuous covariates into substantively meaningful bins; reach for [Genetic Matching](#sec-genetic-matching) when distance-metric specification is itself uncertain and the dataset is large enough to absorb its computational cost; reach for entropy balancing or weighting when treated units are few and discarding any of them would be unacceptable. Sensitivity to unobserved confounding (covered in [Rosenbaum bounds](#sec-rosenbaum-bounds) and the broader discussion of [selection on unobservables](#sec-selection-on-unobservables)) should accompany any matching analysis, since none of these algorithms can rescue a violation of [conditional ignorability](#sec-conditional-ignorability-assumption).
------------------------------------------------------------------------
## Matching vs. Regression
Matching and regression are two core strategies used in observational studies to adjust for differences in covariates $X$ and estimate causal effects. While both aim to remove bias due to confounding, they approach the problem differently, particularly in how they weight observations, handle functional form assumptions, and address covariate balance.
Neither method can resolve the issue of unobserved confounding, but each can be a powerful tool when used with care and supported by appropriate diagnostics.
- Matching emphasizes covariate balance by pruning the dataset to retain only comparable units. It is nonparametric, focusing on ATT.
- Regression (typically [OLS][Ordinary Least Squares]) emphasizes functional form and allows for model-based adjustment, enabling the estimation of ATE and continuous or interactive effects of treatment.
Both matching and regression assign implicit or explicit weights to observations during estimation:
- Matching: weights observations more heavily in strata with more treated units, aligning with the ATT estimand.
- [OLS][Ordinary Least Squares] regression: places more weight on strata where the variance of treatment assignment is highest, i.e., when groups are approximately balanced between treated and control (near 50/50).
This results in differing estimands and sensitivities:
> Important Caveat: if your [OLS][Ordinary Least Squares] estimate is biased due to unobserved confounding, your matching estimate is likely biased too. Both depend on the [selection on observables](#sec-selection-on-observables) assumption.
We explore the difference in estimands between matching and regression, especially for estimating the ATT.
### Matching Estimand
Suppose we want the treatment effect on the treated:
$$
\delta_{\text{TOT}} = E[Y_{1i} - Y_{0i} \mid D_i = 1]
$$
Using the [Law of Iterated Expectation]:
$$
\delta_{\text{TOT}} = E\left[ E[Y_{1i} \mid X_i, D_i = 1] - E[Y_{0i} \mid X_i, D_i = 1] \mid D_i = 1 \right]
$$
Assuming conditional independence:
$$
E[Y_{0i} \mid X_i, D_i = 0] = E[Y_{0i} \mid X_i, D_i = 1]
$$
Then,
$$
\begin{aligned}
\delta_{TOT} &= E [ E[ Y_{1i} | X_i, D_i = 1] - E[ Y_{0i}|X_i, D_i = 0 ]|D_i = 1 ] \\
&= E\left[ E[Y_i \mid X_i, D_i = 1] - E[Y_i \mid X_i, D_i = 0] \mid D_i = 1 \right] \\
&= E[\delta_X |D_i = 1]
\end{aligned}
$$
where $\delta_X$ is an $X$-specific difference in means at covariate value $X_i$
If $X_i$ is discrete, the matching estimand becomes:
$$
\delta_M = \sum_x \delta_x P(X_i = x \mid D_i = 1)
$$
where $P(X_i = x |D_i = 1)$ is the probability mass function for $X_i$ given $D_i = 1$
By Bayes' rule:
$$
P(X_i = x \mid D_i = 1) = \frac{P(D_i = 1 \mid X_i = x) P(X_i = x)}{P(D_i = 1)}
$$
So,
$$
\begin{aligned}
\delta_M &= \frac{\sum_x \delta_x P (D_i = 1 | X_i = x) P (X_i = x)}{\sum_x P(D_i = 1 |X_i = x)P(X_i = x)} \\
&= \sum_x \delta_x \frac{ P (D_i = 1 | X_i = x) P (X_i = x)}{\sum_x P(D_i = 1 |X_i = x)P(X_i = x)}
\end{aligned}
$$
------------------------------------------------------------------------
### Regression Estimand
In regression:
$$
Y_i = \sum_x d_{ix} \beta_x + \delta_R D_i + \varepsilon_i
$$
- $d_{ix}$ = indicator that $X_i = x$
- $\beta_x$ = baseline outcome at $X = x$
- $\delta_R$ = regression estimand
Then,
$$
\begin{aligned}
\delta_R &= \frac{\sum_x \delta_x [P(D_i = 1 | X_i = x) (1 - P(D_i = 1 | X_i = x))]P(X_i = x)}{\sum_x [P(D_i = 1| X_i = x)(1 - P(D_i = 1 | X_i = x))]P(X_i = x)} \\
&= \sum_x \delta_x \frac{[P(D_i = 1 | X_i = x) (1 - P(D_i = 1 | X_i = x))]P(X_i = x)}{\sum_x [P(D_i = 1| X_i = x)(1 - P(D_i = 1 | X_i = x))]P(X_i = x)}
\end{aligned}
$$
------------------------------------------------------------------------
### Interpretation: Weighting Differences
The distinction between matching and regression comes down to how covariate-specific treatment effects $\delta_x$ are weighted:
+-------------+--------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------+
| Type | Weighting Function | Interpretation | Makes Sense Because... |
+=============+======================================================================================+==============================================================================================+=====================================================================================================================+
| Matching | $P(D_i = 1 \mid X_i = x)$ | Weights more heavily where more treated units exist (ATT-focused) | We're interested in the effect on the treated, so more weight is placed where treated units are observed |
+-------------+--------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------+
| Regression | $\begin{aligned}P(D_i = 1 \mid X_i = x)\\(1 - P(D_i = 1 \mid X_i = x))\end{aligned}$ | Weights more where treatment assignment has high variance (i.e., near 50/50 treated/control) | These cells provide lowest-variance estimates of $\delta_x$, assuming the treatment effect is homogenous across $X$ |
+-------------+--------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------+
### Summary Table: Matching vs. Regression
+----------------------------+----------------------------------------------------------+-----------------------------------------------------+
| Feature | Matching | Regression (OLS) |
+============================+==========================================================+=====================================================+
| **Functional Form** | Less parametric; no assumption of linearity | Parametric; usually assumes linearity |
+----------------------------+----------------------------------------------------------+-----------------------------------------------------+
| **Primary Estimand** | ATT (effect on the treated) | ATE or effects of continuous/interacted treatments |
+----------------------------+----------------------------------------------------------+-----------------------------------------------------+
| **Balance** | Enforces balance via matched samples | Does not guarantee balance |
+----------------------------+----------------------------------------------------------+-----------------------------------------------------+
| **Diagnostics** | Covariate SMDs, QQ plots, empirical distributions | Residual plots, R-squared, heteroskedasticity tests |
+----------------------------+----------------------------------------------------------+-----------------------------------------------------+
| **Unobserved Confounding** | Cannot be resolved; assumes ignorability | Same limitation |
+----------------------------+----------------------------------------------------------+-----------------------------------------------------+
| **Standard Errors** | Larger; require bootstrapping | Smaller; closed-form under assumptions |
+----------------------------+----------------------------------------------------------+-----------------------------------------------------+
| **Best Used When** | High control-to-treated ratio; misspecification concerns | Model is correctly specified; sufficient overlap |
+----------------------------+----------------------------------------------------------+-----------------------------------------------------+
------------------------------------------------------------------------
### Qualitative Comparisons
+---------------------------------------------------------------------+----------------------------------------------------------------------+
| Matching | Regression |
+=====================================================================+======================================================================+
| Not sensitive to the form of covariate-outcome relationship | Can estimate continuous or interacted treatment effects |
+---------------------------------------------------------------------+----------------------------------------------------------------------+
| Easier to assess balance and interpret diagnostics | Easier to estimate the effects of all covariates, not just treatment |
+---------------------------------------------------------------------+----------------------------------------------------------------------+
| Facilitates clear visual evaluation of overlap and balance | Less intuitive diagnostics; model diagnostics used |
+---------------------------------------------------------------------+----------------------------------------------------------------------+
| Helps when treatment is rare (prunes clearly incomparable controls) | Performs better with balanced treatment assignment |
+---------------------------------------------------------------------+----------------------------------------------------------------------+
| Forces explicit enforcement of common support | May extrapolate outside the support of covariate distributions |
+---------------------------------------------------------------------+----------------------------------------------------------------------+
------------------------------------------------------------------------
## Software and Practical Implementation
Many R packages provide functionality for implementing the various matching methods discussed above. Below is an overview of some popular options:
- MatchIt:\
Implements a wide range of matching methods (nearest neighbor, optimal, full, subclassification, exact, etc.). It focuses on "preprocessing" data before a final outcome analysis.
- Matching:\
Provides multivariate and propensity score matching, including options for *exact* and *nearest neighbor* matching. The package also offers functions to evaluate balance and to conduct sensitivity analyses.
- cem ([Coarsened Exact Matching](#sec-cem)):\
Uses a coarsening approach to create strata within which exact matching can be performed. This can reduce imbalance by discarding units that do not overlap in coarsened covariate space.
- optmatch:\
Enables *optimal matching* with variable matching ratios and full matching, allowing for flexible group constructions that minimize overall distance.
- MatchingFrontier [@king2017balance]:\
Finds the "frontier" of matching solutions by balancing sample size (or other constraints) against covariate balance. Allows analysts to see trade-offs in real time.
- CBPS (Covariate Balancing Propensity Score):\
Estimates propensity scores such that covariate balance is directly optimized. This can help avoid iterative re-specification of the propensity score model.
- PanelMatch [@rauh2025panelmatch]:\
Tailored to panel (longitudinal) data settings, providing matching methods that exploit repeated observations over time (e.g., for DID-type analyses in a time-series cross-sectional environment).
- PSAgraphics:\
Specializes in visual diagnostics for propensity score analyses, offering graphical tools to inspect balance and common support.
- rbounds:\
Conducts Rosenbaum bounds sensitivity analysis on matched data. Researchers can examine how a hypothetical unmeasured confounder could undermine their estimated treatment effects.
- twang:\
Implements *generalized boosted models (GBM)* to estimate propensity scores. Often used for weighting approaches such as inverse probability weighting (IPW).
In practice, the choice of software and methods hinges on the study design, the nature of the data, and the researcher's theoretical expectations regarding treatment assignment.
------------------------------------------------------------------------
## Selection on Observables {#sec-selection-on-observables}
In observational studies, treatment assignment is typically not randomized. This poses a challenge when estimating causal effects, as treated and control groups may differ systematically. A central assumption that allows us to estimate causal effects from such data is selection on observables, also known as unconfoundedness or conditional independence.
Suppose we observe a binary treatment indicator $T_i \in {0, 1}$ and an outcome $Y_i$. Each unit $i$ has two potential outcomes:
- $Y_i(1)$: outcome if treated
- $Y_i(0)$: outcome if untreated
However, only one of these outcomes is observed for each unit. The average treatment effect on the treated (ATT) is:
$$
\text{ATT} = \mathbb{E}[Y(1) - Y(0) \mid T = 1]
$$
To identify this from data, we invoke the conditional independence assumption:
$$
(Y(0), Y(1)) \perp T \mid X
$$
This assumption means that after controlling for covariates $X$, treatment is as good as randomly assigned. A secondary assumption is overlap:
$$
0 < \mathbb{P}(T = 1 \mid X = x) < 1 \quad \text{for all } x
$$
This ensures that for every covariate profile, there is a positive probability of being both treated and untreated.
Matching attempts to approximate the conditions of a randomized experiment by creating a comparison group that is similar to the treated group in terms of observed covariates. Instead of relying solely on model-based adjustment (e.g., regression), matching balances the covariate distribution across treatment groups before estimation.
------------------------------------------------------------------------
### Matching with `MatchIt`
We demonstrate the matching procedure using the `lalonde` dataset, a classic example in the causal inference literature, which investigates the effect of job training on subsequent earnings.
```{r}
library(MatchIt)
data("lalonde")
```
We focus on estimating the effect of the treatment (`treat`) on earnings in 1978 (`re78`), conditional on covariates.
------------------------------------------------------------------------
#### Step 1: Planning the Analysis
Before conducting matching, several strategic decisions must be made:
- Estimand: do you want ATT (effect on treated), ATE (effect in population), or ATC (effect on controls)? Matching typically targets the ATT.
- Covariate Selection: only include pre-treatment variables that are potential confounders, i.e., that affect both the treatment assignment and the outcome [@austin2011optimal; @vanderweele2019principles].
- Distance Measure: choose how to quantify similarity between units (e.g., propensity score, Mahalanobis distance).
- Matching Method: determine the method (e.g., nearest neighbor, full matching, genetic matching).
For our demonstration, we focus on ATT using propensity score matching.
------------------------------------------------------------------------
#### Step 2: Assessing Initial Imbalance
We first assess imbalance between treatment and control groups before matching.
```{r}
# Estimate propensity scores with logistic regression
m.out0 <- matchit(
treat ~ age + educ + race + married + nodegree + re74 + re75,
data = MatchIt::lalonde,
method = NULL, # no matching, only estimates propensity scores
distance = "glm"
)
# Summary of balance statistics before matching
summary(m.out0)
```
This summary provides:
- Standardized mean differences
- Variance ratios
- Propensity score distributions
These diagnostics help us understand the extent of covariate imbalance.
------------------------------------------------------------------------
#### Step 3: Implementing Matching
1. Nearest Neighbor Matching (1:1 without Replacement)
```{r}
m.out1 <- matchit(
treat ~ age + educ + race + married + nodegree + re74 + re75,
data = MatchIt::lalonde,
method = "nearest",
distance = "glm"
)
```
Matching is based on estimated propensity scores. Each treated unit is matched to the closest control unit.
Assess Balance After Matching
The code below produces the post-matching balance diagnostics for the nearest-neighbour 1:1 propensity-score match: a jitter plot of the propensity-score distribution and QQ plots for selected covariates.
```{r mm-nearest-balance-diagnostics}
summary(m.out1, un = FALSE) # only show post-matching stats
# Visual diagnostic: jitter plot of propensity scores
plot(m.out1, type = "jitter", interactive = FALSE)
# QQ plot for individual covariates
plot(m.out1, type = "qq", which.xs = c("age", "re74"))
```
**Interpretation**: Good matches will show overlapping distributions of covariates across groups, and standardized differences should be below 0.1 in absolute value.
2. Full Matching
Allows many-to-one or one-to-many matches, minimizing overall distance.
```{r}
m.out2 <- matchit(
treat ~ age + educ + race + married + nodegree + re74 + re75,
data = MatchIt::lalonde,
method = "full",
distance = "glm",
link = "probit"
)
summary(m.out2, un = FALSE)
```
3. Exact Matching
Only matches units with exactly the same covariate values (usually categorical):
```{r}
m.out3 <- matchit(
treat ~ race + nodegree,
data = MatchIt::lalonde,
method = "exact"
)
```
4. Optimal Matching
Minimizes the total distance between matched units across the sample.
```{r}
m.out4 <- matchit(
treat ~ age + educ + re74 + re75,
data = MatchIt::lalonde,
method = "optimal",
ratio = 2
)
```
5. Genetic Matching
Searches over weights assigned to covariates to optimize balance.
```{r}
m.out5 <- matchit(
treat ~ age + educ + re74 + re75,
data = MatchIt::lalonde,
method = "genetic"
)
```
------------------------------------------------------------------------
#### Step 4: Estimating Treatment Effects
Once matching is complete, we use the matched data to estimate treatment effects.
```{r}
library(lmtest)
library(sandwich)
# Extract matched data
matched_data <- match.data(m.out1)
# Estimate ATT with robust standard errors
model <- lm(re78 ~ treat + age + educ + race + re74 + re75,
data = matched_data,
weights = weights)
coeftest(model, vcov. = vcovCL, cluster = ~subclass)
```
The coefficient on `treat` is our estimate of the ATT. The weights and subclass clustering account for the matched design.
### Reporting Standards
To ensure transparency and reproducibility, always report the following:
1. Matching method (e.g., nearest neighbor, genetic)
2. Distance metric (e.g., propensity score via logistic regression)
3. Covariates matched on, and justification for their inclusion
4. Balance statistics (e.g., standardized mean differences before/after)
5. Sample sizes: total, matched, unmatched, discarded
6. Estimation model: whether treatment effects are estimated using regression adjustment, with or without weights
7. Assumptions: especially unconfoundedness and overlap
------------------------------------------------------------------------
### Optimization-Based Matching via `designmatch`
For more advanced applications, the `designmatch` package provides matching methods based on combinatorial optimization.
```{r}
library(designmatch)
```
Notable methods:
- `distmatch()`: Distance-based matching with custom constraints
- `bmatch()`: Bipartite matching using linear programming
- `cardmatch()`: Cardinality matching for maximum matched sample size with balance constraints
- `profmatch()`: Profile matching for stratified treatment allocation
- `nmatch()`: Non-bipartite matching (e.g., in interference settings)
------------------------------------------------------------------------
### MatchingFrontier
As mentioned in `MatchIt`, you have to make trade-off (also known as bias-variance trade-off) between balance and sample size. An automated procedure to optimize this trade-off is implemented in `MatchingFrontier` [@king2017balance], which solves this joint optimization problem.
Following `MatchingFrontier` [guide](https://projects.iq.harvard.edu/files/frontier/files/using_matchingfrontier.pdf)
```{r, message=FALSE, eval=FALSE}
# library(devtools)
# install_github('ChristopherLucas/MatchingFrontier')
library(MatchingFrontier)
data("lalonde", package = "MatchIt")
# choose var to match on
match.on <-
colnames(lalonde)[!(colnames(lalonde) %in% c('re78', 'treat'))]
match.on
# Mahanlanobis frontier (default)
mahal.frontier <-
makeFrontier(
dataset = lalonde,
treatment = "treat",
match.on = match.on
)
mahal.frontier
# L1 frontier
L1.frontier <-
makeFrontier(
dataset = lalonde,
treatment = 'treat',
match.on = match.on,
QOI = 'SATT',
metric = 'L1',
ratio = 'fixed'
)
L1.frontier
# estimate effects along the frontier
# Set base form
my.form <-
as.formula(re78 ~ treat + age + black + education
+ hispanic + married + nodegree + re74 + re75)
# Estimate effects for the mahalanobis frontier
mahal.estimates <-
estimateEffects(
mahal.frontier,
're78 ~ treat',
mod.dependence.formula = my.form,
continuous.vars = c('age', 'education', 're74', 're75'),
prop.estimated = .1,
means.as.cutpoints = TRUE
)
# Estimate effects for the L1 frontier
L1.estimates <-
estimateEffects(
L1.frontier,
're78 ~ treat',
mod.dependence.formula = my.form,
continuous.vars = c('age', 'education', 're74', 're75'),
prop.estimated = .1,
means.as.cutpoints = TRUE
)
# Plot covariates means
# plotPrunedMeans()
# Plot estimates (deprecated)
# plotEstimates(
# L1.estimates,
# ylim = c(-10000, 3000),
# cex.lab = 1.4,
# cex.axis = 1.4,
# panel.first = grid(NULL, NULL, lwd = 2,)
# )
# Plot estimates
plotMeans(L1.frontier)
# parallel plot
parallelPlot(
L1.frontier,
N = 400,
variables = c('age', 're74', 're75', 'black'),
treated.col = 'blue',
control.col = 'gray'
)
# export matched dataset
# take 400 units
matched.data <- generateDataset(L1.frontier, N = 400)
```
------------------------------------------------------------------------
### Propensity Scores {#sec-propensity-scores}
Propensity score methods are widely used for estimating causal effects in observational studies, where random assignment to treatment and control groups is not feasible. Conceptually, the propensity score collapses a high-dimensional vector of covariates into a single scalar (the conditional probability of treatment), and matching, weighting, or stratifying on that scalar is sufficient to remove confounding from the *observed* covariates. The appeal is dimensional: instead of searching for control units that look similar across many variables at once, the analyst searches along a one-dimensional probability axis. The cost is that two units sharing the same propensity score can still differ markedly in covariate space, which is why propensity score methods trade balance on the joint distribution of $X$ for tractability. They are most defensible when the propensity model is well specified, the covariate set is rich enough to make [conditional ignorability](#sec-conditional-ignorability-assumption) credible, and [overlap](#sec-overlap-positivity-assumption) is strong.
The core idea is to mimic a randomized experiment by adjusting for confounding variables that predict treatment assignment. Formally, the propensity score is defined as the probability of assignment to treatment conditional on observed covariates [@rosenbaum1983central; @rosenbaum1985bias]:
$$
e_i(X_i) = P(T_i = 1 \mid X_i)
$$
where:
- $T_i \in {0, 1}$ is the binary treatment indicator for unit $i$,
- $X_i$ is a vector of observed pre-treatment covariates for unit $i$.
The key insight from @rosenbaum1983central is that conditioning on the propensity score is sufficient to remove bias due to confounding from observed covariates, under certain assumptions.
------------------------------------------------------------------------
#### Assumptions for Identification
To identify causal effects using propensity scores, the following assumptions must hold:
- Unconfoundedness / Conditional Independence Assumption (CIA):
$$
(Y_i(0), Y_i(1)) \perp T_i \mid X_i
$$
- Positivity (Overlap):
$$
0 < P(T_i = 1 \mid X_i) < 1 \quad \text{for all } i
$$
These assumptions ensure that for each unit, we can observe comparable treated and untreated units in the sample. Violations of positivity, especially in high-dimensional covariate spaces, are a critical weakness of propensity score matching.
------------------------------------------------------------------------
#### Why PSM Is Not Recommended Anymore
Despite its intuitive appeal, recent literature has strongly cautioned against using propensity score matching for causal inference [@king2019propensity]. The main criticisms are as follows:
- Imbalance: PSM often fails to achieve covariate balance better than simpler techniques like covariate adjustment via regression or exact matching. Matching on the propensity score is a *scalar reduction* of a multivariate distribution, and this reduction can distort multivariate relationships.
- Inefficiency: discarding unmatched units reduces statistical efficiency, especially when better estimators (e.g., inverse probability weighting or doubly robust estimators) can use all data.
- Model dependence: small changes in the specification of the propensity score model can lead to large changes in matches and estimated treatment effects.
- Bias: poor matches and irrelevant covariates can introduce additional bias rather than reduce it.
@abadie2016matching show that the asymptotic distribution of treatment effect estimators is sensitive to the estimation of the propensity score itself:
- The estimated propensity score can improve efficiency over using the true propensity score when estimating the [ATE](#sec-average-treatment-effect). Formally, the adjustment to the asymptotic variance is non-positive.
- However, for the [ATT](#sec-average-treatment-effect-on-the-treated), the sign of the adjustment is data-dependent. Estimation error in the propensity score can lead to misestimated confidence intervals: they may be too wide or too narrow.
This result suggests that even in large samples, failure to account for the estimation uncertainty in the propensity score can produce misleading inference.
A fundamental flaw in PSM is the asymmetry of match quality:
- If $X_c = X_t$, then it must be that $e(X_c) = e(X_t)$.
- However, the converse does not hold:\
$e(X_c) = e(X_t) \nRightarrow X_c = X_t$
Therefore, two units with identical propensity scores may still differ substantially in covariate space. This undermines the matching goal of achieving similarity across all covariates.
------------------------------------------------------------------------
#### Estimating the Propensity Score
Estimation of the propensity score is typically carried out using:
- Parametric models:
- Logistic regression:\
$$
\hat{e}_i = \frac{1}{1 + \exp(-X_i^\top \hat{\beta})}
$$
- Nonparametric / machine learning methods:
- Generalized Boosted Models (GBM)
- Boosted Classification and Regression Trees (CART)
- Random forests or Bayesian Additive Regression Trees (BART)
These machine learning approaches often yield better balance due to flexible functional forms, but they also complicate interpretation and inference.
------------------------------------------------------------------------