Skip to content

New example: Time-varying and phased interventions #53

@smjenness

Description

@smjenness

Motivation

Every current gallery example applies interventions from the start of the simulation. No example demonstrates interventions that activate, deactivate, or change intensity at specific timesteps. This is unrealistic — real-world interventions are phased (campaigns start, policies are enacted and later relaxed, resources are deployed over time). Users building policy evaluation models need to know how to implement time-varying parameters, and it's a common question. This example would be a concise, focused tutorial on the pattern.

Suggested Design

Disease Model: SIR with Phased Vaccination Campaign

Keep the disease model simple (SIR) so the focus stays on the intervention timing mechanism. Use a closed population (no vital dynamics) for clarity.

Compartment Description
S Susceptible
I Infectious
R Recovered (natural immunity)
V Vaccinated (vaccine-immune)

Custom Modules

Module Purpose
infection.FUN Standard S → I transmission
recovery.FUN I → R at a fixed recovery rate
vaccine.FUN Time-varying vaccination: S → V at a rate that changes based on the current timestep and a user-defined intervention schedule

The key teaching point is the vaccine.FUN module, which reads an intervention schedule from the parameters and applies different rates at different times. The pattern is generalizable to any time-varying intervention.

Parameters

Parameter Description Suggested Value
inf.prob Per-act transmission probability 0.2
act.rate Acts per partnership per week 1
rec.rate Weekly recovery rate 0.05
vax.start Timestep when vaccination begins 50
vax.end Timestep when vaccination campaign ends 150
vax.rate Weekly vaccination probability during active campaign 0.02–0.05
vax.efficacy Probability vaccine confers immunity (all-or-nothing) 0.9

ERGM Parameterization

Simple network to keep focus on the intervention mechanism:

  • ~edges: Mean degree ~1.0
  • ~degree(0:3): Constrain degree distribution to avoid extreme heterogeneity
  • Dissolution ~offset(edges): Duration ~50 weeks

Intentionally simple so the example is accessible. The ERGM is not the pedagogical focus here.

Scenarios

  1. No intervention: SIR epidemic runs its course — establishes the counterfactual
  2. Early vaccination (start at step 20): Campaign begins before epidemic peak — maximum impact
  3. Late vaccination (start at step 80): Campaign begins after peak — diminished but still measurable impact
  4. Short campaign (steps 50–80): Vaccination runs for 30 weeks then stops
  5. Pulse campaigns: Two short bursts (steps 40–60 and 100–120) — demonstrates a reusable schedule pattern
  6. Reactive vaccination: Vaccination activates only when prevalence exceeds a threshold (e.g., 5%) and deactivates when it drops below 2% — demonstrates conditional/adaptive interventions

Analyses

  • Overlay epidemic curves from all scenarios to show impact of timing
  • Bar chart: cumulative infections averted by intervention timing
  • Plot vaccination coverage over time for each scenario
  • For the reactive scenario: show the feedback loop between prevalence and vaccination activity
  • Key pedagogical takeaway: the same intervention with the same rate has very different impact depending on when it starts

Implementation Notes

The vaccine.FUN module demonstrates a reusable pattern:

# Time-varying intervention pattern
vax.rate.at <- if (at >= vax.start && at <= vax.end) vax.rate else 0

For the reactive scenario:

# Adaptive intervention pattern
current.prev <- sum(status == "i") / sum(active == 1)
vax.rate.at <- if (current.prev > prev.threshold) vax.rate else 0

These patterns are applicable to any time-varying or state-dependent intervention.

Relationship to Existing Examples

  • Simpler disease model than SEIRwithAONVax but focuses on intervention timing rather than vaccine mechanism
  • Introduces a pattern (time-varying parameters) that no current example demonstrates
  • The reactive vaccination scenario introduces state-dependent interventions (feedback loops)
  • Complements the vaccination examples by showing that when you vaccinate matters as much as how

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions