Risk Observers

This module contains tools for observing risk exposure during the simulation.

class vivarium_public_health.metrics.risk.CategoricalRiskObserver(risk)[source]

An observer for a categorical risk factor.

Observes category person time for a risk factor.

By default, this observer computes aggregate categorical person time over the full course of the simulation. It can be configured to add or remove stratification groups to the default groups defined by a ResultsStratifier.

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

configuration:
    stratification:
        risk_name:
            exclude:
                - "sex"
            include:
                - "sample_stratification"
Parameters:

risk (str) –

CONFIGURATION_DEFAULTS: Dict[str, Any] = {'stratification': {'risk': {'exclude': [], 'include': []}}}

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

property configuration_defaults: Dict[str, Any]

A dictionary containing the defaults for any configurations managed by this component.

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

aggregate_risk_category_person_time(x)[source]
Parameters:

x (DataFrame) –

Return type:

float