View source: R/bage_mod-functions.R
set_var_age | R Documentation |
Specify which variable (if any) represents age.
Functions mod_pois()
, mod_binom()
,
and mod_norm()
try to infer the age variable
from variable names, but do not always get it right.
set_var_age(mod, name)
mod |
An object of class |
name |
The name of the age variable. |
In an R formula
, a 'variable' is different
from a 'term'. For instance,
~ age + region + age:region
contains variables age
and region
,
and terms age
, region
, and age:region
.
By default, bage gives a term involving age a
(RW()
) prior. Changing the age variable
via set_var_age()
can change priors:
see below for an example.
If set_var_age()
is applied to
a fitted model, it 'unfits'
the model, deleting existing estimates.
A bage_mod
object
set_var_sexgender()
Set sex or gender variable
set_var_time()
Set time variable
is_fitted()
Test whether a model is fitted
internally, bage uses poputils::find_var_age()
to locate age variables
## rename 'age' variable to something unusual
injuries2 <- nzl_injuries
injuries2$age_last_birthday <- injuries2$age
## mod_pois does not recognize age variable
mod <- mod_pois(injuries ~ age_last_birthday * ethnicity + year,
data = injuries2,
exposure = popn)
mod
## so we set the age variable explicitly
## (which, as a side effect, changes the prior on
## the age main effect)
mod |>
set_var_age(name = "age_last_birthday")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.