12
Vaccination and time-dependent interventions
An intervention changes either the population state or the model parameters. We represent pre-outbreak vaccination by reducing the initial susceptible population, and a timed contact intervention by changing the transmission parameter during the epidemic.
Biological scenario
A population of 1,000 begins with 10 infectious people. We compare:
- no intervention;
- 40% vaccination coverage with 80% efficacy before the outbreak;
- the same vaccination plus a day-30 intervention reducing \(\beta\) from 0.30 to 0.12 per day.
The aim is to compare infectious peaks, peak times and infections occurring after the simulation begins.
Two interventions, two mathematical mechanisms
Vaccination before the outbreak
Changes the initial conditions by moving effectively immunised people out of \(S(0)\).
\[V_{\mathrm{immune}}=c\varepsilon S_{\mathrm{eligible}},\]
where \(c\) is coverage and \(\varepsilon\) is vaccine efficacy.
Timed contact intervention
Changes transmission during the simulation through a time-dependent parameter \(\beta(t)\).
\[\beta(t)=\begin{cases}\beta_1,&t<T_L,\\\beta_2,&t\geq T_L.\end{cases}\]
Vaccination changes the initial state
There are \(N-I(0)\) initially non-infectious people eligible to be susceptible in this simplified scenario:
\[S_{\mathrm{eligible}}=N-I(0).\]
With coverage \(c=0.4\) and efficacy \(\varepsilon=0.8\), the effectively immunised fraction is \(c\varepsilon=0.32\), not 0.40.
\[V_{\mathrm{immune}}=0.4\times0.8\times990=316.8.\]
\[S(0)=990-316.8=673.2.\]
The standard SIR symbol \(R\) is better interpreted here as removed or immune, because it contains vaccine-induced immunity as well as people who later recover from infection.
Program a time-dependent transmission parameter
\(\beta(t)=0.30\)
\(\beta(t)=0.12\)
def beta_at_time(
t,
beta_before,
beta_after,
intervention_day
):
if t < intervention_day:
return beta_before
else:
return beta_after
- t is the time supplied by the ODE solver.
- if selects the pre-intervention value before the switching day.
- else selects the post-intervention value from that day onwards.
- The function returns one value of \(\beta(t)\) for each solver evaluation.
Use \(\beta(t)\) inside the SIR equations
beta = beta_at_time(
t,
beta_before,
beta_after,
intervention_day
)
infection_flow = beta * S * I / N
The equations retain the same structure, but the infection flow now uses the transmission value appropriate to the current time.
Scenarios compared
No vaccine immunity and \(\beta=0.30\) throughout.
32% of initially eligible susceptible people effectively immunised; \(\beta=0.30\) throughout.
Same vaccine immunity; \(\beta\) changes to 0.12 on day 30.
Run the intervention comparison
Output
Run the code to see the result.
Understand the new code
| Code | Technical meaning | Modelling use |
|---|---|---|
0 <= coverage <= 1 | A chained comparison requiring a proportion between 0 and 1. | Prevents impossible vaccination coverage. |
np.where(condition, a, b) | Creates an array choosing a where a condition is true and b otherwise. | Creates the displayed piecewise transmission schedule. |
np.full_like(time, 0.30) | Creates an array matching the shape of time and fills it with 0.30. | Displays constant transmission. |
max_step=0.5 | Prevents the solver from taking an internal step longer than half a day. | Encourages resolution around the abrupt day-30 parameter change. |
outbreak_infections | Uses \(I(0)+S(0)-S(T)\). | Excludes people immune from vaccination who never enter the outbreak. |
Biological interpretation
Vaccination lowers the number initially susceptible to infection. The timed intervention reduces the infection flow from day 30 onward. Both mechanisms can lower infectious burden, but they act through different parts of the model.
The effect of a timed intervention depends strongly on when it begins. If it begins after the natural infectious peak, it cannot reduce the earlier peak retrospectively.
Assumptions and limitations
| Assumption | Consequence |
|---|---|
| Vaccine protection is immediate. | No delay between vaccination and immunity is represented. |
| Effective protection is all-or-nothing. | Successfully protected people are placed directly in the immune compartment. |
| Protection does not wane. | Vaccinated immune people remain immune throughout the simulation. |
| \(\beta\) changes instantly on day 30. | Behavioural change is represented as an abrupt step rather than a gradual transition. |
| Parameters are otherwise constant. | Changing adherence and other time-varying factors are omitted. |
This is a scenario analysis under model assumptions. It does not establish that an observed intervention caused a particular real-world outcome.
Try changing intervention timing
In the combined scenario, change intervention_day=30 to 15 and then to 60. Also change the plotted schedule condition and vertical line to match.
- Compare peak sizes and peak times.
- Compare outbreak infections.
- Determine whether day 60 occurs before or after the uncontrolled peak.
- Explain why timing changes the outcome even when \(\beta_2\) is unchanged.