Vaccination
Introduction
Vaccine doses move susceptibles into a protected pool. Here a renewal process with susceptible depletion gets all-or-nothing, leaky and waning protection.
Packages used
using ComposableRecurrences
using ComposableRecurrences: Depletion, Flow, Hazard, Truncate
using CairoMakie, AlgebraOfGraphics, DataFramesMeta
CairoMakie.activate!(type = "png", px_per_unit = 2)Two pools
With the hazard form, each day draws infections from both pools and then moves the doses:
where Depletion holds both pools, :S and :V. Its Hazard form, Hazard(; weights = (S = 1, V = σ)), draws from Flow after it moves the doses from :S to :V.
Let
gi = [0.1, 0.3, 0.3, 0.2, 0.1]
T = 80
N = 2_000.0
R = fill(1.8, T)
η = 0.7
doses = [t < 15 ? 0.0 : 40.0 for t in 1:T]
vaccinated(σ, d, flows...) = Depletion(
N, Hazard(; weights = (S = 1, V = σ)),
Flow(:S => :V, TimeVarying(d); form = Truncate()), flows...; pools = (:S, :V)
)
run_with(d) = Recurrence(gi; modifiers = (d,))(R; history = [5.0])
plot_infections(runs) = @chain runs begin
map(((name, d),) -> DataFrame(day = 1:T, vaccine = name, count = run_with(d)), _)
reduce(vcat, _)
data(_) * mapping(:day, :count, color = :vaccine => "") * visual(Lines, linewidth = 2)
draw(_; axis = (xlabel = "Day", ylabel = "Infections"))
end
leaky = vaccinated(1 - η, doses)
vaccines = [
"None" => Depletion(N),
"All-or-nothing" => vaccinated(0.0, η .* doses),
"Leaky" => leaky,
]
plot_infections(vaccines)Both vaccines lower the peak and bring it slightly earlier, because the susceptible pool shrinks faster. At the same efficacy the all-or-nothing vaccine prevents slightly more infections. The final sizes of both vaccines match seeded stochastic SIR simulations from EpiBranch.jl, as the vaccination use case checks. The leaky vaccine leaves every vaccinated person some risk, which adds up over time. A delay from dose to protection is a Convolution of the doses, passed as the flow's demand.
Waning protection
Protection that wanes moves people from the protected pool back to the susceptible pool. Waning at rate Flow(:V => :S, ω). The pool's flows act after each day's infections, and hazard flows act before count flows, so waning acts before the day's doses:
where
waning = vaccinated(1 - η, doses, Flow(:V => :S, 1 / 20))
plot_infections(["Leaky" => leaky, "Leaky, waning" => waning])Waning raises the peak a little and adds about 8% more infections over the outbreak, because people protected early return to the susceptible pool while the epidemic runs.
Performance
Each bar times leaky vaccination with waning protection over 200 days with a 20-day generation interval, against a preallocated hand-written loop.
performance_plot("vaccination")Learning more
Infectious disease models: the operator for each model part, vaccines included.
Public API: every public name with its docstring.