Implementing Propensity Score Methods: A Review of the … › ... › files ›...

22
Implementing Propensity Score Methods: A Review of the Statistical Software Megan Schuler Harvard Medical School Departments of Health Care Policy [email protected] Aug 13, 2015

Transcript of Implementing Propensity Score Methods: A Review of the … › ... › files ›...

Page 1: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

Implementing Propensity Score Methods: AReview of the Statistical Software

Megan SchulerHarvard Medical School

Departments of Health Care Policy

[email protected]

Aug 13, 2015

Page 2: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

Overview

R

I Matching with MatchIt

I Weighting with twang

STATA

I Matching with psmatch2, cem

I Matching and weighting with teffects

SAS

I Matching with %GMATCH, %VMATCH

Additional resources

Page 3: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

Matching in R: MatchIt package

I MatchIt is one of the most comprehensive matching packages(Ho, Imai, King, Stuart)

I Implements many matching types (nearest neighbor w caliper,Mahalanobis, exact, coarsened exact, full, optimal, genetic)

I Additionally, PS subclassification

I Both parametric and non-parametric methods for PSestimation (e.g, GAM, classification trees, neural networks)

I Extensive balance diagnostics (balance tables, ASMD graphs,PS histographs, QQ-plots, etc.)

Page 4: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

MatchIt syntax

Default = 1:1 nearest neighbor matching without replacement

I m.out=matchit(treat ∼ Xl + · · · + Xn, data=mydata,method=“nearest”)

Exact match on several variables

I m.out=matchit(treat ∼ Xl + · · · + Xn, data=mydata,exact=c(“X1,X2”) )

Optimal matching

I m.out=matchit(treat ∼ Xl + · · · + Xn, data=mydata,method=“optimal”)

Balance table

I summary(m.out, standardize=T, interactions=T)

Page 5: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

MatchIt: Estimating treatment effects

Save matched dataset from MatchIt output

I matched.mydata = match.data(m.out)

1:1 Matching

I lm(Y ∼ treat, data=matched.mydata)

Matching w replacement, k:1 matching, or variable ratio matching:use weights, with survey package

I design.ps = svydesign(ids=˜1, weights=˜weights,data=matched.mydata)

I svyglm(Y ∼ treat, design = design.ps)

Page 6: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

MatchIt balance diagnostics

Page 7: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

Weighting in R: twang package

I twang implements a machine learning algorithm (generalizedboosted modeling) for PS estimation (Ridgeway, McCaffrey,Morral, Griffin, Burgette)

I Implements both ATE and ATT weighting

I Missing data: includes both variable and missingness indicatorin PS model

I Allows both binary and categorical treatment (3+ groups)

Page 8: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

twang syntax

ATT weighting for binary treatment

I ps.out=ps(treat ∼ Xl + · · · + Xn, data=mydata,n.trees=5000, interaction.depth=2, estimand=“ATT”)

ATE weighting for binary treatment

I ps.out=ps(treat ∼ Xl + · · · + Xn, data=mydata,n.trees=5000, interaction.depth=2, estimand=“ATE”)

ATE weighting for categorical treatment

I ps.out= mnps(treat ∼ Xl + · · · + Xn, data=mydata,n.trees=5000, interaction.depth=2, estimand=“ATE”)

Balance table

I bal.table(ps.out)

Page 9: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

twang : Estimating treatment effects

Extract weights

I mydata$w = get.weights(ps.out)

Treat as survey weights, using survey package

I design.ps = svydesign(ids=˜1, weights=˜w, data=mydata)

I svyglm(Y ∼ treat, design = design.ps)

Page 10: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

twang balance diagnostics

Page 11: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

Matching in STATA: psmatch2

I User-written command -psmatch2- offers many matchingoptions (nearest neighbor w caliper, Mahalanobis, kernel,spline, local linear regression . . . ) (Leuven & Sianesi)

I Includes built-in procedures for estimating both ATE and ATT

I Matching default is “with replacement:” without replacementonly available for 1:1

Page 12: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

psmatch2 syntax

Default = 1:1 nearest neighbor matching with replacement

I psmatch2 treat X1 . . .Xn, logit

1:1 nearest neighbor matching without replacement

I psmatch2 treat X1 . . .Xn, logit noreplace

Kernel matching

I psmatch2 treat X1 . . .Xn, logit kernel bwidth(0.10)

Balance table, graph

I pstest X1 . . .Xn, treated(treat) both graph

Generate ATT estimate

I psmatch2 treat X1 . . .Xn, logit outcome(Y)

Page 13: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

Matching in STATA: cem

User-written command -cem- implements coarsened exactmatching using cem package in R (Blackwell, Iacus, King, Porro)

I Missing data: treats missing as a covariate level

Implement CEM (with automatic binning)

I cem X1 . . .Xn, treatment(treat)

Use weights since variable-ratio matching method

I regress Y treat X1 . . .Xn [iweight=cem weights]

Page 14: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

Matching & weighting in STATA 13: teffects

I Implements both matching (nearest neighbor w caliper,Mahalanobis) and weighting (inverse prob weighting,augmented inverse prob weighting)

I Based on -psmatch2- but fewer matching options (e.g., nokernel matching, no 1:1 matching without replacement)

I Built-in procedures for estimating both ATE and ATT, withrobust SE (Abadie & Imbens, 2006)

I Estimates PS and treatment effect in a single step: need toassess balance

I STATA 14 increases graphical balance diagnostic options

Page 15: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

teffects syntax

1:1 nearest neighbor matching with replacement, ATT

I teffects psmatch (Y) (treat X1 . . .Xn)

2:1 nearest neighbor matching with replacement, ATE

I teffects psmatch (Y) (treat X1 . . .Xn), ate nn(2)

Inverse probability weighting, ATT

I teffects ipw (Y) (treat X1 . . .Xn), atet

Augmented inverse probability weighting, ATE

I teffects aipw (Y X1 . . .Xn) (treat X1 . . .Xn)

Page 16: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

Balance diagnostics in STATA

Page 17: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

Matching in SAS: %GMATCH macro

I User-written macro %GMATCH performs nearest neighbormatching with caliper option

I Estimate PS yourself prior to running macro to creatematched dataset

I Random sorting of data is recommended

I Only does matching without replacement

Page 18: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

%GMATCH syntax

1:1 nearest neighbor matching

I %gmatch(data=mydata, group=treat, id=id, mvars=pscore,out=matched.data)

2:1 nearest neighbor matching with caliper

I %gmatch(data=mydata, group=treat, id=id, mvars=pscore,dmaxk=0.10, ncontrls=2, out=matched.data)

Page 19: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

Matching in SAS: %VMATCH and %DIST macro

User-written macros %VMATCH and %DIST perform optimalmatching with caliper option

1:1 optimal matching

I %dist(data=mydata, group=treat, mvars=pscore,vmatch=Y, a=1, b=1);

Variable ratio optimal matching (1-3 controls)

I %dist(data=mydata, group=treat, mvars=pscore, vmatch=Y,a=1, b=3);

Page 20: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

Summary

non-param Weighting w replace w/o replace global ATE & ATT 3+ groups

MatchIt x x x xtwang x x x x

psmatch2 x 1:1 only xteffects x x x

%GMATCH x%VMATCH x

Page 21: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

Recommended resources

R

I MatchIt documentation

I twang documentation and vignettes

STATA

I Garrido et al. (2014) Methods for constructing and assessingpropensity scores, Health Services Research

SAS

I Faries et al. (2010) Analysis of observational health care datausing SAS

Page 22: Implementing Propensity Score Methods: A Review of the … › ... › files › schuler-jsm-plain.pdf · 2015-08-13 · Matching in R: MatchIt package I MatchIt is one of the most

Thanks!

I My website: http://scholar.harvard.edu/schuler/

I Health Policy Data Science Lab website:http://www.healthpolicydatascience.org