-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
31-matching-methods.Rmd
1497 lines (975 loc) · 53.1 KB
/
31-matching-methods.Rmd
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
Matching is a process that aims to close back doors - potential sources of bias - by constructing comparison groups that are similar according to a set of matching variables. This helps to ensure that any observed differences in outcomes between the treatment and comparison groups can be more confidently attributed to the treatment itself, rather than other factors that may differ between the groups.
Matching and DiD can use pre-treatment outcomes to correct for selection bias. From real world data and simulation, [@chabe2015analysis] found that matching generally underestimates the average causal effect and gets closer to the true effect with more number of pre-treatment outcomes. When selection bias is symmetric around the treatment date, DID is still consistent when implemented symmetrically (i.e., the same number of period before and after treatment). In cases where selection bias is asymmetric, the MC simulations show that Symmetric DID still performs better than Matching.
Matching is useful, but not a general solution to causal problems [@smith2005does]
**Assumption**: Observables can identify the selection into the treatment and control groups
**Identification**: The exclusion restriction can be met conditional on the observables
**Motivation**
Effect of college quality on earnings
- They ultimately estimate the treatment effect on the treated of attending a top (high ACT) versus bottom (low ACT) quartile college
**Example**
@aaronson2007teachers
Do teachers qualifications (causally) affect student test scores?
Step 1:
$$
Y_{ijt} = \delta_0 + Y_{ij(t-1)} \delta_1 + X_{it} \delta_2 + Z_{jt} \delta_3 + \epsilon_{ijt}
$$
There can always be another variable
Any observable sorting is imperfect
Step 2:
$$
Y_{ijst} = \alpha_0 + Y_{ij(t-1)}\alpha_1 + X_{it} \alpha_2 + Z_{jt} \alpha_3 + \gamma_s + u_{isjt}
$$
- $\delta_3 >0$
- $\delta_3 > \alpha_3$
- $\gamma_s$ = school fixed effect
Sorting is less within school. Hence, we can introduce the school fixed effect
Step 3:
Find schools that look like they are putting students in class randomly (or as good as random) + we run step 2
$$
\begin{aligned}
Y_{isjt} = Y_{isj(t-1)} \lambda &+ X_{it} \alpha_1 +Z_{jt} \alpha_{21} \\
&+ (Z_{jt} \times D_i)\alpha_{22}+ \gamma_5 + u_{isjt}
\end{aligned}
$$
- $D_{it}$ is an element of $X_{it}$
- $Z_{it}$ = teacher experience
$$
D_{it}=
\begin{cases}
1 & \text{ if high poverty} \\
0 & \text{otherwise}
\end{cases}
$$
$H_0:$ $\alpha_{22} = 0$ test for effect heterogeneity whether the effect of teacher experience ($Z_{jt}$) is different
- For low poverty is $\alpha_{21}$
- For high poverty effect is $\alpha_{21} + \alpha_{22}$
Matching is **selection on observables** and only works if you have good observables.
Sufficient identification assumption under Selection on observable/ back-door criterion (based on Bernard Koch's [presentation](https://www.youtube.com/watch?v=v9uf9rDYEMg&ab_channel=SummerInstituteinComputationalSocialScience))
- Strong conditional ignorability
- $Y(0),Y(1) \perp T|X$
- No hidden confounders
- Overlap
- $\forall x \in X, t \in \{0, 1\}: p (T = t | X = x> 0$
- All treatments have non-zero probability of being observed
- SUTVA/ Consistency
- Treatment and outcomes of different subjects are independent
Relative to [OLS][Ordinary Least Squares]
1. Matching makes the **common support** explicit (and changes default from "ignore" to "enforce")
2. Relaxes linear function form. Thus, less parametric.
It also helps if you have high ratio of controls to treatments.
For detail summary [@stuart2010matching]
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]
Equivalently, matching is a selection on observables identifications strategy.
**If you think your OLS estimate is biased, a matching estimate (almost surely) is too.**
Unconditionally, consider
$$
\begin{aligned}
E(Y_i^T | T) - E(Y_i^C |C) &+ E(Y_i^C | T) - E(Y_i^C | T) \\
= E(Y_i^T - Y_i^C | T) &+ [E(Y_i^C | T) - E(Y_i^C |C)] \\
= E(Y_i^T - Y_i^C | T) &+ \text{selection bias}
\end{aligned}
$$
where $E(Y_i^T - Y_i^C | T)$ is the causal inference that we want to know.
Randomization eliminates the selection bias.
If we don't have randomization, then $E(Y_i^C | T) \neq E(Y_i^C |C)$
Matching tries to do selection on observables $E(Y_i^C | X, T) = E(Y_i^C|X, C)$
[Propensity Scores] basically do $E(Y_i^C| P(X) , T) = E(Y_i^C | P(X), C)$
**Matching standard errors will exceed OLS standard errors**
The treatment should have larger predictive power than the control because you use treatment to pick control (not control to pick treatment).
The average treatment effect (ATE) is
$$
\frac{1}{N_T} \sum_{i=1}^{N_T} (Y_i^T - \frac{1}{N_{C_T}} \sum_{i=1}^{N_{C_T}} Y_i^C)
$$
Since there is no closed-form solution for the standard error of the average treatment effect, we have to use bootstrapping to get standard error.
Professor Gary King advocates instead of using the word "matching", we should use "**pruning**" (i.e., deleting observations). It is a preprocessing step where it prunes nonmatches to make control variables less important in your analysis.
Without Matching
- **Imbalance data** leads to **model dependence** lead to a lot of **researcher discretion** leads to **bias**
With Matching
- We have balance data which essentially erase human discretion
| Balance Covariates | Complete Randomization | Fully Exact |
|--------------------|------------------------|-------------|
| Observed | On average | Exact |
| Unobserved | On average | On average |
: Table \@ref(tab:Gary King - International Methods Colloquium talk 2015)
Fully blocked is superior on
- imbalance
- model dependence
- power
- efficiency
- bias
- research costs
- robustness
Matching is used when
- Outcomes are not available to select subjects for follow-up
- Outcomes are available to improve precision of the estimate (i.e., reduce bias)
Hence, we can only observe one outcome of a unit (either treated or control), we can think of this problem as missing data as well. Thus, this section is closely related to [Imputation (Missing Data)]
In observational studies, we cannot randomize the treatment effect. Subjects select their own treatments, which could introduce selection bias (i.e., systematic differences between group differences that confound the effects of response variable differences).
Matching is used to
- reduce model dependence
- diagnose balance in the dataset
Assumptions of matching:
1. treatment assignment is independent of potential outcomes given the covariates
- $T \perp (Y(0),Y(1))|X$
- known as ignorability, or ignorable, no hidden bias, or unconfounded.
- You typically satisfy this assumption when unobserved covariates correlated with observed covariates.
- But when unobserved covariates are unrelated to the observed covariates, you can use sensitivity analysis to check your result, or use "design sensitivity" [@heller2009split]
2. positive probability of receiving treatment for all X
- $0 < P(T=1|X)<1 \forall X$
3. Stable Unit Treatment value Assumption (SUTVA)
- Outcomes of A are not affected by treatment of B.
- Very hard in cases where there is "spillover" effects (interactions between control and treatment). To combat, we need to reduce interactions.
Generalization
- $P_t$: treated population -\> $N_t$: random sample from treated
- $P_c$: control population -\> $N_c$: random sample from control
- $\mu_i$ = means ; $\Sigma_i$ = variance covariance matrix of the $p$ covariates in group i ($i = t,c$)
- $X_j$ = $p$ covariates of individual $j$
- $T_j$ = treatment assignment
- $Y_j$ = observed outcome
- Assume: $N_t < N_c$
- Treatment effect is $\tau(x) = R_1(x) - R_0(x)$ where
- $R_1(x) = E(Y(1)|X)$
- $R_0(x) = E(Y(0)|X)$
- Assume: parallel trends hence $\tau(x) = \tau \forall x$
- If the parallel trends are not assumed, an average effect can be estimated.
- Common estimands:
- Average effect of the treatment on the treated (**ATT**): effects on treatment group
- Average treatment effect (**ATE**): effect on both treatment and control
Steps:
1. Define "closeness": decide distance measure to be used
1. Which variables to include:
1. Ignorability (no unobserved differences between treatment and control)
1. Since cost of including unrelated variables is small, you should include as many as possible (unless sample size/power doesn't allow you to because of increased variance)
2. Do not include variables that were affected by the treatment.
3. Note: if a matching variable (i.e., heavy drug users) is highly correlated to the outcome variable (i.e., heavy drinkers) , you will be better to exclude it in the matching set.
2. Which distance measures: more below
2. Matching methods
1. Nearest neighbor matching
1. Simple (greedy) matching: performs poorly when there is competition for controls.
2. Optimal matching: considers global distance measure
3. Ratio matching: to combat increase bias and reduced variation when you have k:1 matching, one can use approximations by @rubin1996matching.
4. With or without replacement: with replacement is typically better, but one needs to account for dependent in the matched sample when doing later analysis (can use frequency weights to combat).
2. Subclassification, Full Matching and Weighting
Nearest neighbor matching assign is 0 (control) or 1 (treated), while these methods use weights between 0 and 1.
1. Subclassification: distribution into multiple subclass (e.g., 5-10)
2. Full matching: optimal ly minimize the average of the distances between each treated unit and each control unit within each matched set.
3. Weighting adjustments: weighting technique uses propensity scores to estimate ATE. If the weights are extreme, the variance can be large not due to the underlying probabilities, but due to the estimation procure. To combat this, use (1) weight trimming, or (2) doubly -robust methods when propensity scores are used for weighing or matching.
1. Inverse probability of treatment weighting (IPTW) $w_i = \frac{T_i}{\hat{e}_i} + \frac{1 - T_i}{1 - \hat{e}_i}$
2. Odds $w_i = T_i + (1-T_i) \frac{\hat{e}_i}{1-\hat{e}_i}$
3. Kernel weighting (e.g., in economics) averages over multiple units in the control group.
3. Assessing Common Support
- common support means overlapping of the propensity score distributions in the treatment and control groups. Propensity score is used to discard control units from the common support. Alternatively, convex hull of the covariates in the multi-dimensional space.
3. Assessing the quality of matched samples (Diagnose)
- Balance = similarity of the empirical distribution of the full set of covariates in the matched treated and control groups. Equivalently, treatment is unrelated to the covariates
- $\tilde{p}(X|T=1) = \tilde{p}(X|T=0)$ where $\tilde{p}$ is the empirical distribution.
- Numerical Diagnostics
1. standardized difference in means of each covariate (most common), also known as"standardized bias", "standardized difference in means".
2. standardized difference of means of the propensity score (should be \< 0.25) [@rubin2001using]
3. ratio of the variances of the propensity score in the treated and control groups (should be between 0.5 and 2). [@rubin2001using]
4. For each covariate, the ratio fo the variance of the residuals orthogonal to the propensity score in the treated and control groups.
Note: can't use hypothesis tests or p-values because of (1) in-sample property (not population), (2) conflation of changes in balance with changes in statistical power.
- Graphical Diagnostics
- QQ plots
- Empirical Distribution Plot
4. Estimate the treatment effect
1. After k:1
1. Need to account for weights when use matching with replacement.
2. After Subclassification and Full Matching
1. Weighting the subclass estimates by the number of treated units in each subclass for ATT
2. Weighting by the overall number of individual in each subclass for ATE.
3. Variance estimation: should incorporate uncertainties in both the matching procedure (step 3) and the estimation procedure (step 4)
**Notes**:
- With missing data, use generalized boosted models, or multiple imputation [@qu2009propensity]
- Violation of ignorable treatment assignment (i.e., unobservables affect treatment and outcome). control by
- measure pre-treatment measure of the outcome variable
- find the difference in outcomes between multiple control groups. If there is a significant difference, there is evidence for violation.
- find the range of correlations between unobservables and both treatment assignment and outcome to nullify the significant effect.
- Choosing between methods
- smallest standardized difference of mean across the largest number of covariates
- minimize the standardized difference of means of a few particularly prognostic covariates
- fest number of large standardized difference of means (\> 0.25)
- [@diamond2013genetic] automates the process
- In practice
- If ATE, ask if there is enough overlap of the treated and control groups' propensity score to estimate ATE, if not use ATT instead
- If ATT, ask if there are controls across the full range of the treated group
- Choose matching method
- If ATE, use IPTW or full matching
- If ATT, and more controls than treated (at least 3 times), k:1 nearest neighbor without replacement
- If ATT, and few controls , use subclassification, full matching, and weighting by the odds
- Diagnostic
- If balance, use regression on matched samples
- If imbalance on few covariates, treat them with Mahalanobis
- If imbalance on many covariates, try k:1 matching with replacement
Ways to define the distance $D_{ij}$
1. Exact
$$
D_{ij} =
\begin{cases}
0, \text{ if } X_i = X_j, \\
\infty, \text{ if } X_i \neq X_j
\end{cases}
$$
An advanced is [Coarsened Exact Matching]
2. Mahalanobis
$$
D_{ij} = (X_i - X_j)'\Sigma^{-1} (X_i - X_j)
$$
where
$\Sigma$ = variance covariance matrix of X in the
- control group if ATT is interested
- polled treatment and control groups if ATE is interested
3. Propensity score:
$$
D_{ij} = |e_i - e_j|
$$
where $e_k$ = the propensity score for individual k
An advanced is Prognosis score [@hansen2008prognostic], but you have to know (i.e., specify) the relationship between the covariates and outcome.
4. Linear propensity score
$$
D_{ij} = |logit(e_i) - logit(e_j)|
$$
The exact and Mahalanobis are not good in high dimensional or non normally distributed X's cases.
We can combine Mahalanobis matching with propensity score calipers [@rubin2000combining]
Other advanced methods for longitudinal settings
- marginal structural models [@robins2000marginal]
- balanced risk set matching [@li2001balanced]
Most matching methods are based on (ex-post)
- propensity score
- distance metric
- covariates
Packages
- `cem` Coarsened exact matching
- `Matching` Multivariate and propensity score matching with balance optimization
- `MatchIt` Nonparametric preprocessing for parametric causal inference. Have nearest neighbor, Mahalanobis, caliper, exact, full, optimal, subclassification
- `MatchingFrontier` optimize balance and sample size [@king2017balance]
- `optmatch`optimal matching with variable ratio, optimal and full matching
- `PSAgraphics` Propensity score graphics
- `rbounds` sensitivity analysis with matched data, examine ignorable treatment assignment assumption
- `twang` weighting and analysis of non-equivalent groups
- `CBPS` covariate balancing propensity score. Can also be used in the longitudinal setting with marginal structural models.
- `PanelMatch` based on [Imai, Kim, and Wang (2018)](https://imai.fas.harvard.edu/research/files/tscs.pdf)
+--------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------+
| Matching | Regression |
+==============================================================================================================+===================================================================+
| Not as sensitive to the functional form of the covariates | can estimate the effect of a continuous treatment |
+--------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------+
| Easier to asses whether it's working | estimate the effect of all the variables (not just the treatment) |
| | |
| Easier to explain | |
| | |
| allows a nice visualization of an evaluation | |
+--------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------+
| If you treatment is fairly rare, you may have a lot of control observations that are obviously no comparable | can estimate interactions of treatment with covariates |
+--------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------+
| Less parametric | More parametric |
+--------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------+
| Enforces common support (i.e., space where treatment and control have the same characteristics) | |
+--------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------+
However, the problem of **omitted variables** (i.e., those that affect both the outcome and whether observation was treated) - unobserved confounders is still present in matching methods.
Difference between matching and regression following Pischke's [lecture](https://econ.lse.ac.uk/staff/spischke/ec533/regression%20vs%20matching.pdf)
Suppose we want to estimate the effect of treatment on the treated
$$
\begin{aligned}
\delta_{TOT} &= E[ Y_{1i} - Y_{0i} | D_i = 1 ] \\
&= E\{E[Y_{1i} | X_i, D_i = 1] \\
& - E[Y_{0i}|X_i, D_i = 1]|D_i = 1\} && \text{law of itereated expectations}
\end{aligned}
$$
Under conditional independence
$$
E[Y_{0i} |X_i , D_i = 0 ] = E[Y_{0i} | 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\{E[y_i | X_i, D_i = 1] - E[y_i |X_i, D_i = 0 ] | D_i = 1\} \\
&= E[\delta_X |D_i = 1]
\end{aligned}
$$
where $\delta_X$ is an X-specific difference in means at covariate value $X_i$
When $X_i$ is discrete, the matching estimand is
$$
\delta_M = \sum_x \delta_x P(X_i = x |D_i = 1)
$$
where $P(X_i = x |D_i = 1)$ is the probability mass function for $X_i$ given $D_i = 1$
According to Bayes rule,
$$
P(X_i = x | D_i = 1) = \frac{P(D_i = 1 | X_i = x) \times P(X_i = x)}{P(D_i = 1)}
$$
hence,
$$
\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}
$$
On the other hand, suppose we have regression
$$
y_i = \sum_x d_{ix} \beta_x + \delta_R D_i + \epsilon_i
$$
where
- $d_{ix}$ = dummy that indicates $X_i = x$
- $\beta_x$ = regression-effect for $X_i = x$
- $\delta_R$ = regression estimand where
$$
\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}
$$
the difference between the regression and matching estimand is the weights they use to combine the covariate specific treatment effect $\delta_x$
+------------+---------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Type | uses weights which depend on | interpretation | makes sense because |
+============+=======================================================================================+====================================================================================================================================================================================================================================+====================================================================================================================================================================================+
| Matching | $P(D_i = 1|X_i = x)$ | This is larger in cells with many treated observations. | we want the effect of treatment on the treated |
| | | | |
| | the fraction of treated observations in a covariate cell (i.e., or the mean of $D_i$) | | |
+------------+---------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Regression | $P(D_i = 1 |X_i = x)(1 - P(D_i = 1| X_i ))$ | This weight is largest in cells where there are half treated and half untreated observations. (this is the reason why we want to treat our sample so it is balanced, before running regular regression model, as mentioned above). | these cells will produce the lowest variance estimates of $\delta_x$. If all the $\delta_x$ are the same, the most efficient estimand uses the lowest variance cells most heavily. |
| | | | |
| | the variance of $D_i$ in the covariate cell | | |
+------------+---------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
The goal of matching is to produce covariate balance (i.e., distributions of covariates in treatment and control groups are approximately similar as they would be in a successful randomized experiment).
## Selection on Observables
### MatchIt
Procedure typically involves (proposed by [Noah Freifer](https://cran.r-project.org/web/packages/MatchIt/vignettes/MatchIt.html) using `MatchIt`)
1. planning
2. matching
3. checking (balance)
4. estimating the treatment effect
```{r}
library(MatchIt)
data("lalonde")
```
examine `treat` on `re78`
1. Planning
- select type of effect to be estimated (e.g., mediation effect, conditional effect, marginal effect)
- select the target population
- select variables to match/balance [@austin2011optimal] [@vanderweele2019principles]
2. Check Initial Imbalance
```{r, eval = FALSE}
# No matching; constructing a pre-match matchit object
m.out0 <- matchit(
formula(treat ~ age + educ + race
+ married + nodegree + re74 + re75, env = lalonde),
data = data.frame(lalonde),
method = NULL,
# assess balance before matching
distance = "glm" # logistic regression
)
# Checking balance prior to matching
summary(m.out0)
```
3. Matching
```{r}
# 1:1 NN PS matching w/o replacement
m.out1 <- matchit(treat ~ age + educ,
data = lalonde,
method = "nearest",
distance = "glm")
m.out1
```
4. Check balance
Sometimes you have to make trade-off between balance and sample size.
```{r}
# Checking balance after NN matching
summary(m.out1, un = FALSE)
# examine visually
plot(m.out1, type = "jitter", interactive = FALSE)
plot(
m.out1,
type = "qq",
interactive = FALSE,
which.xs = c("age")
)
```
Try Full Match (i.e., every treated matches with one control, and every control with one treated).
```{r}
# Full matching on a probit PS
m.out2 <- matchit(treat ~ age + educ,
data = lalonde,
method = "full",
distance = "glm",
link = "probit")
m.out2
```
Checking balance again
```{r}
# Checking balance after full matching
summary(m.out2, un = FALSE)
plot(summary(m.out2))
```
Exact Matching
```{r}
# Full matching on a probit PS
m.out3 <-
matchit(
treat ~ age + educ,
data = lalonde,
method = "exact"
)
m.out3
```
Subclassfication
```{r}
m.out4 <- matchit(
treat ~ age + educ,
data = lalonde,
method = "subclass"
)
m.out4
# Or you can use in conjunction with "nearest"
m.out4 <- matchit(
treat ~ age + educ,
data = lalonde,
method = "nearest",
option = "subclass"
)
m.out4
```
Optimal Matching
```{r}
m.out5 <- matchit(
treat ~ age + educ,
data = lalonde,
method = "optimal",
ratio = 2
)
m.out5
```
Genetic Matching
```{r}
m.out6 <- matchit(
treat ~ age + educ,
data = lalonde,
method = "genetic"
)
m.out6
```
4. Estimating the Treatment Effect
```{r}
# get matched data
m.data1 <- match.data(m.out1)
head(m.data1)
```
```{r, message=FALSE}
library("lmtest") #coeftest
library("sandwich") #vcovCL
# imbalance matched dataset
fit1 <- lm(re78 ~ treat + age + educ ,
data = m.data1,
weights = weights)
coeftest(fit1, vcov. = vcovCL, cluster = ~subclass)
```
`treat` coefficient = estimated ATT
```{r}
# balance matched dataset
m.data2 <- match.data(m.out2)
fit2 <- lm(re78 ~ treat + age + educ ,
data = m.data2, weights = weights)
coeftest(fit2, vcov. = vcovCL, cluster = ~subclass)
```
When reporting, remember to mention
1. the matching specification (method, and additional options)
2. the distance measure (e.g., propensity score)
3. other methods, and rationale for the final chosen method.
4. balance statistics of the matched dataset.
5. number of matched, unmatched, discarded
6. estimation method for treatment effect.
### designmatch
This package includes
- `distmatch` optimal distance matching
- `bmatch` optimal bipartile matching
- `cardmatch` optimal cardinality matching
- `profmatch` optimal profile matching
- `nmatch` optimal nonbipartile matching
```{r}
library(designmatch)
```
### 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")
# 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
Even though I mention the propensity scores matching method here, it is no longer recommended to use such method in research and publication [@king2019propensity] because it increases
- imbalance
- inefficiency
- model dependence: small changes in the model specification lead to big changes in model results
- bias
[@abadie2016matching]note
- The initial estimation of the propensity score influences the large sample distribution of the estimators.
- Adjustments are made to the large sample variances of these estimators for both ATE and ATT.
- The adjustment for the ATE estimator is either negative or zero, indicating greater efficiency when matching on an estimated propensity score versus the true score in large samples.
- For the ATET estimator, the sign of the adjustment depends on the data generating process. Neglecting the estimation error in the propensity score can lead to inaccurate confidence intervals for the ATT estimator, making them either too large or too small.
PSM tries to accomplish complete randomization while other methods try to achieve fully blocked. Hence, you probably better off use any other methods.
Propensity is "the probability of receiving the treatment given the observed covariates." [@rosenbaum1985bias]
Equivalently, it can to understood as the probability of being treated.
$$
e_i (X_i) = P(T_i = 1 | X_i)
$$
Estimation using
- logistic regression
- Non parametric methods:
- boosted CART
- generalized boosted models (gbm)
Steps by Gary King's [slides](https://www.youtube.com/watch?v=rBv39pK1iEs&ab_channel=MethodsColloquium)
- reduce k elements of X to scalar
- $\pi_i \equiv P(T_i = 1|X) = \frac{1}{1+e^{X_i \beta}}$
- Distance ($X_c, X_t$) = $|\pi_c - \pi_t|$
- match each treated unit to the nearest control unit
- control units: not reused; pruned if unused
- prune matches if distances \> caliper
In the best case scenario, you randomly prune, which increases imbalance
Other methods dominate because they try to match exactly hence
- $X_c = X_t \to \pi_c = \pi_t$ (exact match leads to equal propensity scores) but
- $\pi_c = \pi_t \nrightarrow X_c = X_t$ (equal propensity scores do not necessarily lead to exact match)
Notes:
- Do not include/control for irrelevant covariates because it leads your PSM to be more random, hence more imbalance
- Do not include for [@bhattacharya2007instrumental] instrumental variable in the predictor set of a propensity score matching estimator. More generally, using variables that do not control for potential confounders, even if they are predictive of the treatment, can result in biased estimates
What you left with after pruning is more important than what you start with then throw out.
Diagnostics:
- balance of the covariates
- no need to concern about collinearity
- can't use c-stat or stepwise because those model fit stat do not apply
#### Look Ahead Propensity Score Matching
- [@bapna2018monetizing]
### Mahalanobis Distance
Approximates fully blocked experiment
Distance $(X_c,X_t)$ = $\sqrt{(X_c - X_t)'S^{-1}(X_c - X_t)}$
where $S^{-1}$ standardize the distance
In application we use Euclidean distance.
Prune unused control units, and prune matches if distance \> caliper
### Coarsened Exact Matching
Steps from Gray King's [slides](https://www.youtube.com/watch?v=rBv39pK1iEs&ab_channel=MethodsColloquium) International Methods Colloquium talk 2015
- Temporarily coarsen $X$
- Apply exact matching to the coarsened $X, C(X)$
- sort observation into strata, each with unique values of $C(X)$
- prune stratum with 0 treated or 0 control units
- Pass on original (uncoarsened) units except those pruned
Properties:
- Monotonic imbalance bounding (MIB) matching method
- maximum imbalance between the treated and control chosen ex ante
- meets congruence principle
- robust to measurement error
- can be implemented with multiple imputation