class: center, middle, inverse, title-slide # POL90: Statistics ## Matching ### Prof. Wasow, PoliticsPomona College ### 2022-04-20 --- <style type="text/css"> .regression10 table { font-size: 10px; } .regression12 table { font-size: 12px; } .regression14 table { font-size: 14px; } </style> # Announcements .large[ - Assignments - PS10 due Tuesday - Report 3 teams assigned - Reading: - Skim: Elizabeth Stuart & Donald Rubin (2007), "Matching methods for causal inference: Designing observational studies" ] --- # Schedule <table> <thead> <tr> <th style="text-align:right;"> Week </th> <th style="text-align:left;"> Date </th> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Title </th> <th style="text-align:right;"> Chapter </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> 11 </td> <td style="text-align:left;"> Mar 30 </td> <td style="text-align:left;"> Wed </td> <td style="text-align:left;"> Interaction terms </td> <td style="text-align:right;"> 9 </td> </tr> <tr> <td style="text-align:right;"> 12 </td> <td style="text-align:left;"> Apr 4 </td> <td style="text-align:left;"> Mon </td> <td style="text-align:left;"> Logistic regression </td> <td style="text-align:right;"> 20 </td> </tr> <tr> <td style="text-align:right;"> 12 </td> <td style="text-align:left;"> Apr 6 </td> <td style="text-align:left;"> Wed </td> <td style="text-align:left;"> Logistic regression </td> <td style="text-align:right;"> 20 </td> </tr> <tr> <td style="text-align:right;"> 13 </td> <td style="text-align:left;"> Apr 11 </td> <td style="text-align:left;"> Mon </td> <td style="text-align:left;"> Missing Data </td> <td style="text-align:right;"> Handout </td> </tr> <tr> <td style="text-align:right;"> 13 </td> <td style="text-align:left;"> Apr 13 </td> <td style="text-align:left;"> Wed </td> <td style="text-align:left;"> Panel Data </td> <td style="text-align:right;"> Handout </td> </tr> <tr> <td style="text-align:right;"> 14 </td> <td style="text-align:left;"> Apr 18 </td> <td style="text-align:left;"> Mon </td> <td style="text-align:left;"> Matching </td> <td style="text-align:right;"> Handout </td> </tr> <tr> <td style="text-align:right;color: black !important;background-color: yellow !important;"> 14 </td> <td style="text-align:left;color: black !important;background-color: yellow !important;"> Apr 20 </td> <td style="text-align:left;color: black !important;background-color: yellow !important;"> Wed </td> <td style="text-align:left;color: black !important;background-color: yellow !important;"> Matching </td> <td style="text-align:right;color: black !important;background-color: yellow !important;"> Handout </td> </tr> <tr> <td style="text-align:right;"> 15 </td> <td style="text-align:left;"> Apr 25 </td> <td style="text-align:left;"> Mon </td> <td style="text-align:left;"> Causal inference: Panel data </td> <td style="text-align:right;"> Handout </td> </tr> <tr> <td style="text-align:right;"> 15 </td> <td style="text-align:left;"> Apr 27 </td> <td style="text-align:left;"> Wed </td> <td style="text-align:left;"> Causal inference: Natural Experiments </td> <td style="text-align:right;"> Dunning </td> </tr> <tr> <td style="text-align:right;"> 16 </td> <td style="text-align:left;"> May 2 </td> <td style="text-align:left;"> Mon </td> <td style="text-align:left;"> Causal inference: RDD </td> <td style="text-align:right;"> NA </td> </tr> <tr> <td style="text-align:right;"> 16 </td> <td style="text-align:left;"> May 4 </td> <td style="text-align:left;"> Wed </td> <td style="text-align:left;"> No class </td> <td style="text-align:right;"> NA </td> </tr> </tbody> </table> --- ## Assignment schedule <table> <thead> <tr> <th style="text-align:right;"> Week </th> <th style="text-align:left;"> Date </th> <th style="text-align:left;"> Day </th> <th style="text-align:left;"> Assignment </th> <th style="text-align:right;"> Percent </th> </tr> </thead> <tbody> <tr> <td style="text-align:right;"> 13 </td> <td style="text-align:left;"> Apr 18 </td> <td style="text-align:left;"> Mon </td> <td style="text-align:left;"> PS09 </td> <td style="text-align:right;"> 3 </td> </tr> <tr> <td style="text-align:right;color: black !important;background-color: yellow !important;"> 14 </td> <td style="text-align:left;color: black !important;background-color: yellow !important;"> Apr 25 </td> <td style="text-align:left;color: black !important;background-color: yellow !important;"> Mon </td> <td style="text-align:left;color: black !important;background-color: yellow !important;"> PS10 </td> <td style="text-align:right;color: black !important;background-color: yellow !important;"> 3 </td> </tr> <tr> <td style="text-align:right;color: black !important;background-color: yellow !important;"> 15 </td> <td style="text-align:left;color: black !important;background-color: yellow !important;"> May 2 </td> <td style="text-align:left;color: black !important;background-color: yellow !important;"> Mon </td> <td style="text-align:left;color: black !important;background-color: yellow !important;"> Report3 </td> <td style="text-align:right;color: black !important;background-color: yellow !important;"> 10 </td> </tr> </tbody> </table> --- class: center, middle # Revisiting: Homicide and Ice Cream --- ## Revisiting: Homicide and Ice Cream <img src="images/homicide_ice_cream_screen_grab.png" width="571" style="display: block; margin: auto;" /> --- class: center, middle # Propensity Score Matching --- ## <img src="images/pscore001.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/pscore002.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/pscore003.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/pscore004.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/pscore005.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/pscore006.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/pscore007.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/pscore008.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/pscore020BestCase.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/pscore022BestCase.png" width="100%" style="display: block; margin: auto;" /> --- class: center, middle # Mahalanobis Matching --- ## <img src="images/mah001.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/mah002.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/mah003.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/mah004.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/mah020BestCase.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/mah021BestCase.png" width="100%" style="display: block; margin: auto;" /> --- class: center, middle # Other Matching Methods --- ## <img src="images/diamond_sekhon_2013.png" width="100%" style="display: block; margin: auto;" /> .footnote[Source: https://www.mitpressjournals.org/doi/pdf/10.1162/REST_a_00318] --- .center[ <img src="images/stuart_matching_abstract.png" width="85%" style="display: block; margin: auto;" /> ] .footnote[Source: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2943670/] --- .center[ <img src="images/stuart_matching_subclass_full.png" width="85%" style="display: block; margin: auto;" /> ] .footnote[Source: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2943670/] --- ## Birdkeeping + lung cancer data (modified) ```r birds <- Sleuth3::case2002 %>% clean_names() head(birds, 10) ``` ``` lc fm ss bk ag yr cd 1 LungCancer Male Low Bird 37 19 12 2 LungCancer Male Low Bird 41 22 15 3 LungCancer Male High NoBird 43 19 15 4 LungCancer Male Low Bird 46 24 15 5 LungCancer Male Low Bird 49 31 20 6 LungCancer Male High NoBird 51 24 15 7 LungCancer Male High Bird 52 31 20 8 LungCancer Male Low NoBird 53 33 20 9 LungCancer Male Low Bird 56 33 10 10 LungCancer Male High NoBird 56 26 25 ``` --- ## What if age is related to birdkeeping? ```r birds %>% ggplot() + aes(x = ag, color = bk) + geom_density() + theme_bw() ``` <img src="week14_02_files/figure-html/unnamed-chunk-28-1.png" width="70%" style="display: block; margin: auto;" /> --- ## What if we match via subclass? ```r birds <- birds %>% mutate( lc_bin = ifelse(lc == "LungCancer", 1, 0), bk_bin = ifelse(bk == "Bird", 1, 0) ) # find "nearest neighbors" match_out <- MatchIt::matchit( formula = bk_bin ~ ag + yr + fm + ss, data = birds, method = "subclass" ) ``` --- ## Look at Subclassifications ```r plot(match_out, type = "jitter", interactive = FALSE) ``` <img src="week14_02_files/figure-html/unnamed-chunk-30-1.png" width="720" style="display: block; margin: auto;" /> --- .center[ <img src="images/imai_ratkovic_2014.png" width="85%" style="display: block; margin: auto;" /> ] .footnote[Source: https://imai.fas.harvard.edu/research/files/CBPS.pdf] --- ## What are Weights? .large[ - The process of using weights in matching is analogous to the kinds of weights that survey researchers use to try and accurately represent a population with a subsample. - For example, imagine pollsters are trying to estimate approval for President Biden but young people answer their phones at about half the rate of older respondents. - The pollster would know this by comparing the survey response rates to population-level data like the Census. ] --- ## What are Weights? .large[ - So, for example, if 18 to 23 year olds are found to be 10 percent of the population in sources like the Census but are only one in twenty of our survey respondents, we might weight each 18 to 23 year old respondent as if they were two people. - Conversely, if we oversampled Baby Boomers, we might weight them as if each respondent counted for "half" a person. Through weighting, we could make our sample representative of the larger population as measured by the Census. - There's obviously a lot more that survey researchers do to ensure the representativeness of their samples but that's the basic idea. ] --- ## How do Weights Work in Matching? .large[ - With matching weights, we're doing something similar to survey weights. - We're using weights to increase or decrease the influence of certain observations so that the CONTROL sample looks as similar as possible to our TREATED sample on a set of characteristics. - In essence, we're often using our TREATED sample a bit like the Census as a reference and then re-weighting the CONTROL observations as if they were a sample that needed to be adjusted to be representative. ] --- ## Matching Exercise <br><br><br><br> .large[ http://appliedstats.org/matching_exercise.html ] --- class: center, middle # Questions? --- ## Causal Inference Mixtape: Subclassification <br> <img src="images/cunningham_subclassification_01.png" width="796" style="display: block; margin: auto;" /> .footnote[Source: https://mixtape.scunning.com/matching-and-subclassification.html] --- ## Causal Inference Mixtape: Subclassification <br> <img src="images/cunningham_subclassification_02.png" width="785" style="display: block; margin: auto;" /> .footnote[Source: https://mixtape.scunning.com/matching-and-subclassification.html] --- ## Causal Inference Mixtape: Subclassification <br> <img src="images/cunningham_subclassification_03.png" width="792" style="display: block; margin: auto;" /> .footnote[Source: https://mixtape.scunning.com/matching-and-subclassification.html] --- ## Causal Inference Mixtape: Subclassification <br> <img src="images/cunningham_subclassification_04.png" width="803" style="display: block; margin: auto;" /> .footnote[Source: https://mixtape.scunning.com/matching-and-subclassification.html] --- ## Causal Inference Mixtape: Subclassification <br> <img src="images/cunningham_subclassification_05.png" width="790" style="display: block; margin: auto;" /> .footnote[Source: https://mixtape.scunning.com/matching-and-subclassification.html] --- ## Causal Inference Mixtape: Subclassification <br> <img src="images/cunningham_subclassification_06.png" width="775" style="display: block; margin: auto;" /> .footnote[Source: https://mixtape.scunning.com/matching-and-subclassification.html] --- ## Causal Inference Mixtape: Subclassification <br> <img src="images/cunningham_subclassification_07.png" width="788" style="display: block; margin: auto;" /> .footnote[Source: https://mixtape.scunning.com/matching-and-subclassification.html] http://appliedstats.org/matching_exercise.html --- class: center, middle # Appendix: --- class: center, middle # Problem of Model Dependence --- ## <img src="images/modeldep1.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/modeldep2.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/modeldep3.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/modeldep4.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/modeldep5.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/modeldep6.png" width="100%" style="display: block; margin: auto;" /> --- ## <img src="images/modeldep7.png" width="100%" style="display: block; margin: auto;" /> --- ## How to Reduce Researcher Bias? Imbalance → Model Dependence → Researcher discretion → Bias - Qualitative choice from unbiased estimates <span style="color:red">=</span> biased estimator - e.g., Choosing from <em>results</em> of 50 randomized experiments - Conscientious effort doesn't avoid biases (Banaji 2013) - People do not have easy access to their own mental processes or feedback to avoid the problem (Wilson and Brekke 1994) - Experts overestimate their ability to control personal biases more than nonexperts, and more prominent experts are the most overconfident (Tetlock 2005) - "Do not trust anyone - including yourself - to tell you how much you should trust their judgment" (Kahneman 2011) --- ## The Problems Matching Solves ### Without Matching: Imbalance → Model Dependence → Researcher discretion → Bias <br/><br/> --- ## The Problems Matching Solves ### With<strike><span style="color:red">out</strike></span> Matching: <strike><span style="color:red">Im</span></strike>balance → <strike><span style="color:red">Model Dependence</span></strike> → <strike><span style="color:red">Researcher discretion</span></strike> → <strike><span style="color:red">Bias</span></strike> <br/><br/> <span style="color:red">A central project of statistics: Automating away human discretion</span> --- class: middle, center ### Supplemental Materials from <a href="http://GaryKing.org/"><font size="6">GaryKing.org</font></a> --- ## Steps with Propensity Score Matching 1. Preprocess with Matching - Reduce `\(k\)` elements of `\(X\)` to scalar `$$\pi_i\equiv\Pr(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 Distance > <em>caliper</em> - (Many adjustments available to this basic method) 2. Estimation Difference in means or a model 3. Approximates Completely Randomized Experiment (but only under assumption that by matching on observed variables, we also match *unobserved variables*) --- ### What's Matching? - `\(Y_i\)` dep var, `\(T_i\)` (1=treated, 0=control), `\(X_i\)` confounders - Treatment Effect for <u>treated</u> observation `\(i\)`: `\begin{align*} \text{TE}_i &= Y_i(1)-Y_i(0)\\ &= \text{observed} - unobserved \end{align*}` --- ### What's Matching? - `\(Y_i\)` dep var, `\(T_i\)` (1=treated, 0=control), `\(X_i\)` confounders - Treatment Effect for <u>treated</u> observation `\(i\)`: `\begin{align*} \text{TE}_i &= Y_i-Y_i(0)\\ &= \text{observed} - unobserved \end{align*}` - Estimate <span style="color:red"> `\(Y_i(0)\)` </span> with `\(Y_j\)` with a matched `\((X_i\approx X_j)\)` control - Quantities of Interest: 1. SATT: Sample Average Treatment effect on the Treated: `\begin{align*} \text{SATT} = \mathop{\text{Mean}}\limits_{i\in \{T_i=1\}}\left(\text{TE}_i\right) \end{align*}` - <span style="color:red">Big convenience</span>: Follow preprocessing with whatever statistical method you'd have used without matching - <span style="color:red">Pruning nonmatches makes control vars matter less</span>: reduces imbalance, model dependence, researcher discretion, & bias --- ### Method 1: Coarsened Exact Matching #### (Approximates Fully Blocked Experiment) - <span style="color:red">Preprocess</span> (Matching) 1. <u>Temporarily coarsen</u> <em>X</em> as much as you're willing - e.g., Education (grade school, high school, college, graduate) 2. <u>Apply exact matching</u> to the coarsened `\(X\)`, `\(C(X)\)` - Sort observations into strata, each with unique values of `\(C(X)\)` - Prune any stratum with 0 treated or 0 control units 3. <u>Pass on original (uncoarsened) units</u> except those pruned - <span style="color:red">Estimation</span> Difference in means or a model - Weight controls in each stratum to equal treateds --- ### Method 2: Propensity Score Matching #### (Approximates Completely Randomized Experiment) 1. <span style="color:red">Preprocess</span> (Matching) - Reduce `\(k\)` elements of `\(X\)` to scalar `$$\pi_i\equiv\Pr(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 Distance > <em>caliper</em> - (Many adjustments available to this basic method) 2. <span style="color:red">Estimation</span> Difference in means or a model --- ### Method 3: Mahalanobis Distance Matching #### (Approximates Fully Blocked Experiment) 1. <span style="color:red">Preprocess</span> (Matching) - Distance `\((X_c, X_t) = \sqrt{(X_c-X_t)'S^{-1}(X_c-X_t)}\)` - (Mahalanobis is for methodologists; in applications, use Euclidean!) - Match each treated unit to the nearest control unit - Control units: not reused; pruned if unused - Prune matches if Distance `\(>\)`<em>caliper</em> - (Many adjustments available to this basic method) 2. <span style="color:red">Estimation</span> Difference in means or a model