if (all(sapply(c("WeightIt", "MatchIt"), requireNamespace, quietly = TRUE))) {
data("lalonde", package = "cobalt")
library("MatchIt"); library("WeightIt")
m.out <- matchit(treat ~ age + educ + race, data = lalonde)
w.out <- weightit(treat ~ age + educ + race, data = lalonde,
estimand = "ATT")
bal.tab(treat ~ age + educ + race, data = lalonde,
weights = data.frame(matched = get.w(m.out),
weighted = get.w(w.out)),
method = c("matching", "weighting"),
estimand = "ATT")
}Run the code above in your browser using DataLab