Beta Interventions¶
This module provides time-varying intervention parameters for TBsim simulations.
Main Beta Module¶
- class tbsim.interventions.beta.BetaByYear(pars=None, *args, **kwargs)[source]¶
Bases:
Intervention
A transmission reduction intervention that modifies the tuberculosis transmission rate (beta) at specified time points during the simulation.
This intervention allows for modeling population-wide changes that affect disease transmission, such as policy changes, behavioral modifications, environmental improvements, or calibration scenarios. The intervention multiplies the current beta value by a specified factor at each target year, creating a sustained reduction in transmission rates.
IMPORTANT:¶
The modifier (x_beta) is always applied to the current/latest value of beta at the time of intervention, not the original or baseline value. This means that if multiple interventions are scheduled, each one will multiply the beta value as it exists after all previous modifications. The effect is cumulative and multiplicative.
- For example:
If beta starts at 0.01, and x_beta=0.5 is applied in 2000, beta becomes 0.005.
If another x_beta=0.8 is applied in 2010, beta becomes 0.004 (0.005 * 0.8).
This is NOT a reset to the original value; each change compounds on the last.
- x_beta¶
Multiplicative factor(s) to apply to the current beta value. - If a single value, it is applied to all years. - If a list, it must be the same length as years, and each value is applied to the corresponding year.
- applied_years¶
(Deprecated) No longer used; interventions are now removed after application.
- Type:
- Behavior:
Each (year, x_beta) pair is applied only once. After application, both are removed from their lists.
If x_beta is a list, its length must match years, or a ValueError is raised.
Changes are applied to both the main disease beta parameter and all mixing pools in the network to ensure consistency.
This is a multiplicative change, not additive. For example, x_beta=0.5 reduces transmission by 50%, while x_beta=0.8 reduces it by 20%.
Multiple interventions compound: Each new x_beta is applied to the already-modified beta value.
Examples
```python # Reduce transmission by 50% in 2000 intervention = BetaByYear(pars={‘years’: [2000], ‘x_beta’: 0.5})
# Reduce transmission by 30% in multiple years (same factor) intervention = BetaByYear(pars={‘years’: [2000, 2010, 2020], ‘x_beta’: 0.7})
# Use different factors for each year intervention = BetaByYear(pars={‘years’: [2000, 2010, 2020], ‘x_beta’: [0.7, 0.8, 0.9]})
# Increase transmission by 20% in 2015 intervention = BetaByYear(pars={‘years’: [2015], ‘x_beta’: 1.2}) ```
- __init__(pars=None, *args, **kwargs)[source]¶
Initialize the BetaByYear intervention.
- Parameters:
pars (dict, optional) – Dictionary containing intervention parameters. - ‘years’ (list of ints): Years to apply the intervention. - ‘x_beta’ (float or list): Multiplicative factor(s) for beta. If a list, must match years.
*args – Additional positional arguments passed to parent class
**kwargs – Additional keyword arguments passed to parent class
- Raises:
ValueError – If x_beta is a list and its length does not match years.
Available Classes¶
- BetaByYear
Class for implementing time-varying transmission parameters
Key Features¶
Time-varying Parameters: Dynamic intervention parameters over time
Year-based Changes: Annual updates to transmission rates
Flexible Configuration: Customizable parameter schedules
Integration: Seamless integration with TB transmission models
Historical Modeling: Support for historical intervention patterns
Usage Examples¶
Basic beta intervention:
from tbsim.interventions.beta import BetaByYear
from tbsim import TB
# Add TB module and time-varying transmission parameters
tb = TB()
beta = BetaByYear()
sim = ss.Sim(
diseases=tb,
interventions=beta
)
sim.run()
Custom beta schedule:
beta = BetaByYear(
baseline_rate=0.1,
year_changes={
2020: 0.08, # 20% reduction in 2020
2025: 0.06, # Further reduction in 2025
2030: 0.04 # Target rate by 2030
}
)
Key Methods¶
- Parameter Management
get_beta_for_year(): Get transmission rate for specific year
update_parameters(): Update intervention parameters
step(): Execute parameter updates each time step
- Configuration
set_baseline_rate(): Set initial transmission rate
add_year_change(): Add year-specific parameter changes
get_current_rate(): Get current transmission rate
Time-varying Parameters¶
Beta interventions allow modeling of: - Historical Changes: Past intervention implementations - Future Plans: Planned intervention rollouts - Seasonal Effects: Time-based parameter variations - Policy Changes: Impact of new policies over time
This enables realistic modeling of intervention effectiveness and temporal dynamics.