class: center middle main-title section-title-1 # Propensity score matching .class-info[ **Session 12** .light[STA 379/679: Causal Inference <br> Lucy D'Agostino McGowan ] ] --- class: title title-1 # Matching: ATT .small[ ```r library(MatchIt) m <- matchit(qsmk ~ wt71 + age + marital + race + sex, data = nhefs_complete_uc) m ``` ] --- class: title title-1 # Matching: ATT .small[ ```r *library(MatchIt) m <- matchit(qsmk ~ wt71 + age + marital + race + sex, data = nhefs_complete_uc) m ``` ] --- class: title title-1 # Matching: ATT .small[ ```r library(MatchIt) *m <- matchit(qsmk ~ wt71 + age + marital + race + sex, data = nhefs_complete_uc) m ``` ] --- class: title title-1 # Matching: ATT .small[ ```r library(MatchIt) m <- matchit(qsmk ~ wt71 + age + marital + race + sex, data = nhefs_complete_uc) m ``` ``` ## A matchit object ## - method: 1:1 nearest neighbor matching without replacement ## - distance: Propensity score ## - estimated with logistic regression ## - number of obs.: 1566 (original), 806 (matched) ## - target estimand: ATT ## - covariates: wt71, age, marital, race, sex ``` ] --- class: title title-1 # Matching: ATT .small[ ```r library(MatchIt) m <- matchit(qsmk ~ wt71 + age + marital + race + sex, data = nhefs_complete_uc) m ``` ``` ## A matchit object ## - method: 1:1 nearest neighbor matching without replacement ## - distance: Propensity score ## - estimated with logistic regression ## - number of obs.: 1566 (original), 806 (matched) *## - target estimand: ATT ## - covariates: wt71, age, marital, race, sex ``` ] --- class: title title-1 # Matching: ATT .small[ ```r matched_data <- get_matches(m, id = "i") glimpse(matched_data) ``` ] --- class: title title-1 # Matching: ATT .small[ ```r *matched_data <- get_matches(m, id = "i") glimpse(matched_data) ``` ] --- class: title title-1 # Matching: ATT .small[ ```r matched_data <- get_matches(m, id = "i") *glimpse(matched_data) ``` ] --- class: title title-1 # Matching: ATT .small[ ```r matched_data <- get_matches(m, id = "i") glimpse(matched_data) ``` ``` ## Rows: 806 ## Columns: 71 ## $ i <chr> "11", "227", "15", "76", "18", "1261", "23", "53", "… ## $ subclass <fct> 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9… ## $ weights <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1… ## $ seqn <dbl> 428, 6309, 446, 1968, 596, 23274, 618, 1513, 806, 21… ## $ qsmk <dbl> 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0… ## $ death <dbl> 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1… ## $ yrdth <dbl> NA, NA, 88, 85, NA, NA, NA, 85, NA, NA, 85, 84, 84, … ## $ modth <dbl> NA, NA, 1, 9, NA, NA, NA, 8, NA, NA, 1, 5, 10, 2, NA… ## $ dadth <dbl> NA, NA, 3, 11, NA, NA, NA, 3, NA, NA, 22, 8, 17, 29,… ## $ sbp <dbl> 135, 136, 141, 142, 151, 127, 125, 140, 144, 154, 12… ## $ dbp <dbl> 89, 79, 79, 69, 80, 81, 71, 86, 76, 94, 83, 70, 56, … ## $ sex <fct> 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1… ## $ age <dbl> 43, 49, 71, 65, 48, 48, 56, 45, 47, 52, 57, 58, 72, … ## $ race <fct> 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ income <dbl> 19, 16, 17, 16, 18, 19, 20, 20, 22, 19, NA, 17, 12, … ## $ marital <dbl> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3… ## $ school <dbl> 12, 12, 0, 12, 12, 9, 12, 12, 17, 10, 12, 12, 10, 11… ## $ education <fct> 3, 3, 1, 3, 3, 2, 3, 3, 5, 2, 3, 3, 2, 2, 3, 4, 3, 1… ## $ ht <dbl> 176.5938, 167.5938, 147.0938, 179.0000, 164.0000, 16… ## $ wt71 <dbl> 63.96, 69.97, 75.64, 69.63, 62.03, 61.80, 60.78, 71.… ## $ wt82 <dbl> 79.83226, 68.03886, 56.69905, 69.39963, 70.30682, 57… ## $ wt82_71 <dbl> 15.8722571, -1.9311445, -18.9409537, -0.2303674, 8.2… ## $ birthplace <dbl> 42, 22, NA, 25, 36, 31, NA, 47, 42, 18, 18, NA, 25, … ## $ smokeintensity <dbl> 30, 15, 40, 5, 2, 10, 20, 15, 30, 20, 7, 40, 20, 40,… ## $ smkintensity82_71 <dbl> -30, 5, -40, 0, -2, 10, -20, 0, -30, 0, -7, 0, -20, … ## $ smokeyrs <dbl> 24, 24, 41, 47, 30, 26, 11, 28, 23, 40, 35, 42, 40, … ## $ asthma <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ bronch <dbl> 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0… ## $ tb <dbl> 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hf <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hbp <dbl> 0, 0, 0, 1, 0, 2, 0, 0, 0, 2, 1, 2, 0, 2, 0, 0, 0, 1… ## $ pepticulcer <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0… ## $ colitis <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hepatitis <dbl> 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ chroniccough <dbl> 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hayfever <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ diabetes <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ polio <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0… ## $ tumor <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ nervousbreak <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ alcoholpy <dbl> 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1… ## $ alcoholfreq <dbl> 3, 3, 4, 0, 1, 1, 3, 0, 3, 0, 2, 0, 1, 0, 3, 3, 4, 0… ## $ alcoholtype <dbl> 3, 1, 4, 3, 2, 3, 4, 1, 2, 1, 3, 2, 3, 1, 4, 4, 4, 1… ## $ alcoholhowmuch <dbl> 2, 1, NA, 1, 1, 3, NA, 6, 1, 2, 1, 1, 2, 4, NA, NA, … ## $ pica <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ headache <dbl> 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0… ## $ otherpain <dbl> 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ weakheart <dbl> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ allergies <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ nerves <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ lackpep <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hbpmed <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 1, 2, 0, 2, 0, 0, 0, 1… ## $ boweltrouble <dbl> 0, 1, 1, 1, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ wtloss <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ infection <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0… ## $ active <fct> 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1… ## $ exercise <fct> 1, 2, 1, 1, 1, 1, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 1, 2… ## $ birthcontrol <dbl> 2, 0, 0, 2, 0, 0, 0, 2, 2, 2, 2, 2, 0, 2, 0, 0, 0, 0… ## $ pregnancies <dbl> NA, 3, 15, NA, 3, 4, 4, NA, NA, NA, NA, NA, 4, NA, 5… ## $ cholesterol <dbl> 173, 199, 229, 244, 225, 225, 230, 208, 328, 202, 26… ## $ hightax82 <dbl> 0, 0, NA, 1, 0, 0, NA, 0, 0, 0, 0, NA, 1, 0, 0, 1, 1… ## $ price71 <dbl> 2.346680, 2.099609, NA, 2.414551, 2.241699, 2.157715… ## $ price82 <dbl> 1.797363, 1.775391, NA, 1.951172, 1.828125, 1.841309… ## $ tax71 <dbl> 1.3649902, 0.9974365, NA, 1.2597656, 1.0498047, 1.10… ## $ tax82 <dbl> 0.5718994, 0.4179688, NA, 0.6379395, 0.5059814, 0.57… ## $ price71_82 <dbl> 0.54931641, 0.32458496, NA, 0.46356201, 0.41357422, … ## $ tax71_82 <dbl> 0.7929688, 0.5794678, NA, 0.6219482, 0.5439453, 0.53… ## $ id <int> 11, 240, 15, 79, 18, 1317, 23, 54, 27, 992, 32, 849,… ## $ censored <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ older <dbl> 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1… ## $ distance <dbl> 0.2758261, 0.2757454, 0.3964640, 0.3965607, 0.260259… ``` ] --- class: title title-1 # Matching: ATT .small[ ```r matched_data <- get_matches(m, id = "i") glimpse(matched_data) ``` ``` *## Rows: 806 ## Columns: 71 ## $ i <chr> "11", "227", "15", "76", "18", "1261", "23", "53", "… ## $ subclass <fct> 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9… ## $ weights <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1… ## $ seqn <dbl> 428, 6309, 446, 1968, 596, 23274, 618, 1513, 806, 21… ## $ qsmk <dbl> 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0… ## $ death <dbl> 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1… ## $ yrdth <dbl> NA, NA, 88, 85, NA, NA, NA, 85, NA, NA, 85, 84, 84, … ## $ modth <dbl> NA, NA, 1, 9, NA, NA, NA, 8, NA, NA, 1, 5, 10, 2, NA… ## $ dadth <dbl> NA, NA, 3, 11, NA, NA, NA, 3, NA, NA, 22, 8, 17, 29,… ## $ sbp <dbl> 135, 136, 141, 142, 151, 127, 125, 140, 144, 154, 12… ## $ dbp <dbl> 89, 79, 79, 69, 80, 81, 71, 86, 76, 94, 83, 70, 56, … ## $ sex <fct> 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1… ## $ age <dbl> 43, 49, 71, 65, 48, 48, 56, 45, 47, 52, 57, 58, 72, … ## $ race <fct> 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ income <dbl> 19, 16, 17, 16, 18, 19, 20, 20, 22, 19, NA, 17, 12, … ## $ marital <dbl> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3… ## $ school <dbl> 12, 12, 0, 12, 12, 9, 12, 12, 17, 10, 12, 12, 10, 11… ## $ education <fct> 3, 3, 1, 3, 3, 2, 3, 3, 5, 2, 3, 3, 2, 2, 3, 4, 3, 1… ## $ ht <dbl> 176.5938, 167.5938, 147.0938, 179.0000, 164.0000, 16… ## $ wt71 <dbl> 63.96, 69.97, 75.64, 69.63, 62.03, 61.80, 60.78, 71.… ## $ wt82 <dbl> 79.83226, 68.03886, 56.69905, 69.39963, 70.30682, 57… ## $ wt82_71 <dbl> 15.8722571, -1.9311445, -18.9409537, -0.2303674, 8.2… ## $ birthplace <dbl> 42, 22, NA, 25, 36, 31, NA, 47, 42, 18, 18, NA, 25, … ## $ smokeintensity <dbl> 30, 15, 40, 5, 2, 10, 20, 15, 30, 20, 7, 40, 20, 40,… ## $ smkintensity82_71 <dbl> -30, 5, -40, 0, -2, 10, -20, 0, -30, 0, -7, 0, -20, … ## $ smokeyrs <dbl> 24, 24, 41, 47, 30, 26, 11, 28, 23, 40, 35, 42, 40, … ## $ asthma <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ bronch <dbl> 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0… ## $ tb <dbl> 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hf <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hbp <dbl> 0, 0, 0, 1, 0, 2, 0, 0, 0, 2, 1, 2, 0, 2, 0, 0, 0, 1… ## $ pepticulcer <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0… ## $ colitis <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hepatitis <dbl> 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ chroniccough <dbl> 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hayfever <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ diabetes <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ polio <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0… ## $ tumor <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ nervousbreak <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ alcoholpy <dbl> 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1… ## $ alcoholfreq <dbl> 3, 3, 4, 0, 1, 1, 3, 0, 3, 0, 2, 0, 1, 0, 3, 3, 4, 0… ## $ alcoholtype <dbl> 3, 1, 4, 3, 2, 3, 4, 1, 2, 1, 3, 2, 3, 1, 4, 4, 4, 1… ## $ alcoholhowmuch <dbl> 2, 1, NA, 1, 1, 3, NA, 6, 1, 2, 1, 1, 2, 4, NA, NA, … ## $ pica <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ headache <dbl> 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0… ## $ otherpain <dbl> 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ weakheart <dbl> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ allergies <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ nerves <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ lackpep <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hbpmed <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 1, 2, 0, 2, 0, 0, 0, 1… ## $ boweltrouble <dbl> 0, 1, 1, 1, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ wtloss <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ infection <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0… ## $ active <fct> 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1… ## $ exercise <fct> 1, 2, 1, 1, 1, 1, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 1, 2… ## $ birthcontrol <dbl> 2, 0, 0, 2, 0, 0, 0, 2, 2, 2, 2, 2, 0, 2, 0, 0, 0, 0… ## $ pregnancies <dbl> NA, 3, 15, NA, 3, 4, 4, NA, NA, NA, NA, NA, 4, NA, 5… ## $ cholesterol <dbl> 173, 199, 229, 244, 225, 225, 230, 208, 328, 202, 26… ## $ hightax82 <dbl> 0, 0, NA, 1, 0, 0, NA, 0, 0, 0, 0, NA, 1, 0, 0, 1, 1… ## $ price71 <dbl> 2.346680, 2.099609, NA, 2.414551, 2.241699, 2.157715… ## $ price82 <dbl> 1.797363, 1.775391, NA, 1.951172, 1.828125, 1.841309… ## $ tax71 <dbl> 1.3649902, 0.9974365, NA, 1.2597656, 1.0498047, 1.10… ## $ tax82 <dbl> 0.5718994, 0.4179688, NA, 0.6379395, 0.5059814, 0.57… ## $ price71_82 <dbl> 0.54931641, 0.32458496, NA, 0.46356201, 0.41357422, … ## $ tax71_82 <dbl> 0.7929688, 0.5794678, NA, 0.6219482, 0.5439453, 0.53… ## $ id <int> 11, 240, 15, 79, 18, 1317, 23, 54, 27, 992, 32, 849,… ## $ censored <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ older <dbl> 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1… ## $ distance <dbl> 0.2758261, 0.2757454, 0.3964640, 0.3965607, 0.260259… ``` ] --- class: title title-1 # Matching: ATT .small[ ```r matched_data <- get_matches(m, id = "i") glimpse(matched_data) ``` ``` ## Rows: 806 *## Columns: 71 ## $ i <chr> "11", "227", "15", "76", "18", "1261", "23", "53", "… ## $ subclass <fct> 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9… ## $ weights <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1… ## $ seqn <dbl> 428, 6309, 446, 1968, 596, 23274, 618, 1513, 806, 21… ## $ qsmk <dbl> 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0… ## $ death <dbl> 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1… ## $ yrdth <dbl> NA, NA, 88, 85, NA, NA, NA, 85, NA, NA, 85, 84, 84, … ## $ modth <dbl> NA, NA, 1, 9, NA, NA, NA, 8, NA, NA, 1, 5, 10, 2, NA… ## $ dadth <dbl> NA, NA, 3, 11, NA, NA, NA, 3, NA, NA, 22, 8, 17, 29,… ## $ sbp <dbl> 135, 136, 141, 142, 151, 127, 125, 140, 144, 154, 12… ## $ dbp <dbl> 89, 79, 79, 69, 80, 81, 71, 86, 76, 94, 83, 70, 56, … ## $ sex <fct> 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1… ## $ age <dbl> 43, 49, 71, 65, 48, 48, 56, 45, 47, 52, 57, 58, 72, … ## $ race <fct> 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ income <dbl> 19, 16, 17, 16, 18, 19, 20, 20, 22, 19, NA, 17, 12, … ## $ marital <dbl> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3… ## $ school <dbl> 12, 12, 0, 12, 12, 9, 12, 12, 17, 10, 12, 12, 10, 11… ## $ education <fct> 3, 3, 1, 3, 3, 2, 3, 3, 5, 2, 3, 3, 2, 2, 3, 4, 3, 1… ## $ ht <dbl> 176.5938, 167.5938, 147.0938, 179.0000, 164.0000, 16… ## $ wt71 <dbl> 63.96, 69.97, 75.64, 69.63, 62.03, 61.80, 60.78, 71.… ## $ wt82 <dbl> 79.83226, 68.03886, 56.69905, 69.39963, 70.30682, 57… ## $ wt82_71 <dbl> 15.8722571, -1.9311445, -18.9409537, -0.2303674, 8.2… ## $ birthplace <dbl> 42, 22, NA, 25, 36, 31, NA, 47, 42, 18, 18, NA, 25, … ## $ smokeintensity <dbl> 30, 15, 40, 5, 2, 10, 20, 15, 30, 20, 7, 40, 20, 40,… ## $ smkintensity82_71 <dbl> -30, 5, -40, 0, -2, 10, -20, 0, -30, 0, -7, 0, -20, … ## $ smokeyrs <dbl> 24, 24, 41, 47, 30, 26, 11, 28, 23, 40, 35, 42, 40, … ## $ asthma <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ bronch <dbl> 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0… ## $ tb <dbl> 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hf <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hbp <dbl> 0, 0, 0, 1, 0, 2, 0, 0, 0, 2, 1, 2, 0, 2, 0, 0, 0, 1… ## $ pepticulcer <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0… ## $ colitis <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hepatitis <dbl> 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ chroniccough <dbl> 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hayfever <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ diabetes <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ polio <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0… ## $ tumor <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ nervousbreak <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ alcoholpy <dbl> 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1… ## $ alcoholfreq <dbl> 3, 3, 4, 0, 1, 1, 3, 0, 3, 0, 2, 0, 1, 0, 3, 3, 4, 0… ## $ alcoholtype <dbl> 3, 1, 4, 3, 2, 3, 4, 1, 2, 1, 3, 2, 3, 1, 4, 4, 4, 1… ## $ alcoholhowmuch <dbl> 2, 1, NA, 1, 1, 3, NA, 6, 1, 2, 1, 1, 2, 4, NA, NA, … ## $ pica <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ headache <dbl> 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0… ## $ otherpain <dbl> 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ weakheart <dbl> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ allergies <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ nerves <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ lackpep <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hbpmed <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 1, 2, 0, 2, 0, 0, 0, 1… ## $ boweltrouble <dbl> 0, 1, 1, 1, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ wtloss <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ infection <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0… ## $ active <fct> 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1… ## $ exercise <fct> 1, 2, 1, 1, 1, 1, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 1, 2… ## $ birthcontrol <dbl> 2, 0, 0, 2, 0, 0, 0, 2, 2, 2, 2, 2, 0, 2, 0, 0, 0, 0… ## $ pregnancies <dbl> NA, 3, 15, NA, 3, 4, 4, NA, NA, NA, NA, NA, 4, NA, 5… ## $ cholesterol <dbl> 173, 199, 229, 244, 225, 225, 230, 208, 328, 202, 26… ## $ hightax82 <dbl> 0, 0, NA, 1, 0, 0, NA, 0, 0, 0, 0, NA, 1, 0, 0, 1, 1… ## $ price71 <dbl> 2.346680, 2.099609, NA, 2.414551, 2.241699, 2.157715… ## $ price82 <dbl> 1.797363, 1.775391, NA, 1.951172, 1.828125, 1.841309… ## $ tax71 <dbl> 1.3649902, 0.9974365, NA, 1.2597656, 1.0498047, 1.10… ## $ tax82 <dbl> 0.5718994, 0.4179688, NA, 0.6379395, 0.5059814, 0.57… ## $ price71_82 <dbl> 0.54931641, 0.32458496, NA, 0.46356201, 0.41357422, … ## $ tax71_82 <dbl> 0.7929688, 0.5794678, NA, 0.6219482, 0.5439453, 0.53… ## $ id <int> 11, 240, 15, 79, 18, 1317, 23, 54, 27, 992, 32, 849,… ## $ censored <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ older <dbl> 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1… ## $ distance <dbl> 0.2758261, 0.2757454, 0.3964640, 0.3965607, 0.260259… ``` ] --- class: title title-1 # Matching: ATT .small[ ```r matched_data <- get_matches(m, id = "i") glimpse(matched_data) ``` ``` ## Rows: 806 ## Columns: 71 *## $ i <chr> "11", "227", "15", "76", "18", "1261", "23", "53", "… ## $ subclass <fct> 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9… ## $ weights <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1… ## $ seqn <dbl> 428, 6309, 446, 1968, 596, 23274, 618, 1513, 806, 21… ## $ qsmk <dbl> 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0… ## $ death <dbl> 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1… ## $ yrdth <dbl> NA, NA, 88, 85, NA, NA, NA, 85, NA, NA, 85, 84, 84, … ## $ modth <dbl> NA, NA, 1, 9, NA, NA, NA, 8, NA, NA, 1, 5, 10, 2, NA… ## $ dadth <dbl> NA, NA, 3, 11, NA, NA, NA, 3, NA, NA, 22, 8, 17, 29,… ## $ sbp <dbl> 135, 136, 141, 142, 151, 127, 125, 140, 144, 154, 12… ## $ dbp <dbl> 89, 79, 79, 69, 80, 81, 71, 86, 76, 94, 83, 70, 56, … ## $ sex <fct> 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1… ## $ age <dbl> 43, 49, 71, 65, 48, 48, 56, 45, 47, 52, 57, 58, 72, … ## $ race <fct> 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ income <dbl> 19, 16, 17, 16, 18, 19, 20, 20, 22, 19, NA, 17, 12, … ## $ marital <dbl> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3… ## $ school <dbl> 12, 12, 0, 12, 12, 9, 12, 12, 17, 10, 12, 12, 10, 11… ## $ education <fct> 3, 3, 1, 3, 3, 2, 3, 3, 5, 2, 3, 3, 2, 2, 3, 4, 3, 1… ## $ ht <dbl> 176.5938, 167.5938, 147.0938, 179.0000, 164.0000, 16… ## $ wt71 <dbl> 63.96, 69.97, 75.64, 69.63, 62.03, 61.80, 60.78, 71.… ## $ wt82 <dbl> 79.83226, 68.03886, 56.69905, 69.39963, 70.30682, 57… ## $ wt82_71 <dbl> 15.8722571, -1.9311445, -18.9409537, -0.2303674, 8.2… ## $ birthplace <dbl> 42, 22, NA, 25, 36, 31, NA, 47, 42, 18, 18, NA, 25, … ## $ smokeintensity <dbl> 30, 15, 40, 5, 2, 10, 20, 15, 30, 20, 7, 40, 20, 40,… ## $ smkintensity82_71 <dbl> -30, 5, -40, 0, -2, 10, -20, 0, -30, 0, -7, 0, -20, … ## $ smokeyrs <dbl> 24, 24, 41, 47, 30, 26, 11, 28, 23, 40, 35, 42, 40, … ## $ asthma <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ bronch <dbl> 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0… ## $ tb <dbl> 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hf <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hbp <dbl> 0, 0, 0, 1, 0, 2, 0, 0, 0, 2, 1, 2, 0, 2, 0, 0, 0, 1… ## $ pepticulcer <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0… ## $ colitis <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hepatitis <dbl> 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ chroniccough <dbl> 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hayfever <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ diabetes <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ polio <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0… ## $ tumor <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ nervousbreak <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ alcoholpy <dbl> 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1… ## $ alcoholfreq <dbl> 3, 3, 4, 0, 1, 1, 3, 0, 3, 0, 2, 0, 1, 0, 3, 3, 4, 0… ## $ alcoholtype <dbl> 3, 1, 4, 3, 2, 3, 4, 1, 2, 1, 3, 2, 3, 1, 4, 4, 4, 1… ## $ alcoholhowmuch <dbl> 2, 1, NA, 1, 1, 3, NA, 6, 1, 2, 1, 1, 2, 4, NA, NA, … ## $ pica <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ headache <dbl> 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0… ## $ otherpain <dbl> 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ weakheart <dbl> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ allergies <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ nerves <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ lackpep <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hbpmed <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 1, 2, 0, 2, 0, 0, 0, 1… ## $ boweltrouble <dbl> 0, 1, 1, 1, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ wtloss <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ infection <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0… ## $ active <fct> 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1… ## $ exercise <fct> 1, 2, 1, 1, 1, 1, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 1, 2… ## $ birthcontrol <dbl> 2, 0, 0, 2, 0, 0, 0, 2, 2, 2, 2, 2, 0, 2, 0, 0, 0, 0… ## $ pregnancies <dbl> NA, 3, 15, NA, 3, 4, 4, NA, NA, NA, NA, NA, 4, NA, 5… ## $ cholesterol <dbl> 173, 199, 229, 244, 225, 225, 230, 208, 328, 202, 26… ## $ hightax82 <dbl> 0, 0, NA, 1, 0, 0, NA, 0, 0, 0, 0, NA, 1, 0, 0, 1, 1… ## $ price71 <dbl> 2.346680, 2.099609, NA, 2.414551, 2.241699, 2.157715… ## $ price82 <dbl> 1.797363, 1.775391, NA, 1.951172, 1.828125, 1.841309… ## $ tax71 <dbl> 1.3649902, 0.9974365, NA, 1.2597656, 1.0498047, 1.10… ## $ tax82 <dbl> 0.5718994, 0.4179688, NA, 0.6379395, 0.5059814, 0.57… ## $ price71_82 <dbl> 0.54931641, 0.32458496, NA, 0.46356201, 0.41357422, … ## $ tax71_82 <dbl> 0.7929688, 0.5794678, NA, 0.6219482, 0.5439453, 0.53… ## $ id <int> 11, 240, 15, 79, 18, 1317, 23, 54, 27, 992, 32, 849,… ## $ censored <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ older <dbl> 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1… ## $ distance <dbl> 0.2758261, 0.2757454, 0.3964640, 0.3965607, 0.260259… ``` ] --- class: title title-1 # Matching: ATT .small[ ```r matched_data <- get_matches(m, id = "i") glimpse(matched_data) ``` ``` ## Rows: 806 ## Columns: 71 ## $ i <chr> "11", "227", "15", "76", "18", "1261", "23", "53", "… *## $ subclass <fct> 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9… ## $ weights <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1… ## $ seqn <dbl> 428, 6309, 446, 1968, 596, 23274, 618, 1513, 806, 21… ## $ qsmk <dbl> 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0… ## $ death <dbl> 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1… ## $ yrdth <dbl> NA, NA, 88, 85, NA, NA, NA, 85, NA, NA, 85, 84, 84, … ## $ modth <dbl> NA, NA, 1, 9, NA, NA, NA, 8, NA, NA, 1, 5, 10, 2, NA… ## $ dadth <dbl> NA, NA, 3, 11, NA, NA, NA, 3, NA, NA, 22, 8, 17, 29,… ## $ sbp <dbl> 135, 136, 141, 142, 151, 127, 125, 140, 144, 154, 12… ## $ dbp <dbl> 89, 79, 79, 69, 80, 81, 71, 86, 76, 94, 83, 70, 56, … ## $ sex <fct> 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1… ## $ age <dbl> 43, 49, 71, 65, 48, 48, 56, 45, 47, 52, 57, 58, 72, … ## $ race <fct> 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ income <dbl> 19, 16, 17, 16, 18, 19, 20, 20, 22, 19, NA, 17, 12, … ## $ marital <dbl> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3… ## $ school <dbl> 12, 12, 0, 12, 12, 9, 12, 12, 17, 10, 12, 12, 10, 11… ## $ education <fct> 3, 3, 1, 3, 3, 2, 3, 3, 5, 2, 3, 3, 2, 2, 3, 4, 3, 1… ## $ ht <dbl> 176.5938, 167.5938, 147.0938, 179.0000, 164.0000, 16… ## $ wt71 <dbl> 63.96, 69.97, 75.64, 69.63, 62.03, 61.80, 60.78, 71.… ## $ wt82 <dbl> 79.83226, 68.03886, 56.69905, 69.39963, 70.30682, 57… ## $ wt82_71 <dbl> 15.8722571, -1.9311445, -18.9409537, -0.2303674, 8.2… ## $ birthplace <dbl> 42, 22, NA, 25, 36, 31, NA, 47, 42, 18, 18, NA, 25, … ## $ smokeintensity <dbl> 30, 15, 40, 5, 2, 10, 20, 15, 30, 20, 7, 40, 20, 40,… ## $ smkintensity82_71 <dbl> -30, 5, -40, 0, -2, 10, -20, 0, -30, 0, -7, 0, -20, … ## $ smokeyrs <dbl> 24, 24, 41, 47, 30, 26, 11, 28, 23, 40, 35, 42, 40, … ## $ asthma <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ bronch <dbl> 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0… ## $ tb <dbl> 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hf <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hbp <dbl> 0, 0, 0, 1, 0, 2, 0, 0, 0, 2, 1, 2, 0, 2, 0, 0, 0, 1… ## $ pepticulcer <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0… ## $ colitis <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hepatitis <dbl> 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ chroniccough <dbl> 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hayfever <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ diabetes <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ polio <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0… ## $ tumor <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ nervousbreak <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ alcoholpy <dbl> 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1… ## $ alcoholfreq <dbl> 3, 3, 4, 0, 1, 1, 3, 0, 3, 0, 2, 0, 1, 0, 3, 3, 4, 0… ## $ alcoholtype <dbl> 3, 1, 4, 3, 2, 3, 4, 1, 2, 1, 3, 2, 3, 1, 4, 4, 4, 1… ## $ alcoholhowmuch <dbl> 2, 1, NA, 1, 1, 3, NA, 6, 1, 2, 1, 1, 2, 4, NA, NA, … ## $ pica <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ headache <dbl> 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0… ## $ otherpain <dbl> 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ weakheart <dbl> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ allergies <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ nerves <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ lackpep <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hbpmed <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 1, 2, 0, 2, 0, 0, 0, 1… ## $ boweltrouble <dbl> 0, 1, 1, 1, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ wtloss <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ infection <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0… ## $ active <fct> 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1… ## $ exercise <fct> 1, 2, 1, 1, 1, 1, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 1, 2… ## $ birthcontrol <dbl> 2, 0, 0, 2, 0, 0, 0, 2, 2, 2, 2, 2, 0, 2, 0, 0, 0, 0… ## $ pregnancies <dbl> NA, 3, 15, NA, 3, 4, 4, NA, NA, NA, NA, NA, 4, NA, 5… ## $ cholesterol <dbl> 173, 199, 229, 244, 225, 225, 230, 208, 328, 202, 26… ## $ hightax82 <dbl> 0, 0, NA, 1, 0, 0, NA, 0, 0, 0, 0, NA, 1, 0, 0, 1, 1… ## $ price71 <dbl> 2.346680, 2.099609, NA, 2.414551, 2.241699, 2.157715… ## $ price82 <dbl> 1.797363, 1.775391, NA, 1.951172, 1.828125, 1.841309… ## $ tax71 <dbl> 1.3649902, 0.9974365, NA, 1.2597656, 1.0498047, 1.10… ## $ tax82 <dbl> 0.5718994, 0.4179688, NA, 0.6379395, 0.5059814, 0.57… ## $ price71_82 <dbl> 0.54931641, 0.32458496, NA, 0.46356201, 0.41357422, … ## $ tax71_82 <dbl> 0.7929688, 0.5794678, NA, 0.6219482, 0.5439453, 0.53… ## $ id <int> 11, 240, 15, 79, 18, 1317, 23, 54, 27, 992, 32, 849,… ## $ censored <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ older <dbl> 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1… ## $ distance <dbl> 0.2758261, 0.2757454, 0.3964640, 0.3965607, 0.260259… ``` ] --- class: title title-1 # Matching: ATC .small[ ```r library(MatchIt) m <- matchit(qsmk ~ wt71 + age + marital + race + sex, data = nhefs_complete_uc, estimand = "ATC") m ``` ] --- class: title title-1 # Matching: ATC .small[ ```r library(MatchIt) m <- matchit(qsmk ~ wt71 + age + marital + race + sex, data = nhefs_complete_uc, * estimand = "ATC") m ``` ] --- class: title title-1 # Matching: ATC .small[ ```r library(MatchIt) m <- matchit(qsmk ~ wt71 + age + marital + race + sex, data = nhefs_complete_uc, estimand = "ATC") m ``` ``` ## A matchit object ## - method: 1:1 nearest neighbor matching without replacement ## - distance: Propensity score ## - estimated with logistic regression ## - number of obs.: 1566 (original), 806 (matched) ## - target estimand: ATC ## - covariates: wt71, age, marital, race, sex ``` ] --- class: title title-1 # Matching: ATC .small[ ```r library(MatchIt) m <- matchit(qsmk ~ wt71 + age + marital + race + sex, data = nhefs_complete_uc, estimand = "ATC") m ``` ``` ## A matchit object ## - method: 1:1 nearest neighbor matching without replacement ## - distance: Propensity score ## - estimated with logistic regression ## - number of obs.: 1566 (original), 806 (matched) *## - target estimand: ATC ## - covariates: wt71, age, marital, race, sex ``` ] --- class: title title-1 # Matching ATM .small[ ```r library(MatchIt) m <- matchit(qsmk ~ wt71 + age + marital + race + sex, data = nhefs_complete_uc, link = "linear.logit", caliper = 0.1) m ``` ] --- class: title title-1 # Matching ATM .small[ ```r library(MatchIt) m <- matchit(qsmk ~ wt71 + age + marital + race + sex, data = nhefs_complete_uc, * link = "linear.logit", caliper = 0.1) m ``` ] --- class: title title-1 # Matching ATM .small[ ```r library(MatchIt) m <- matchit(qsmk ~ wt71 + age + marital + race + sex, data = nhefs_complete_uc, link = "linear.logit", * caliper = 0.1) m ``` ] -- .box-1[Only matches propensity scores withing 0.1 standard deviations on the linear-logit scale] --- class: title title-1 # Matching ATM .small[ ```r library(MatchIt) m <- matchit(qsmk ~ wt71 + age + marital + race + sex, data = nhefs_complete_uc, link = "linear.logit", caliper = 0.1) m ``` ``` ## A matchit object ## - method: 1:1 nearest neighbor matching without replacement ## - distance: Propensity score [caliper] ## - estimated with logistic regression and linearized ## - caliper: <distance> (0.039) ## - number of obs.: 1566 (original), 804 (matched) ## - target estimand: ATT ## - covariates: wt71, age, marital, race, sex ``` ] --- class: title title-1 # Matching ATM .small[ ```r library(MatchIt) m <- matchit(qsmk ~ wt71 + age + marital + race + sex, data = nhefs_complete_uc, link = "linear.logit", caliper = 0.1) m ``` ``` ## A matchit object ## - method: 1:1 nearest neighbor matching without replacement ## - distance: Propensity score [caliper] ## - estimated with logistic regression and linearized ## - caliper: <distance> (0.039) ## - number of obs.: 1566 (original), 804 (matched) *## - target estimand: ATT ## - covariates: wt71, age, marital, race, sex ``` ] --- class: title title-1 # Matching ATM .small[ ```r matched_data <- get_matches(m, id = "i") glimpse(matched_data) ``` ``` ## Rows: 804 ## Columns: 71 ## $ i <chr> "11", "227", "15", "76", "18", "1261", "23", "53", "… ## $ subclass <fct> 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9… ## $ weights <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1… ## $ seqn <dbl> 428, 6309, 446, 1968, 596, 23274, 618, 1513, 806, 21… ## $ qsmk <dbl> 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0… ## $ death <dbl> 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1… ## $ yrdth <dbl> NA, NA, 88, 85, NA, NA, NA, 85, NA, NA, 85, 84, 84, … ## $ modth <dbl> NA, NA, 1, 9, NA, NA, NA, 8, NA, NA, 1, 5, 10, 2, NA… ## $ dadth <dbl> NA, NA, 3, 11, NA, NA, NA, 3, NA, NA, 22, 8, 17, 29,… ## $ sbp <dbl> 135, 136, 141, 142, 151, 127, 125, 140, 144, 154, 12… ## $ dbp <dbl> 89, 79, 79, 69, 80, 81, 71, 86, 76, 94, 83, 70, 56, … ## $ sex <fct> 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1… ## $ age <dbl> 43, 49, 71, 65, 48, 48, 56, 45, 47, 52, 57, 58, 72, … ## $ race <fct> 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ income <dbl> 19, 16, 17, 16, 18, 19, 20, 20, 22, 19, NA, 17, 12, … ## $ marital <dbl> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3… ## $ school <dbl> 12, 12, 0, 12, 12, 9, 12, 12, 17, 10, 12, 12, 10, 11… ## $ education <fct> 3, 3, 1, 3, 3, 2, 3, 3, 5, 2, 3, 3, 2, 2, 3, 4, 3, 1… ## $ ht <dbl> 176.5938, 167.5938, 147.0938, 179.0000, 164.0000, 16… ## $ wt71 <dbl> 63.96, 69.97, 75.64, 69.63, 62.03, 61.80, 60.78, 71.… ## $ wt82 <dbl> 79.83226, 68.03886, 56.69905, 69.39963, 70.30682, 57… ## $ wt82_71 <dbl> 15.8722571, -1.9311445, -18.9409537, -0.2303674, 8.2… ## $ birthplace <dbl> 42, 22, NA, 25, 36, 31, NA, 47, 42, 18, 18, NA, 25, … ## $ smokeintensity <dbl> 30, 15, 40, 5, 2, 10, 20, 15, 30, 20, 7, 40, 20, 40,… ## $ smkintensity82_71 <dbl> -30, 5, -40, 0, -2, 10, -20, 0, -30, 0, -7, 0, -20, … ## $ smokeyrs <dbl> 24, 24, 41, 47, 30, 26, 11, 28, 23, 40, 35, 42, 40, … ## $ asthma <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ bronch <dbl> 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0… ## $ tb <dbl> 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hf <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hbp <dbl> 0, 0, 0, 1, 0, 2, 0, 0, 0, 2, 1, 2, 0, 2, 0, 0, 0, 1… ## $ pepticulcer <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0… ## $ colitis <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hepatitis <dbl> 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ chroniccough <dbl> 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hayfever <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ diabetes <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ polio <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0… ## $ tumor <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ nervousbreak <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ alcoholpy <dbl> 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1… ## $ alcoholfreq <dbl> 3, 3, 4, 0, 1, 1, 3, 0, 3, 0, 2, 0, 1, 0, 3, 3, 4, 0… ## $ alcoholtype <dbl> 3, 1, 4, 3, 2, 3, 4, 1, 2, 1, 3, 2, 3, 1, 4, 4, 4, 1… ## $ alcoholhowmuch <dbl> 2, 1, NA, 1, 1, 3, NA, 6, 1, 2, 1, 1, 2, 4, NA, NA, … ## $ pica <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ headache <dbl> 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0… ## $ otherpain <dbl> 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1… ## $ weakheart <dbl> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ allergies <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ nerves <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ lackpep <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ hbpmed <dbl> 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 1, 2, 0, 2, 0, 0, 0, 1… ## $ boweltrouble <dbl> 0, 1, 1, 1, 0, 2, 0, 0, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0… ## $ wtloss <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ infection <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0… ## $ active <fct> 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 2, 2, 1, 1, 1, 1, 1, 1… ## $ exercise <fct> 1, 2, 1, 1, 1, 1, 2, 2, 0, 1, 2, 2, 2, 2, 2, 2, 1, 2… ## $ birthcontrol <dbl> 2, 0, 0, 2, 0, 0, 0, 2, 2, 2, 2, 2, 0, 2, 0, 0, 0, 0… ## $ pregnancies <dbl> NA, 3, 15, NA, 3, 4, 4, NA, NA, NA, NA, NA, 4, NA, 5… ## $ cholesterol <dbl> 173, 199, 229, 244, 225, 225, 230, 208, 328, 202, 26… ## $ hightax82 <dbl> 0, 0, NA, 1, 0, 0, NA, 0, 0, 0, 0, NA, 1, 0, 0, 1, 1… ## $ price71 <dbl> 2.346680, 2.099609, NA, 2.414551, 2.241699, 2.157715… ## $ price82 <dbl> 1.797363, 1.775391, NA, 1.951172, 1.828125, 1.841309… ## $ tax71 <dbl> 1.3649902, 0.9974365, NA, 1.2597656, 1.0498047, 1.10… ## $ tax82 <dbl> 0.5718994, 0.4179688, NA, 0.6379395, 0.5059814, 0.57… ## $ price71_82 <dbl> 0.54931641, 0.32458496, NA, 0.46356201, 0.41357422, … ## $ tax71_82 <dbl> 0.7929688, 0.5794678, NA, 0.6219482, 0.5439453, 0.53… ## $ id <int> 11, 240, 15, 79, 18, 1317, 23, 54, 27, 992, 32, 849,… ## $ censored <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0… ## $ older <dbl> 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1… ## $ distance <dbl> -0.9652609, -0.9656651, -0.4202205, -0.4198163, -1.0… ``` ] --- class: title title-1 #
Application Exercise .box-1[Open `appex-09` from last class] .box-1[Using the same propensity score model, calculate ATM matches with a caliper of 0.05] .box-1[Extract your matched data set and create a Table 1 of just this data] .box-1[Knit, commit, push to GitHub]
10
:
00