Risk Exposure Model

This module contains tools for modeling categorical and continuous risk exposure.

class vivarium_public_health.risks.base_risk.Risk(risk)[source]

A model for a risk factor defined by either a continuous or a categorical value. For example,

  1. high systolic blood pressure as a risk where the SBP is not dichotomized into hypotension and normal but is treated as the actual SBP measurement.

  2. smoking as two categories: current smoker and non-smoker.

This component can source data either from builder.data or from parameters supplied in the configuration. If data is derived from the configuration, it must be an integer or float expressing the desired exposure level or a covariate name that is intended to be used as a proxy. For example, for a risk named “risk”, the configuration could look like this:

configuration:
    risk:
        exposure: 1.0

or

configuration:
    risk:
        exposure: proxy_covariate

For polytomous risks, you can also provide an optional ‘rebinned_exposed’ block in the configuration to indicate that the risk should be rebinned into a dichotomous risk. That block should contain a list of the categories that should be rebinned into a single exposed category in the resulting dichotomous risk. For example, for a risk named “risk” with categories cat1, cat2, cat3, and cat4 that you wished to rebin into a dichotomous risk with an exposed category containing cat1 and cat2 and an unexposed category containing cat3 and cat4, the configuration could look like this:

configuration:
    risk:
       rebinned_exposed: ['cat1', 'cat2']

For alternative risk factors, you must provide a ‘category_thresholds’ block in the in configuration to dictate the thresholds that should be used to bin the continuous distributions. Note that this is mutually exclusive with providing ‘rebinned_exposed’ categories. For a risk named “risk”, the configuration could look like:

configuration:
    risk:
        category_thresholds: [7, 8, 9]
Parameters:

risk (str) –

CONFIGURATION_DEFAULTS: Dict[str, Any] = {'risk': {'category_thresholds': [], 'exposure': 'data', 'rebinned_exposed': []}}

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]

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

These default values will be stored at the component_configs layer of the simulation’s ConfigTree.

Returns:

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

Return type:

Dict[str, Any]

property columns_created: List[str]

Provides names of columns created by the component.

Returns:

Names of the columns created by this component, or an empty list if none.

Return type:

List[str]

property initialization_requirements: Dict[str, List[str]]

Provides the names of all values required by this component during simulant initialization.

Returns:

A dictionary containing the additional requirements of this component during simulant initialization. An omitted key or an empty list for a key implies no requirements for that key during initialization.

Return type:

Dict[str, 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

get_exposure_distribution()[source]
Return type:

SimulationDistribution

get_randomness_stream(builder)[source]
Parameters:

builder (Builder) –

Return type:

RandomnessStream

get_propensity_pipeline(builder)[source]
Parameters:

builder (Builder) –

Return type:

Pipeline

get_exposure_pipeline(builder)[source]
Parameters:

builder (Builder) –

Return type:

Pipeline

on_initialize_simulants(pop_data)[source]

Method that vivarium will run during simulant initialization.

This method is intended to be overridden by subclasses if there are operations they need to perform specifically during the simulant initialization phase.

Parameters:

pop_data (SimulantData) – The data associated with the simulants being initialized.

Return type:

None

get_current_exposure(index)[source]
Parameters:

index (Index) –

Return type:

Series