View source: R/bage_mod-functions.R
set_var_sexgender | R Documentation |
Specify which variable (if any) represents sex or gender.
Functions mod_pois()
, mod_binom()
,
and mod_norm()
try to infer the sex/gender variable
from variable names, but do not always get it right.
set_var_sexgender(mod, name)
mod |
An object of class |
name |
The name of the sex or gender variable. |
In an R formula
, a 'variable' is different
from a 'term'. For instance,
~ gender + region + gender:region
contains variables gender
and region
,
and terms gender
, region
, and gender:region
.
If set_var_sexgender()
is applied to
a fitted model, it 'unfits'
the model, deleting existing estimates.
A "bage_mod"
object
set_var_age()
Set age variable
set_var_time()
Set time variable
is_fitted()
Test whether model is fitted
internally, bage uses poputils::find_var_sexgender()
to locate sex or gender variables
internally, bage uses poputils::find_label_female()
to locate female categories within a sex or gender variable
internally, bage uses poputils::find_label_male()
to locate male categories within a sex or gender variable
## rename 'sex' variable to something unexpected
injuries2 <- nzl_injuries
injuries2$biological_sex <- injuries2$sex
## mod_pois does not recognize sex variable
mod <- mod_pois(injuries ~ age * biological_sex + year,
data = injuries2,
exposure = popn)
mod
## so we set the sex variable explicitly
mod |>
set_var_sexgender(name = "biological_sex")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.