Replaces or adds the addition terms of a model formula, the terms
after | on the left-hand side, such as trials(), weights(),
se() or cens(). This is brms's update_adterms(), and for a
plain formula its output is identical to brms's on the same input.
Usage
update_adterms(formula, adform, action = c("update", "replace"))Arguments
- formula
A two-sided formula, or a formula made by
bf(). For abf()formula the response formula is updated and every other part (distributional formulas, constants,nl, the family) stays.- adform
A one-sided formula of addition terms, such as
~ trials(10)or~ weights(w) + se(sei).- action
"update"(default) or"replace".
Value
An object of the class of formula: a formula with the same
attributes and environment, or the updated bf() formula.
Details
With action = "update" an addition term of adform replaces the
term of the same name in formula, and the other terms of formula
stay. With action = "replace" the addition terms of formula are
all removed first, so only those of adform remain. A term name
spelled with brms's legacy resp_ prefix counts as the name without
it.
Examples
update_adterms(y | trials(size) ~ x, ~ trials(10))
#> y | trials(10) ~ x
#> <environment: 0x563b31a2c8f0>
update_adterms(y | trials(size) ~ x, ~ weights(w))
#> y | trials(size) + weights(w) ~ x
#> <environment: 0x563b31a2c8f0>
update_adterms(y | trials(size) ~ x, ~ weights(w), action = "replace")
#> y | weights(w) ~ x
#> <environment: 0x563b31a2c8f0>
update_adterms(bf(y ~ x, sigma ~ x), ~ weights(w))
#> y | weights(w) ~ x
#> sigma ~ x