data("lalonde", package = "cobalt")
# Logistic regression ATT weights
w.out <- weightit(treat ~ age + educ + married + re74,
data = lalonde, method = "glm",
estimand = "ATT")
# Linear regression outcome model that adjusts
# for estimation of weights
fit1 <- lm_weightit(re78 ~ treat, data = lalonde,
weightit = w.out)
summary(fit1)
# Linear regression outcome model that treats weights
# as fixed
fit2 <- lm_weightit(re78 ~ treat, data = lalonde,
weightit = w.out, vcov = "HC0")
summary(fit2)
if (FALSE) { # requireNamespace("fwb", quietly = TRUE)
# example code
# Linear regression outcome model that bootstraps
# estimation of weights and outcome model fitting
# using fractional weighted bootstrap with "Mammen"
# weights
set.seed(123)
fit3 <- lm_weightit(re78 ~ treat, data = lalonde,
weightit = w.out,
vcov = "FWB",
R = 50, #should use way more
fwb.args = list(wtype = "mammen"))
summary(fit3)
}
# Multinomial logistic regression outcome model
# that adjusts for estimation of weights
lalonde$re78_3 <- factor(findInterval(lalonde$re78,
c(0, 5e3, 1e4)))
fit4 <- multinom_weightit(re78_3 ~ treat,
data = lalonde,
weightit = w.out)
summary(fit4)
# Ordinal probit regression that adjusts for estimation
# of weights
fit5 <- ordinal_weightit(ordered(re78_3) ~ treat,
data = lalonde,
link = "probit",
weightit = w.out)
summary(fit5)
Run the code above in your browser using DataLab