Add or remove a covariate term from an exposure-response TTE model
Source:R/ertte-scm.R
ertte_term.RdAdd or remove a single covariate term from an existing ertte model, returning a new fitted model object.
Arguments
- mod
An ertte model object, as returned by
ertte_aft()orertte_coxph()- 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). Defaults toFALSE.
Value
An ertte 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 ertte_scm_forward() and ertte_scm_backward(). Named and
shaped to match the companion erglm package's
erglm_add_term()/erglm_remove_term(): term/candidates are plain
formula terms, added/removed additively – categorical covariates enter
as factor levels, continuous covariates enter linearly by default or,
for a power-function parameterisation (theta such that T ~ (x / ref)^theta on the AFT time scale, or h(t|x) ~ h0(t) * (x / ref)^theta
on the Cox hazard scale), by wrapping the covariate in ertte_power(),
e.g. ~ ertte_power(age) or candidates = "ertte_power(age)". Term
handling here works generically on formula term-labels, so
ertte_power() terms need no special-casing.
mod is refit using the matching engine constructor
(ertte_aft()/ertte_coxph()), based on its class – so these
functions (and the SCM family built on them) work for both
ertte_aft and ertte_coxph models.