More often than not, specially if we didn’t construct the data, it would be impossible to find that unconditional independence assumption holds.
For example, treatment (say having health insurance) may vary by age, gender, race, location, etc.
This is similar to the selection bias: Outcomes across treated and untreated groups will be different because:
Composition: Characteristics of people among the treated could be different than those among the untreated For example, they could be older, more educated, mostly men, etc.
Other factors: There could be factors we cannot control for, that also affect outcomes.
There is conditional
When unconditional independence assumption fails, we can call on Conditional independence assumption:
\[
Y(1),Y(0) \perp D | X
\]
In other words, If we can look into specific groups (given \(X\)), it may be possible to impose the Independence assumption.
This relaxes the independence condition, but assumes selection is due to observable characteristics only. (it still needs to be as good as randomized given \(X\))
Matching is a methodology that falls within quasi-experimental designs. You cannot or could not decide the assignment rules, so now are using data as given.
The idea is to construct an artificial control and use it as a counter-factual, so that both treated and control groups “look similar” in terms of observables.
Once a group of synthetic controls has been constructed, treatment effects can be calculated for the whole population:
(Data downloaded from R base)
(8 zero counts ignored; observations not deleted)
(2,177 observations created)
(8 observations deleted)
| class1
Survived | 0 1 | Total
-----------+----------------------+----------
No | 72.92 37.54 | 67.70
Yes | 27.08 62.46 | 32.30
-----------+----------------------+----------
Total | 100.00 100.00 | 100.00
If we assume full Independence assumption we would believe that being in first class increased chance of survival in 35.4%. but is that the case?
What if the composition of individuals differs across classes (women and children)
Code
tab age class1, nofreq coltab sex class1, nofreq col
| class1
Age | 0 1 | Total
-----------+----------------------+----------
Child | 5.49 1.85 | 4.95
Adult | 94.51 98.15 | 95.05
-----------+----------------------+----------
Total | 100.00 100.00 | 100.00
| class1
Sex | 0 1 | Total
-----------+----------------------+----------
Male | 82.68 55.38 | 78.65
Female | 17.32 44.62 | 21.35
-----------+----------------------+----------
Total | 100.00 100.00 | 100.00
There were fewer children, but more women in first class. Perhaps that explains the difference in survival rates
A better approach would be to look into the survival probabilities stratifying the data:
Code
gen surv=survived==2bysort age sex class1:egen sr_mean=mean(survived==2)table (age sex) (class1), stat(mean surv) nototal
-----------------------------------
| class1
| 0 1
-------------+---------------------
Age |
Child |
Sex |
Male | .4067797 1
Female | .6136364 1
Adult |
Sex |
Male | .1883378 .3257143
Female | .6263345 .9722222
-----------------------------------
So even within each group, the survival probability is larger in first class. What about Average?
Code
bysort age sex:egen sr_mean_class1=max(sr_mean*(class1==1))bysort age sex:egen sr_mean_class0=max(sr_mean*(class1==0))gen teff = sr_mean_class1-sr_mean_class0sum teff if class1==1 // ATTsum teff if class1==0 // ATUsum teff // ATE
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
teff | 325 .2375421 .1125033 .1373765 .5932204
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
teff | 1,876 .1887847 .1089261 .1373765 .5932204
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
teff | 2,201 .1959842 .1107948 .1373765 .5932204
What did we do?
The procedure above is a simple stratification approach, aka matching, to analyze the true impact of the treatment (being a 1st class passenger).
Stratified the sample in groups by age and gender.
Identify the shares of each group by class1
Predict probability of survival per strata and class1
Obtain the Strata level Effects
Aggregate as needed.
Here, we could estimate ATE, ATT or ATU!
Where could things go wrong?
Overlapping
The procedure describe above works well whenever there is data overlapping.
For every combination of X, you see data on the control and treated group \(0<P(D|X)<1\)
When this fails, you wont be able to estimate ATE’s, although ATT’s or ATU’s might still be possible:
Would not be able to estimate ATE nor ATU. Only ATT for townhouses.
Curse of dimensionality
There is a second problem in terms of stratification. How would we deal with Multiple dimensions? Would it be possible to find “twins” for every observation?
The answer is, probably no. Too many groups to track, to many micro cells to make use of:
The problem of curse of dimensional states that as the number of desired characteristics to match increase, fewer “twins” will be available in the data. At the end…no one will be like you!
The alternative, is to look into People that are sufficiently close so they can be used for matching.
Depending how \(w(.)\) is defined, we would be facing different kinds of matching estimators.
Types of Matching
Matching on covariates
The first decision to take is whether one should find matches based on covariates, or based on scores (propensity scores).
Using covariates implies that will aim to find the closest “twin” possible, based on multiple dimensions: \[
\begin{aligned}
Eclidean=d(x_i,x_j) &=\sqrt{ (x_i-x_j)'(x_i-x_j)} \\
WEclidean=d(x_i,x_j) &=\sqrt{ (x_i-x_j)'W (x_i-x_j)} \\
Maha =d(x_i,x_j) &=\sqrt{(x_i-x_j)'S^{-1}(x_i-x_j)}
\end{aligned}
\]
Distance measures are used to identify the closest matches to a given observation, and thus the weight assigned to that observation.
Has the advantage of looking at individuals who are indeed close to each other, but becomes more difficult as the dimensionality of X’s increase. (you will not find close matches)
Matching on Scores
A second approach is to match individuals based on some summary index that condenses the information in \(X\) into a single scalar \(h(x)\), reducing the dimensionality problem fron K to 1.
Few candidates:
Propensity Score: \(P(D|X)\) based on a logit/probit/binomial model. Most common approach!
Predicted Mean: \(X\beta\) if there is information on outcome to be predicted
PCA: Using Principal components to reduce dimensionality before Matching
Since there is only 1 dimension to consider, multiple distance measures are possible:
But one has to be careful with the approach. King and Nielsen (2019) Argue about the risks of PSM
1 vs K matching; With and without replacement
Two additional questions remain regarding matching. How many “twins” to use, and if twins will be obtained with/without replacement.
Fewer matches reduce bias (choosing only the closest observation), but increase variance.
More matches increase bias, but reduce variance. (because of less optimal matches)
with replacement: control units may be used more than once. This will improve matching quality reducing bias. But by using the same units multiple times, it will increase variance.
without replacement: Control units are used once, potentially reducing matching quality, but reducing variance. It will be order dependent.
see Caliendo and Kopeing (2008)
What about SE? and Statistical inference?
Well….this is one of the few cases where Bootstrapping WON’T work!
Standard errors are more cumbersome. So we will just rely on software results
Other considerations
Once you have chosen your matching method, find your “statistical twins”, and estimate your differences you are done! (or are you)
Not yet…common practice: Evaluate the balance of your data
Matching aims to reduce or eliminate differences in characteristics between treatment and control units. Thus, one should evaluate the differences (before and after match) of your characteristis
Check for overlapping condition.
either variable by variable or with pscore
Assess Matching Quality: Have differences across groups vanished?
keepif treated == 1 | sample ==2replace treated=0 if treated==.reg re treatedtabstat age educ black hisp married nodegree , by(treated)
(2,750 observations deleted)
(15,992 real changes made)
Source | SS df MS Number of obs = 16,177
-------------+---------------------------------- F(1, 16175) = 142.43
Model | 1.3206e+10 1 1.3206e+10 Prob > F = 0.0000
Residual | 1.4997e+12 16,175 92717515.8 R-squared = 0.0087
-------------+---------------------------------- Adj R-squared = 0.0087
Total | 1.5129e+12 16,176 93528158.4 Root MSE = 9629
------------------------------------------------------------------------------
re | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
treated | -8497.516 712.0207 -11.93 0.000 -9893.156 -7101.877
_cons | 14846.66 76.14292 194.98 0.000 14697.41 14995.91
------------------------------------------------------------------------------
Summary statistics: Mean
Group variable: treated
treated | age educ black hisp married nodegree
---------+------------------------------------------------------------
0 | 33.22524 12.02751 .0735368 .072036 .7117309 .2958354
1 | 25.81622 10.34595 .8432432 .0594595 .1891892 .7081081
---------+------------------------------------------------------------
Total | 33.14051 12.00828 .0823391 .0718922 .7057551 .3005502
----------------------------------------------------------------------
We need to do trimming
Code
bysort educ black hisp married:egen n11=sum(treated==1)bysort age black hisp married:egen n22=sum(treated==1)dropif n11==0 | n22 ==0tabstat age educ black hisp married nodegree , by(treated)reg re treated
(13,536 observations deleted)
Summary statistics: Mean
Group variable: treated
treated | age educ black hisp married nodegree
---------+------------------------------------------------------------
0 | 24.24145 11.69788 .252443 .0260586 .3346906 .2569218
1 | 25.81622 10.34595 .8432432 .0594595 .1891892 .7081081
---------+------------------------------------------------------------
Total | 24.35176 11.60318 .2938281 .0283983 .3244983 .2885271
----------------------------------------------------------------------
Source | SS df MS Number of obs = 2,641
-------------+---------------------------------- F(1, 2639) = 73.89
Model | 5.7607e+09 1 5.7607e+09 Prob > F = 0.0000
Residual | 2.0575e+11 2,639 77964783.1 R-squared = 0.0272
-------------+---------------------------------- Adj R-squared = 0.0269
Total | 2.1151e+11 2,640 80117339.3 Root MSE = 8829.8
------------------------------------------------------------------------------
re | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
treated | -5786.584 673.1834 -8.60 0.000 -7106.605 -4466.564
_cons | 12135.73 178.1702 68.11 0.000 11786.36 12485.1
------------------------------------------------------------------------------
Lets do some matching
Code
teffects nnmatch (re age educ black married nodegree ) (treated)tebalance summarizeteffects nnmatch (re age educ black married nodegree ) (treated), nn(2)tebalance summarizeteffects psmatch (re) (treated age educ black married nodegree )tebalance summarizeteffects psmatch (re) (treated age educ black married nodegree ) , nn(2)tebalance summarize
Treatment-effects estimation Number of obs = 2,641
Estimator : nearest-neighbor matching Matches: requested = 1
Outcome model : matching min = 1
Distance metric: Mahalanobis max = 138
------------------------------------------------------------------------------
| AI robust
re | Coefficient std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
ATE |
treated |
(1 vs 0) | -3685.665 1188.666 -3.10 0.002 -6015.407 -1355.923
------------------------------------------------------------------------------
(refitting the model using the generate() option)
Covariate balance summary
Raw Matched
-----------------------------------------
Number of obs = 2,641 5,282
Treated obs = 185 2,641
Control obs = 2,456 2,641
-----------------------------------------
-----------------------------------------------------------------
|Standardized differences Variance ratio
| Raw Matched Raw Matched
----------------+------------------------------------------------
age | .2342346 -.015417 1.305844 .8410946
educ | -.7684118 -.0812288 1.881909 .8598207
black | 1.473105 0 .7039609 1
married | -.3351313 -.0008087 .6923501 .999393
nodegree | 1.010393 0 1.088086 1
-----------------------------------------------------------------
Treatment-effects estimation Number of obs = 2,641
Estimator : nearest-neighbor matching Matches: requested = 2
Outcome model : matching min = 2
Distance metric: Mahalanobis max = 138
------------------------------------------------------------------------------
| AI robust
re | Coefficient std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
ATE |
treated |
(1 vs 0) | -5166.888 1107.653 -4.66 0.000 -7337.848 -2995.929
------------------------------------------------------------------------------
(refitting the model using the generate() option)
Covariate balance summary
Raw Matched
-----------------------------------------
Number of obs = 2,641 5,282
Treated obs = 185 2,641
Control obs = 2,456 2,641
-----------------------------------------
-----------------------------------------------------------------
|Standardized differences Variance ratio
| Raw Matched Raw Matched
----------------+------------------------------------------------
age | .2342346 -.0209048 1.305844 .7345997
educ | -.7684118 -.0385284 1.881909 .8978301
black | 1.473105 .0074673 .7039609 1.006716
married | -.3351313 -.004586 .6923501 .9965432
nodegree | 1.010393 .0016705 1.088086 1.001557
-----------------------------------------------------------------
Treatment-effects estimation Number of obs = 2,641
Estimator : propensity-score matching Matches: requested = 1
Outcome model : matching min = 1
Treatment model: logit max = 138
------------------------------------------------------------------------------
| AI robust
re | Coefficient std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
ATE |
treated |
(1 vs 0) | -4278.549 1135.847 -3.77 0.000 -6504.768 -2052.331
------------------------------------------------------------------------------
(refitting the model using the generate() option)
Covariate balance summary
Raw Matched
-----------------------------------------
Number of obs = 2,641 5,282
Treated obs = 185 2,641
Control obs = 2,456 2,641
-----------------------------------------
-----------------------------------------------------------------
|Standardized differences Variance ratio
| Raw Matched Raw Matched
----------------+------------------------------------------------
age | .2342346 .0014058 1.305844 .9313458
educ | -.7684118 -.1308249 1.881909 .9665937
black | 1.473105 -.0926638 .7039609 .90999
married | -.3351313 -.0973289 .6923501 .9197524
nodegree | 1.010393 .0821105 1.088086 1.07103
-----------------------------------------------------------------
Treatment-effects estimation Number of obs = 2,641
Estimator : propensity-score matching Matches: requested = 2
Outcome model : matching min = 2
Treatment model: logit max = 138
------------------------------------------------------------------------------
| AI robust
re | Coefficient std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
ATE |
treated |
(1 vs 0) | -4380.078 1158.019 -3.78 0.000 -6649.754 -2110.403
------------------------------------------------------------------------------
(refitting the model using the generate() option)
Covariate balance summary
Raw Matched
-----------------------------------------
Number of obs = 2,641 5,282
Treated obs = 185 2,641
Control obs = 2,456 2,641
-----------------------------------------
-----------------------------------------------------------------
|Standardized differences Variance ratio
| Raw Matched Raw Matched
----------------+------------------------------------------------
age | .2342346 -.06133 1.305844 .8834346
educ | -.7684118 -.1321518 1.881909 1.021302
black | 1.473105 -.0698339 .7039609 .933348
married | -.3351313 -.0414439 .6923501 .9674741
nodegree | 1.010393 .0939209 1.088086 1.080951
-----------------------------------------------------------------
A missing variable? Earnings in previous year. May capture information of Need to do treatment (selection)
Code
tabstat age educ black hisp married nodegree re74, by(treated)gen dre = re-re74teffects nnmatch (dre age educ black married nodegree ) (treated)teffects nnmatch (dre age educ black married nodegree ) (treated), nn(2)teffects psmatch (dre) (treated age educ black married nodegree )teffects psmatch (dre) (treated age educ black married nodegree ) , nn(2)
Summary statistics: Mean
Group variable: treated
treated | age educ black hisp married nodegree
---------+------------------------------------------------------------
0 | 24.24145 11.69788 .252443 .0260586 .3346906 .2569218
1 | 25.81622 10.34595 .8432432 .0594595 .1891892 .7081081
---------+------------------------------------------------------------
Total | 24.35176 11.60318 .2938281 .0283983 .3244983 .2885271
----------------------------------------------------------------------
treated | re74
---------+----------
0 | 9347.406
1 | 2095.574
---------+----------
Total | 8839.421
--------------------
Treatment-effects estimation Number of obs = 2,641
Estimator : nearest-neighbor matching Matches: requested = 1
Outcome model : matching min = 1
Distance metric: Mahalanobis max = 138
------------------------------------------------------------------------------
| AI robust
dre | Coefficient std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
ATE |
treated |
(1 vs 0) | 2616.653 1803.172 1.45 0.147 -917.4997 6150.806
------------------------------------------------------------------------------
Treatment-effects estimation Number of obs = 2,641
Estimator : nearest-neighbor matching Matches: requested = 2
Outcome model : matching min = 2
Distance metric: Mahalanobis max = 138
------------------------------------------------------------------------------
| AI robust
dre | Coefficient std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
ATE |
treated |
(1 vs 0) | 730.2925 1674.91 0.44 0.663 -2552.47 4013.055
------------------------------------------------------------------------------
Treatment-effects estimation Number of obs = 2,641
Estimator : propensity-score matching Matches: requested = 1
Outcome model : matching min = 1
Treatment model: logit max = 138
------------------------------------------------------------------------------
| AI robust
dre | Coefficient std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
ATE |
treated |
(1 vs 0) | 2162.311 1740.12 1.24 0.214 -1248.262 5572.884
------------------------------------------------------------------------------
Treatment-effects estimation Number of obs = 2,641
Estimator : propensity-score matching Matches: requested = 2
Outcome model : matching min = 2
Treatment model: logit max = 138
------------------------------------------------------------------------------
| AI robust
dre | Coefficient std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
ATE |
treated |
(1 vs 0) | 1833.03 1739.496 1.05 0.292 -1576.318 5242.379
------------------------------------------------------------------------------
In this case, Matching alone could not get the right answer. Who were the most likely to “go to the training?”
So instead we change the question: How much the change in earnings compare across groups.
Wait: What about Reweighting?
An alternative method to Matching is to do Re-weighting.
We have seen this!
Your control group has a distribution \(g(x)\) and your treatment \(f(x)\). We can use some weighting factors \(h(x)\) that reshapes \(g(x)\rightarrow \hat f(x)\).
How? Using Propensity scores
Why does it work? Just as matching, your goal is to compare distributions of outcomes, forcing differences in observed characteristics to be the same.
IPW, does this by reweighting the distribution! (rather than matching)
Inverse Probability Weighting:IPW
s1: Estimate Pscore
\[
p(D=1|X)=F(X\beta)
\] S2: Estimate IPW
For ATT: \(W(D=1,x)=1 \ \& \ W(D=0,X)=\frac{\hat p(x)}{1-\hat p(x)}\)
For ATU: \(W(D=0,x)=1 \ \& \ W(D=1,X)=\frac{1-\hat p(x)}{\hat p(x)}\)
For ATE: \(W(D=0,x)=\frac{1}{1-\hat p(x)} \ \& \ W(D=1,X)=\frac{1}{\hat p(x)}\)
An interesting advantage of IPW approach is that you can gain efficiency using Doubly Robust Methods. Namely, instead of comparing outcomes directly, you could compare predicted outcomes!
\[
\begin{aligned}
ATT &= \frac{1}{N_t}\sum(Y_1-X'\hat\beta_w^0) \\
ATU &= \frac{1}{N_c}\sum(X'\hat\beta_w^1-Y_0) \\
ATE &= \frac{1}{N}\sum(X'\hat\beta_w^1-X'\hat\beta_w^0)
\end{aligned}
\] where \(\hat \beta^k_w\) can be modeled using weighted least squares
Comparing to Matching
teffects ipw (re) (treated age educ black married nodegree) , iter(3) nologteffects ipwra (re age educ black married nodegree) (treated age educ black married nodegree), iter(3) nologteffects ipw (dre) (treated age educ black married nodegree), iter(3) nologteffects ipwra (dre age educ black married nodegree) (treated age educ black married nodegree), iter(3) nolog
Treatment-effects estimation Number ofobs = 2,641Estimator : inverse-probability weightsOutcome model : weighted meanTreatment model: logit------------------------------------------------------------------------------ | Robust re | Coefficient std. err. z P>|z| [95% conf. interval]-------------+----------------------------------------------------------------ATE | treated | (1 vs 0) | -4833.352 1088.667 -4.44 0.000 -6967.101 -2699.603-------------+----------------------------------------------------------------POmean | treated | 0 | 11979.19 179.1903 66.85 0.000 11627.99 12330.4------------------------------------------------------------------------------Treatment-effects estimation Number ofobs = 2,641Estimator : IPW regression adjustmentOutcome model : linearTreatment model: logit------------------------------------------------------------------------------ | Robust re | Coefficient std. err. z P>|z| [95% conf. interval]-------------+----------------------------------------------------------------ATE | treated | (1 vs 0) | -4835.38 1012.598 -4.78 0.000 -6820.036 -2850.724-------------+----------------------------------------------------------------POmean | treated | 0 | 11976.52 179.0958 66.87 0.000 11625.49 12327.54------------------------------------------------------------------------------Warning: Convergence not achieved.Treatment-effects estimation Number ofobs = 2,641Estimator : inverse-probability weightsOutcome model : weighted meanTreatment model: logit------------------------------------------------------------------------------ | Robust dre | Coefficient std. err. z P>|z| [95% conf. interval]-------------+----------------------------------------------------------------ATE | treated | (1 vs 0) | 1475.71 1792.427 0.82 0.410 -2037.382 4988.802-------------+----------------------------------------------------------------POmean | treated | 0 | 2746.475 161.2845 17.03 0.000 2430.363 3062.587------------------------------------------------------------------------------Warning: Convergence not achieved.Treatment-effects estimation Number ofobs = 2,641Estimator : IPW regression adjustmentOutcome model : linearTreatment model: logit------------------------------------------------------------------------------ | Robust dre | Coefficient std. err. z P>|z| [95% conf. interval]-------------+----------------------------------------------------------------ATE | treated | (1 vs 0) | 1286.605 1516.493 0.85 0.396 -1685.666 4258.875-------------+----------------------------------------------------------------POmean | treated | 0 | 2754.756 161.4406 17.06 0.000 2438.338 3071.173------------------------------------------------------------------------------Warning: Convergence not achieved.