Skip to content

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 ​

julia
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 is the number of new infections before depletion, the susceptible pool and the protected pool. is the protected pool's relative susceptibility, the doses on day and the doses moved. The doses moved are capped by what remains of . A Depletion holds both pools, :S and :V. Its Hazard form, Hazard(; weights = (S = 1, V = σ)), draws from  , and a count Flow after it moves the doses from :S to :V.

Let be the efficacy. An all-or-nothing vaccine fully protects a share of the vaccinated. This gives  , with   doses moved. A leaky vaccine reduces every vaccinated person's risk by . This gives   , with all doses moved. Here is 0.7, is 2000, is 1.8 and 40 doses a day start on day 15.

julia
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 is a hazard flow, 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 and are the pools after the day's infections and and the pools after waning. Here is 1/20, so protection lasts 20 days on average.

julia
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.

julia
performance_plot("vaccination")

Learning more ​