update() re-fits an mm_lmm or mm_glmm with a modified
model specification, mirroring stats::update() and lme4's update() for
the common cases: changing the formula (. ~ . - x), toggling REML,
swapping weights/offset/family/control, or supplying new data.
Arguments
- object
A fitted
mm_lmmormm_glmm.- formula.
A formula-change applied with
stats::update.formula(); omit to keep the current formula. Random-effect terms ((x | g),(x || g)) are preserved across. ~ .edits.- ...
Arguments to override on the re-fit. For
mm_lmm:data,REML,weights,control. Formm_glmm: additionallyfamily,offset,method,nAGQ,inference.- evaluate
If
TRUE(default) re-fit and return the new model; ifFALSEreturn the unevaluated call.
Details
The re-fit reuses the fitted model frame (model.frame()) as the default
data source, so formula edits that remove terms or change estimation
options work without re-supplying data. A formula edit that introduces a
new variable absent from the original model frame requires an explicit
data = argument.
Examples
set.seed(1)
df <- data.frame(
y = rnorm(80), x = rnorm(80), z = rnorm(80),
g = factor(rep(seq_len(10), each = 8))
)
fit <- lmm(y ~ x + z + (1 | g), df, control = mm_control(verbose = -1))
# drop a fixed term
fit2 <- update(fit, . ~ . - z)
# refit by ML for a likelihood-ratio comparison
fit_ml <- update(fit, REML = FALSE)
fixef(fit2)
#> (Intercept) x
#> 0.07858531 -0.28479350