Source code for vivarium_public_health.treatment.intervention

"""
===========================
Intervention Exposure Model
===========================

This module contains tools for modeling intervention exposures and their
effects on target measures.

"""

from vivarium_public_health.causal_factor.effect import CausalFactorEffect
from vivarium_public_health.causal_factor.exposure import CausalFactor


[docs] class Intervention(CausalFactor): """A model for an intervention defined by a dichotomous coverage value. This is a specialization of :class:`~vivarium_public_health.causal_factor.exposure.CausalFactor` restricted to ``"intervention"`` entity types. It can source data either from the artifact or from parameters supplied in the configuration. For an intervention named ``my_intervention``, the configuration could look like: .. code-block:: yaml configuration: my_intervention: exposure: 0.5 """ VALID_ENTITY_TYPES = ["intervention"] ##################### # Lifecycle methods # ##################### def __init__(self, intervention: str): """ Parameters ---------- intervention The type and name of an intervention, specified as ``"type.name"``. Type is singular. """ super().__init__(intervention)
[docs] class InterventionEffect(CausalFactorEffect): """A model for the effect of an intervention on an affected entity's target measure. This is a specialization of :class:`~vivarium_public_health.causal_factor.effect.CausalFactorEffect` for interventions. It can source relative risk and population attributable fraction data from the artifact or from scalar configuration parameters. For an intervention named ``my_intervention`` that affects ``affected_cause.incidence_rate``, the configuration would look like: .. code-block:: yaml configuration: intervention_effect.my_intervention_on_cause.affected_cause.incidence_rate: data_sources: relative_risk: 0.5 """ EXPOSURE_CLASS = Intervention ############## # Properties # ############## @property def name(self) -> str: """The unique name for this intervention effect component.""" return f"intervention_effect.{self.causal_factor.name}_on_{self.target}" ##################### # Lifecycle methods # ##################### def __init__(self, intervention: str, target: str): """ Parameters ---------- intervention Type and name of intervention, supplied in the form ``"intervention.intervention_name"``. target Type, name, and target measure of entity to be affected by the intervention, supplied in the form ``"entity_type.entity_name.measure"`` where ``entity_type`` should be singular (e.g. ``cause`` instead of ``causes``). """ super().__init__(intervention, target)