Skip to content

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 ​

julia
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"))
end

Two pools ​

The population holds a susceptible pool and a protected pool . On each day infections are drawn from both pools by the hazard form, and doses then move people from to :

where is the number of infections on day , the reproduction number and the weight of the generation interval on lag . is the number of new infections before depletion, the susceptibility of the protected pool relative to the susceptible pool, the doses offered on day and the doses given. The doses given are at most the people left in .

A Depletion holds both pools, :S and :V. Its Hazard form with weights = (S = 1, V = σ) draws from  . A Flow of a count from :S to :V gives the doses, and Truncate caps it at the pool.

With efficacy , the two vaccines are as follows.

  • all-or-nothing:   with   doses moved;

  • leaky:    with all doses moved.

Here  ,  ,  , and 40 doses a day are offered from day 15. The history is 5 infections on the day before day 1, and the run covers 80 days.

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]

# 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   of the risk on every day.

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 per day moves people from back to . It is a hazard flow, 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 and are the pools after the infections of day and and the pools after waning. Here  , a mean duration of protection of 20 days.

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

julia
performance_plot("vaccination")

Learning more ​