Mortality Observer

This module contains tools for observing cause-specific and excess mortality in the simulation, including “other causes”.

class vivarium_public_health.metrics.mortality.MortalityObserver[source]

An observer for cause-specific deaths and ylls (including “other causes”).

By default, this counts cause-specific deaths and years of life lost over the full course of the simulation. It can be configured to add or remove stratification groups to the default groups defined by a :class:ResultsStratifier. The aggregate configuration key can be set to True to aggregate all deaths and ylls into a single observation and remove the stratification by cause of death to improve runtime.

In the model specification, your configuration for this component should be specified as, e.g.:

configuration:
    stratification:
        mortality:
            exclude:
                - "sex"
            include:
                - "sample_stratification"

This observer needs to access the has_excess_mortality attribute of the causes we’re observing, but this attribute gets defined in the setup of the cause models. As a result, the model specification should list this observer after causes.

CONFIGURATION_DEFAULTS: Dict[str, Any] = {'stratification': {'mortality': {'aggregate': False, 'exclude': [], 'include': []}}}

A dictionary containing the defaults for any configurations managed by this component. An empty dictionary indicates no managed configurations.

property columns_required: List[str] | None

Provides names of columns required by the component.

Returns:

Names of required columns not created by this component. An empty list means all available columns are needed. None means no additional columns are necessary.

Return type:

Optional[List[str]]

setup(builder)[source]

Defines custom actions this component needs to run during the setup lifecycle phase.

This method is intended to be overridden by subclasses to perform any necessary setup operations specific to the component. By default, it does nothing.

Parameters:

builder (Builder) – The builder object used to set up the component.

Return type:

None

count_deaths(x)[source]
Parameters:

x (DataFrame) –

Return type:

float

calculate_ylls(x)[source]
Parameters:

x (DataFrame) –

Return type:

float