Risk Exposure Model

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

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

Risk factor model defined by either a continuous or a categorical exposure value.

For example:

  1. Model 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. Model 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, provide an integer or float expressing the desired exposure level or a covariate name to use as a proxy. For example, for a risk named “some_risk”, the configuration could look like this:

configuration:
    some_risk:
        exposure: 1.0

or

configuration:
    some_risk:
        exposure: proxy_covariate

For polytomous risks, optionally provide a ‘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 to rebin into a single exposed category in the resulting dichotomous risk. For example, for a risk named “some_risk” with categories cat1, cat2, cat3, and cat4 that you wish 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:
    some_risk:
       rebinned_exposed: ['cat1', 'cat2']

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

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

risk (str)

VALID_ENTITY_TYPES = ['risk_factor', 'alternative_risk_factor']
setup(builder)[source]

Set up the risk component.

Extend parent setup to register an exposure column for non-loglinear risk effects when applicable.

Parameters:

builder (Builder) – Access point for utilizing framework interfaces during setup.

Return type:

None

initialize_exposure(pop_data)[source]

Initialize an exposure column with the exposure pipeline values.

Parameters:

pop_data (SimulantData) – Metadata about the simulants being initialized.

Return type:

None

on_time_step_prepare(event)[source]

Update the exposure column to equal the exposure pipeline values if there is a NonLogLinearRiskEffect component for this risk in the simulation.

Parameters:

event (Event) – The event triggering the preparation.

Return type:

None

get_exposure(index)[source]

Get the exposure attribute and rename it to the internal exposure column name.

HACK: This is effectively caching the exposure pipeline for use by other components. Specifically, vivarium_public_health.risks.effect.NonLogLinearRiskEffect.get_relative_risk_source() needs the exposure values but calling that pipeline was very slow. By maintaining a cached copy of the exposure values in a private column, we can then request that corresponding “simple” pipeline from the population view instead which is significantly faster.

Parameters:

index (Index) – The index of the population to update.

Return type:

Series