demographics
Define pregnancy, deaths, migration, etc.
Classes
| Name | Description |
|---|---|
| Births | Create births based on rates, rather than based on pregnancy. |
| Deaths | Configure disease-independent “background” deaths. |
| Demographics | A demographic module typically handles births/deaths/migration and takes |
| Pregnancy | Create births via pregnancies for each agent. |
Births
demographics.Births(
pars=None,
birth_rate=_,
rel_birth=_,
rate_units=_,
metadata=None,
**kwargs,
)Create births based on rates, rather than based on pregnancy.
Births are generated using population-level birth rates that can vary by year. The number of births per timestep is determined by applying the birth rate to the current population size.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| birth_rate | float / rate / dataframe |
value for birth rate, or birth rate data | _ |
| rel_birth | float | constant used to scale all birth rates | _ |
| rate_units | float | units for birth rates (default assumes per 1000) | _ |
| metadata | dict | dict with data column mappings for birth rate data (if birth_rate is a dataframe) | None |
Methods
| Name | Description |
|---|---|
| add_births | Add n_new births to each state in the sim |
| get_births | Extract the right birth rates to use and translate it into a number of people to add. |
| init_pre | Initialize with sim information |
| standardize_birth_data | Standardize/validate birth rates - handled in an external file due to shared functionality |
| update_results | Calculate new births and crude birth rate |
add_births
demographics.Births.add_births()Add n_new births to each state in the sim
get_births
demographics.Births.get_births()Extract the right birth rates to use and translate it into a number of people to add.
init_pre
demographics.Births.init_pre(sim)Initialize with sim information
standardize_birth_data
demographics.Births.standardize_birth_data()Standardize/validate birth rates - handled in an external file due to shared functionality
update_results
demographics.Births.update_results()Calculate new births and crude birth rate
Deaths
demographics.Deaths(
pars=None,
rel_death=_,
death_rate=_,
rate_units=_,
metadata=None,
**kwargs,
)Configure disease-independent “background” deaths.
The probability of death for each agent on each timestep is determined by the death_rate parameter and the time step. The default value of this parameter is 0.01, indicating that all agents will face a 1% chance of death per year.
However, this function can be made more realistic by using a dataframe for the death_rate parameter, to allow it to vary by year, sex, and age. The separate ‘metadata’ argument can be used to configure the details of the input datafile.
Alternatively, it is possible to override the death_rate parameter with a bernoulli distribution containing a constant value of function of your own design.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| pars | dict with arguments including: rel_death: constant used to scale all death rates death_rate: float, dict, or pandas dataframe/series containing mortality data rate_units: units for death rates (see in-line comment on par dict below) | None |
|
| metadata | data about the data contained within the data input. “data_cols” is is a dictionary mapping standard keys, like “year” to the corresponding column name in data. Similar for “sex_keys”. | None |
Methods
| Name | Description |
|---|---|
| make_p_death | Take in the module, sim, and uids, and return the probability of death for each UID on this timestep |
| standardize_death_data | Standardize/validate death rates - handled in an external file due to shared functionality |
| step | Select people to die |
make_p_death
demographics.Deaths.make_p_death()Take in the module, sim, and uids, and return the probability of death for each UID on this timestep
standardize_death_data
demographics.Deaths.standardize_death_data()Standardize/validate death rates - handled in an external file due to shared functionality
step
demographics.Deaths.step()Select people to die
Demographics
demographics.Demographics(name=None, label=None, **kwargs)A demographic module typically handles births/deaths/migration and takes place at the start of the timestep, before networks are updated and before any disease modules are executed.
Pregnancy
demographics.Pregnancy(
pars=None,
dur_pregnancy=_,
dur_postpartum=_,
fertility_rate=_,
rel_fertility=_,
p_maternal_death=_,
p_neonatal_death=_,
sex_ratio=_,
min_age=_,
max_age=_,
rate_units=_,
burnin=_,
slot_scale=_,
min_slots=_,
metadata=None,
**kwargs,
)Create births via pregnancies for each agent.
This module models conception, pregnancy, and birth at the individual level using age-specific fertility rates. Supports prenatal and postnatal transmission networks, maternal and neonatal mortality, and burn-in of existing pregnancies at simulation start.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| dur_pregnancy | float / dur | duration of pregnancy (default 9 months) | _ |
| dur_postpartum | float / dur | duration of postpartum period for postnatal transmission (default 6 months) | _ |
| fertility_rate | float / dataframe |
value or dataframe with age-specific fertility rates | _ |
| rel_fertility | float | constant used to scale all fertility rates | _ |
| p_maternal_death | float | probability of maternal death during pregnancy (default 0.0) | _ |
| p_neonatal_death | float | probability of neonatal death (default 0.0) | _ |
| sex_ratio | float | probability of female births (default 0.5) | _ |
| min_age | float | minimum age for pregnancy (default 15) | _ |
| max_age | float | maximum age for pregnancy (default 50) | _ |
| rate_units | float | units for fertility rates (default assumes per 1000) | _ |
| burnin | bool | whether to seed pregnancies from before simulation start (default true) | _ |
| metadata | dict | data column mappings for fertility rate data if a dataframe is supplied | None |
Methods
| Name | Description |
|---|---|
| do_step | Perform all updates |
| init_results | Results could include a range of birth outcomes e.g. LGA, stillbirths, etc. |
| make_embryos | Add properties for the just-conceived |
| make_p_fertility | Take in the module, sim, and uids, and return the conception probability for each UID on this timestep |
| make_pregnancies | Select people to make pregnant using incidence data |
| set_prognoses | Make pregnancies |
| standardize_fertility_data | Standardize/validate fertility rates |
| update_states | Update states |
do_step
demographics.Pregnancy.do_step()Perform all updates
init_results
demographics.Pregnancy.init_results()Results could include a range of birth outcomes e.g. LGA, stillbirths, etc. Still unclear whether this logic should live in the pregnancy module, the individual disease modules, the connectors, or the sim.
make_embryos
demographics.Pregnancy.make_embryos(conceive_uids)Add properties for the just-conceived
make_p_fertility
demographics.Pregnancy.make_p_fertility(filter_uids=None)Take in the module, sim, and uids, and return the conception probability for each UID on this timestep
make_pregnancies
demographics.Pregnancy.make_pregnancies()Select people to make pregnant using incidence data
set_prognoses
demographics.Pregnancy.set_prognoses(uids)Make pregnancies Add miscarriage/termination logic here Also reconciliation with birth rates Q, is this also a good place to check for other conditions and set prognoses for the fetus?
standardize_fertility_data
demographics.Pregnancy.standardize_fertility_data()Standardize/validate fertility rates
update_states
demographics.Pregnancy.update_states()Update states