All-or-nothing, leaky and waning vaccination
Introduction
This tutorial is for a user who wants to model vaccination in a renewal process with susceptible depletion. Vaccine doses move people from the susceptible pool to a protected pool, in three models:
an all-or-nothing vaccine, which fully protects a share of the vaccinated;
a leaky vaccine, which lowers the risk of every vaccinated person;
a leaky vaccine whose protection wanes.
It assumes you have read A renewal process with susceptible depletion and a reporting delay.
Packages used
using ComposableRecurrences
using ComposableRecurrences: Depletion, Flow, Hazard, Truncate
using CairoMakie, AlgebraOfGraphics, DataFramesMeta
CairoMakie.activate!(type = "png", px_per_unit = 2)
# Lines of the named series against day, one colour a series.
function plot_infections(series::Pair...)
table = stack(
DataFrame("day" => eachindex(last(first(series))), series...),
Not(:day); variable_name = :model
)
layers = data(table) * mapping(:day, :value, color = :model => "") *
visual(Lines, linewidth = 2)
return draw(layers; axis = (xlabel = "Day", ylabel = "Infections"))
endTwo pools
The population
where
A Depletion holds both pools, :S and :V. Its Hazard form with weights = (S = 1, V = σ) draws from Flow of a count from :S to :V gives the doses, and Truncate caps it at the pool.
With efficacy
all-or-nothing:
with doses moved;leaky:
with alldoses moved.
Here
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]
# A depletion of a population `N` with a protected pool of relative
# susceptibility `σ`, the `doses` of each day and any further `flows`.
function vaccination(N, σ, doses, flows...)
return Depletion(
N, Hazard(; weights = (S = 1, V = σ)),
Flow(:S => :V, TimeVarying(doses); form = Truncate()), flows...;
pools = (:S, :V)
)
end
# Infections of the renewal process with generation interval `gi` under
# `depletion`.
function infections(gi, R, depletion; history = [5.0])
return Recurrence(gi; modifiers = (depletion,))(R; history)
end
none = infections(gi, R, Depletion(N))
all_or_nothing = infections(gi, R, vaccination(N, 0.0, η .* doses))
leaky = infections(gi, R, vaccination(N, 1 - η, doses))
plot_infections(
"None" => none, "All-or-nothing" => all_or_nothing, "Leaky" => leaky
)Without a vaccine infections peak at 84 on day 24 and total 1469 over the 80 days. The all-or-nothing vaccine gives a peak of 65 on day 22 and a total of 1032, and the leaky vaccine a peak of 66 and a total of 1058. At equal efficacy the leaky vaccine prevents fewer infections, as every vaccinated person keeps a share
A delay from dose to protection is a Convolution of the doses, passed as the demand of the flow.
Checked against simulation
The final sizes of both vaccine models agree with stochastic SIR simulations from EpiBranch.jl, which the vaccination use case of the tests checks.
Waning protection
Waning at rate Flow(:V => :S, ω). Waning acts after the infections of the day and before its doses.
Order of flows in a Depletion
The flows of a Depletion act after the infections of the day, and hazard flows act before count flows. So a hazard flow for waning acts before the count flow of the doses.
The pools after waning are
where
ω = 1 / 20
waning = infections(
gi, R, vaccination(N, 1 - η, doses, Flow(:V => :S, ω))
)
plot_infections("Leaky" => leaky, "Leaky, waning" => waning)With waning the total is 1145 infections against 1058 without, 8% more, and the peak is 67 against 66.
Performance
The timed model is leaky vaccination with waning protection over 200 days, with a generation interval of 20 lags. The figure gives its minimum time and that of a preallocated hand-written loop of the same model.
performance_plot("vaccination")Learning more
Depletion forms gives the equation of each draw from a pool.
Depletion in practice builds births, budgets and bed capacity from the same parts.