# NOT RUN {
#This loads the classic Lalonde (1986) dataset,
#as well as two matched datasets:
#one from 1:1 propensity score matching,
#and one from cardinality matching, where
#the standardized covariate mean differences are all below 0.1.
data("lalondeMatches")
#obtain the covariates for these datasets
X.lalonde = subset(lalonde, select = -c(treat))
X.matched.ps = subset(lalonde.matched.ps, select = -c(treat,subclass))
X.matched.card = subset(lalonde.matched.card, select = -c(treat,subclass))
#the treatment indicators are
indicator.lalonde = lalonde$treat
indicator.matched.ps = lalonde.matched.ps$treat
indicator.matched.card = lalonde.matched.card$treat
#The following code will display a classic Love plot
#(with a dot for each standardized covariate mean difference),
#where there are differently-colored dots for each dataset.
#full lalonde dataset vs ps matched dataset
lovePlotCompare(X1 = X.lalonde, indicator1 = indicator.lalonde,
X2 = X.matched.ps, indicator2 = indicator.matched.ps,
X.full = X.lalonde, indicator.full = indicator.lalonde,
dataNames = c("unmatched", "ps matched"))
#ps vs card
lovePlotCompare(X1 = X.matched.ps, indicator1 = indicator.matched.ps,
X2 = X.matched.card, indicator2 = indicator.matched.card,
X.full = X.lalonde, indicator.full = indicator.lalonde,
dataNames = c("ps matched", "card matched"))
# }
Run the code above in your browser using DataLab