Add or remove a single covariate term from an existing erglm model, returning a new fitted model object.
Arguments
- mod
An erglm model object, as returned by
erglm_model()- term
A one-sided formula naming the term to add/remove, e.g.
~ sex- quiet
If
TRUE, suppress the warning issued when the term can't be added/removed (because it's already in the model / isn't in the model, respectively)
Value
An erglm model object. If the term can't be added/removed
(see quiet), the original mod is returned unchanged.
Details
These functions are not typically called directly; they
underpin erglm_scm_forward() and erglm_scm_backward(). Named and
shaped to match the companion emaxnls package's
emax_add_term()/emax_remove_term(), which serve the same purpose
for emaxnls/emaxlogistic models – with one structural
difference: emaxnls's terms are two-sided formulas naming a
structural parameter (e.g. E0 ~ AGE), since covariates there attach
to a specific Emax parameter, whereas erglm's terms are plain
one-sided glm() formula terms (e.g. ~ sex), since erglm has no
equivalent parameter-level structure to attach covariates to. term
must be a one-sided formula naming exactly one covariate; passing
NULL, a non-formula, a two-sided formula, or a multi-term formula
(e.g. ~ weight + age) errors informatively rather than failing with
a low-level error (NULL/non-formula) or being silently
misinterpreted (two-sided formulas; multi-term formulas, which used
to add/attempt every term at once with no warning).
Examples
mod <- erglm_model(ae1 ~ aucss, erglm_data, family = binomial())
mod2 <- erglm_add_term(mod, ~ sex)
mod3 <- erglm_remove_term(mod2, ~ sex)