if (FALSE) { # rlang::is_installed("MatchIt")
data("lalonde", package = "MatchIt")
# Fit the model
fit <- glm(I(re78 > 0) ~ treat + age + race +
married + re74,
data = lalonde, family = binomial)
# Simulate coefficients
set.seed(123)
s <- sim(fit, n = 100)
# ADRF for `age`
est <- sim_adrf(s, var = "age",
at = seq(15, 55, length.out = 6),
verbose = FALSE)
est
plot(est)
# AMEF for `age`
est <- sim_adrf(s, var = "age", contrast = "amef",
at = seq(15, 55, length.out = 6),
verbose = FALSE)
est
summary(est)
plot(est)
# ADRF for `age` within levels of `married`
est <- sim_adrf(s, var = "age",
at = seq(15, 55, length.out = 6),
by = ~married,
verbose = FALSE)
est
plot(est)
## Difference between ADRFs
est_diff <- est[7:12] - est[1:6]
plot(est_diff) + ggplot2::labs(y = "Diff")
}
Run the code above in your browser using DataLab