The DiseasyPopulation module is responsible for handling the population included in the model.
See vignette("diseasy-population").
Value
A new instance of the DiseasyPopulation R6 class.
Super class
DiseasyBaseModule -> DiseasyPopulation
Active bindings
groups(
data.frame())
The demographic groups that have been configured in the module.model_population(
tibble)
The population groups and their sizes configured in the module.regional_stratification(
character())
The level of spatial stratification of the population. Read only.age_cuts_lower(
integer())
vector of ages defining the lower bound for each age group. IfNULL, age groups of contact_basis is used. Read only.activity(
diseasy::DiseasyActivity)
The local copy of an DiseasyActivity module. Read-only.regions(
diseasy::DiseasyRegions)
The local copy of an DiseasyRegions module. Read-only.
Methods
Inherited methods
DiseasyPopulation$new()
Creates a new instance of the DiseasyPopulation R6 class.
Usage
DiseasyPopulation$new(
age_cuts_lower = 0L,
regional_stratification = NULL,
activity = NULL,
regions = NULL,
...
)Arguments
age_cuts_lower(
integer())
vector of ages defining the lower bound for each age group. IfNULL, age groups of contact_basis is used.regional_stratification(
character())
The level of spatial stratification of the population.activity, regions(
booleanorR6::R6Class instance)
If a boolean is given, it dictates whether to load a new instance module of this class.
If an instance of the module is provided instead, a copy of this instance is added to theDiseasyModelinstance. This copy is a "clone" of the instance at the time it is added and any subsequent changes to the instance will not reflect in the copy that is added toDiseasyModel....Parameters sent to
DiseasyBaseModuleR6 constructor
DiseasyPopulation$stratify_age()
Sets the age stratification of the model population.
Arguments
age_cuts_lower(
integer())
vector of ages defining the lower bound for each age group. IfNULL, age groups of contact_basis is used.
DiseasyPopulation$stratify_regions()
Sets the spatial stratification of the model population.
Arguments
regional_stratification(
character())
The level of spatial stratification of the population.
DiseasyPopulation$validate_configuration()
Validate the stratifications are supported by demography data. Throw error if misconfigured.
Usage
DiseasyPopulation$validate_configuration(
age_cuts_lower = self %.% age_cuts_lower,
regional_stratification = self %.% regional_stratification
)Arguments
age_cuts_lower(
integer())
vector of ages defining the lower bound for each age group. IfNULL, age groups of contact_basis is used.regional_stratification(
character())
The level of spatial stratification of the population.
DiseasyPopulation$mean_contact_rates()
Compute the mean contact rate matrices. "M" domain. See vignette("diseasy-population") for details.
Usage
DiseasyPopulation$mean_contact_rates(weights = rep(1, 4))DiseasyPopulation$map_population()
The function computes the proportion of population in the new and old age groups.
Usage
DiseasyPopulation$map_population(
age_cuts_lower = self %.% age_cuts_lower,
regions = purrr::pluck(self %.% groups, "region", unique),
age_groups_reference = NULL,
demography = self %.% regions %.% demography
)Arguments
age_cuts_lower(
integer())
vector of ages defining the lower bound for each age group. IfNULL, age groups of contact_basis is used.regions(
character())
The regions the population should be mapped to (e.g. NUTS 1 regions).age_groups_reference(
character())
Age labels (created bydiseasystore::age_labels()of reference data.demography(
data.frame)
"Adata.framewith the columns\cr", " *age(integer()) 1-year age groups orage_group(integer()) dynamic age groups\cr", " *population(numeric()) size of population in age group\cr"
Examples
# Create population module
population <- DiseasyPopulation$new()
# By default a single, non-stratified population is used in the models.
population
#> # DiseasyPopulation ##########################################
#> Stratifications:
#> Age: No age stratification has been configured
#> Space: No spatial stratification has been configured
# Stratification can be added via methods
# Stratifying by age
population$stratify_age(age_cuts_lower = c(0, 60)) # 2 age groups
# NB: Age cuts must be available in demography and disease data.
population
#> # DiseasyPopulation ##########################################
#> Stratifications:
#> Age: Stratified by age: 00-59, 60+
#> Space: No spatial stratification has been configured
rm(population)
