Creates a synthetic agent population with multiple age classification variables derived from a single-year age variable.
Usage
add_ages_to_agents(
agents_dt,
age_sex_area_dt = NULL,
contingency_dt = NULL,
ages_chr = c("AgeGroup3", "Age"),
age_groups_int = 3:11,
include_int = integer(),
prefix_1L_chr = "AgeGroup",
sex_1L_chr = "SEXP",
strategy_1L_chr = c("borrow", "error", "overall"),
target_1L_chr = "Urbanicity",
group_by_chr = c("SA2")
)Arguments
- agents_dt
Optional
data.tableof synthetic agents.- age_sex_area_dt
Optional contingency table used to generate agents when
agents_dtisNULL.- contingency_dt
Optional contingency table used to add a target attribute when generating agents.
- ages_chr
Character vector containing:
Name of the source age-group variable.
Name of the single-year age variable to create.
Defaults to
c("AgeGroup3", "Age").- age_groups_int
Integer vector specifying additional age-group classification systems to create. Defaults to
3:11.- include_int
Optional vector of ages to retain after generating single-year ages.
- prefix_1L_chr
Prefix used when naming generated age-group variables. Defaults to
"AgeGroup".- sex_1L_chr
Name of the sex variable. Defaults to
"SEXP".- strategy_1L_chr
Strategy used by
ReplicaAdderwhen handling missing population groups. One of:"borrow","error", or"overall".- target_1L_chr
Target attribute assigned via
ReplicaAdder. Defaults to"Urbanicity".- group_by_chr
Variables used when assigning target attributes. Defaults to
"SA2".
Details
If agents_dt is not supplied, a synthetic population is generated
from age_sex_area_dt. Optionally, additional attributes can be
assigned using a contingency table via ReplicaAdder.
The function generates a single-year age variable and then creates
additional age-group classifications using add_recoded_age().
Examples
if (FALSE) { # \dontrun{
agents_dt <- add_ages_to_agents(
agents_dt = agents_dt,
ages_chr = c("AgeGroup11", "Age")
)
} # }
