set.seed(42)
d <- titanic |>
dplyr::mutate(
Group = sample(
c("a", "b", NA),
dplyr::n(),
replace = TRUE
)
)
mod <- glm(as.factor(Survived) ~ ., data = d, family = binomial())
# step(mod) should produce an error
mod2 <- step_with_na(mod, full_data = d)
mod2
# \donttest{
## WITH SURVEY ---------------------------------------
library(survey)
ds <- d |>
dplyr::mutate(Survived = as.factor(Survived)) |>
srvyr::as_survey()
mods <- survey::svyglm(
Survived ~ Class + Group + Sex,
design = ds,
family = quasibinomial()
)
mod2s <- step_with_na(mods, design = ds)
mod2s
# }
Run the code above in your browser using DataLab