# NOT RUN {
library("cobalt")
data("lalonde", package = "cobalt")
(W <- weightit(treat ~ age + educ + married +
nodegree + re74, data = lalonde,
method = "ps", estimand = "ATT"))
summary(W)
#Trimming the top and bottom 5 weights
trim(W, at = 5, lower = TRUE)
#Trimming at 90th percentile
(W.trim <- trim(W, at = .9))
summary(W.trim)
#Note that only the control weights were trimmed
#Trimming a numeric vector of weights
weights <- cobalt::get.w(W)
all.equal(trim(weights, at = .9, treat = lalonde$treat),
W.trim$weights)
# }
Run the code above in your browser using DataLab