data(longitudinal_example)
if (FALSE) {
# Prune fixed effects in mixed model (requires lme4)
if (requireNamespace("lme4", quietly = TRUE)) {
pruned <- modelPrune(
outcome ~ x1 + x2 + x3 + x4 + x5 + (1|subject) + (1|site),
data = longitudinal_example,
engine = "lme4",
limit = 5
)
# Random effects preserved, only fixed effects pruned
attr(pruned, "selected_vars")
}
}
Run the code above in your browser using DataLab