data("lalonde", package = "cobalt")
# Model comparison for any relationship between `treat`
# and `re78` (not the same as testing for the ATE)
fit1 <- glm_weightit(
re78 ~ treat * (age + educ + race + married + nodegree +
re74 + re75), data = lalonde
)
fit2 <- glm_weightit(
re78 ~ age + educ + race + married + nodegree +
re74 + re75, data = lalonde
)
anova(fit1, fit2)
# Using the usual maximum likelihood variance matrix
anova(fit1, fit2, vcov = "const")
# Using a bootstrapped variance matrix
anova(fit1, fit2, vcov = "BS", R = 100)
# Model comparison between spline model and linear
# model; note they are nested but not symbolically
# nested
fit_s <- glm_weightit(re78 ~ splines::ns(age, df =4),
data = lalonde )
fit_l <- glm_weightit( re78 ~ age, data = lalonde )
anova(fit_s, fit_l)
Run the code above in your browser using DataLab