Epidemics.jl

This is some minimal documentation for Epidemics.jl. Note that this is a personal project, and comes with no current or future support. This documentation section is intended as a learning experience (for me) in writing Julia package documentation.

License:MIT Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public. Dev Build Status Coverage SciML Code Style

Epidemics.jl is a Julia package that aims to mirror the R package {epidemics}, and to provide a robust way to model epidemic and disease outbreak scenarios. Epidemics.jl is a work in progress since it lags the development of epidemics.

Note Epidemics.jl is a personal project where I aim to learn more about the Julia language; it comes with no guarantees of current or future support or maintenance.

Epidemics.jl currently has basic implementations of three models, roughly tracking the R package {epidemics}.

  1. epidemic_default(): the default model, which is an SEIRV compartmental ODE model allowing for a vaccination regime that confers full immunity with a single dose, as well as (optionally) multiple overlapping interventions to reduce social contacts;

  2. epidemic_vacamole(): the Vacamole model developed by RIVM for the Covid-19 pandemic, which is a work in progress, but will eventually allow for two-dose leaky vaccination, as well as multiple overlapping interventions;

  3. epidemic_stochastic(): A simple stochastic compartmental SIR model.

Epidemics.jl is likely to include the Ebola model, as well as features such as time-dependence and rate interventions, from {epidemics} at some point.

Index

Documentation

Epidemics.NpiType

Npi(timebegin, timeend, contact_reduction)

A structure to hold the end points and strength of a non-pharmaceutical intervention.

source
Epidemics.PopulationType

Population(name, demographyvector, initialconditions, contact_matrix)

A structure to hold population characteristics, including:

  • 'name': A name for the population.
  • 'demography_vector': A numeric vector of the number of individuals in each

age or demographic group of the population.

  • 'initial_conditions': A numeric matrix representing the proportions of each

age or demographic group that are in one of the epidemiological compartments.

  • 'contact_matrix': A matrix giving the contacts between the demographic groups

in the population. Must be a square matrix.

source
Epidemics.VaccinationType

Vaccination(timebegin, timeend, ν)

A structure to hold the end points and strength of a non-pharmaceutical intervention.

source
Epidemics.australia_initial_stateFunction
australia_initial_state()

Initial state with seven compartments: S, E, Is, Ia, R, D, and H, and four age groups and 49 economic sectors (comprised of working age individuals), and two vaccination strata for unvaccinated and vaccinated individuals.

source
Epidemics.cond_vaxMethod
condition(u, t, integrator)

A condition function that triggers an event at a specific time.

source
Epidemics.default_contact_matrixMethod
default_contact_matrix(; n_groups=3)

Create a uniform contact matrix.

Named Arguments

  • n_groups: A Number for the number of demographic groups in the population.

Returns

A matrix of ones with the dimensions n_groups * n_groups.

source
Epidemics.default_initial_conditionsMethod
default_initial_conditions(; n_groups=3, p_infected=[1e-6, 1e-6, 1e-6],
    p_exposed=[0.0, 0.0, 0.0])

Create some useful initial conditions for the default SEIRV epidemic model.

Named Arguments

  • n_groups: A Number for the number of demographic groups in the population.
  • p_infected: The proportion of each demographic group that is infected and also infectious. This is expected to be a Vector of Numbers with each value between 0.0 and 1.0.
  • p_exposed: The proportion of each demographic group that is exposed but not yet infectious. This is expected to be a Vector of Numbers with each value between 0.0 and 1.0.

Returns

A matrix with the dimensions n_groups * 5, with each row representing a demographic groups and each column representing one of the five epidemiological compartments of the default model.

source
Epidemics.epidemic_defaultMethod
epidemic_default(β, σ, γ,
    population, intervention, vaccination,
    time_end, increment
)

Model the progression of an epidemic, with age- or demographic-group specific contact patterns and proportions, non-pharmaceutical interventions with group- specific effects, and group-specific vaccination regimes.

Arguments

  • β: the transmission rate $\beta$ of the disease; may be a numeric Vector;

  • σ: the rate of transition from the exposed to the infectious compartment $\sigma$; may be a numeric Vector;

  • γ: the recovery rate $\gamma$; may be a numeric Vector.

  • population: A Population with population characteristics, importantly including a contact matrix describing group-specific social contacts, and a dmeography vector describing the number of individuals in each demographic group;

  • intervention: An Npi for interventions on social contacts;

  • vaccination: A Vaccination for the vaccination regime applied;

  • time_end: The time in days at which to end the simulation, defaults to 200;

  • increment: The increment in simulation time, defaults to 1.0.

source
Epidemics.epidemic_default_ode!Method
epidemic_default_ode!(du, u, parameters, t)

A simple SEIRV epidemic model function that allows for multiple demographic groups. This function is intended to be called internally from epidemic_default.

The function expects the parameters argument to be a four element vector or tuple with the following elements (which do not have to be named):

  • a prepared contact_matrix, see Population;
  • $\beta$, the transmission rate;
  • $\sigma$, the rate of conversion from exposed to infectious;
  • $\gamma$, the rate of recovery;
  • a matrix specifying the contacts between demographic groups;
  • an Npi object specifying the intervention applied to each age

group, see Npi;

source
Epidemics.epidemic_norovirusMethod
epidemic_norovirus(initial_state, contacts, aging, sigma, phi, upsilon,
    rho, w1, w2, delta, q1, q2, b, d, epsilon, psi, gamma, n_age_groups,
    time_end, increment
)

Model the progression of a norovirus epidemic with multiple optional vaccination strata.

source
Epidemics.epidemic_stochasticMethod
epidemic_stochastic(; population_size, n_infectious, 
    n_recovered, β, σ, time_end, time_increment
)

Run a stochastic, discrete-time, compartmental epidemic model with the compartments "susceptible", "infectious", and "recovered".

Named arguments

  • population_size::Number: The total population size. Defaults to 1000.
  • n_infectious::Number: The number of initially infected individuals. Defaults to 10.
  • n_recovered::Number: The number of initially recovered individuals. Defaults to 0.
  • β::Number: The transmission rate of the infection (denoted $\beta$). Defaults to 10.0.
  • σ::Number: The recovery rate of the infection (denoted $\sigma$, often also denoted $\gamma$). Defaults to 1.0.
  • time_end::Number: The time point at which to end the simulation. Defaults to 5.0.
  • time_increment::Number: The increment in model time. Defaults to 0.01.

Returns

A DataFrame with four columns, "time", "susceptible", "infectious", and "recovered", for the values of each compartment at each time point in the simulation. The number of rows should be roughly equal to time_end / time_increment (and the initial conditions).

Examples

# with default arguments
epidemic_stochastic()

# with some user-sepcified named arguments
epidemic_stochastic(population_size=5000, n_infectious=119,
    β=9.9, σ=1.1
)
source
Epidemics.epidemic_vacamoleMethod
epidemic_vacamole(β, σ, γ, η, ω, βv, ηv, ωv,
    population, intervention, vaccination,
    time_end, increment
)

Model the progression of an epidemic, with age- or demographic-group specific contact patterns and proportions, non-pharmaceutical interventions with group- specific effects, and group-specific vaccination regimes.

The Vacamole model was developed by RIVM, and is particularly useful for modelling leaky, two-dose vaccination.

Arguments

  • β: the transmissibility of the disease;

  • σ: the rate of transition from the exposed to the infectious compartment;

  • γ: the recovery rate;

  • η: the hospitalisation rate;

  • ω: the mortality rate;

  • βv: the transmissibility for fully (doubly) vaccinated individuals;

  • ηv: the hospitalisation rate for fully vaccinated individuals;

  • ωv: the mortality rate for fully vaccinated individuals;

  • population: A Population with population characteristics, which must have

11 compartments in the initial conditions;

  • intervention: An Npi for interventions on social contacts;

  • vaccination: A Vaccination for the vaccination regime applied;

  • time_end: The time in days at which to end the simulation, defaults to 200;

  • increment: The increment in simulation time, defaults to 1.0.

source
Epidemics.epidemic_vacamole_ode!Method
epidemic_vacamole_ode!(du, u, parameters, t)

An epidemic model adapted from the Vacamole model developed by RIVM, the Dutch public health agency, to model the effect of leaky, two-dose vaccination on the Covid-19 pandemic (Ainslie et al. 2022).

This adaptation implements leaky two-dose vaccination, as well as allowing for "hospitalised" and "dead" compartments. Individuals who have been doubly vaccinated can be modelled as having lower susceptibility to infection, and lower hospitalisation and mortality rates.

The model also allows for multiple demographic groups and interventions. This function is intended to be called internally from epidemic_vacamole.

The function expects the parameters argument to be a four element vector or tuple with the following elements (which do not have to be named):

  • a Population object with a prepared contact matrix, see [Population]

(@ref);

  • $\beta$, the baseline transmission rate;

  • $\beta_v$, the transmission rate for doubly vaccinated individuals;

  • $\alpha$, the rate of conversion from exposed to infectious;

  • $\eta$, the baseline hospitalisation rate;

  • $\eta_v$, the hospitalisation rate for doubly vaccinated individuals;

  • $\omega$, the baseline mortality rate;

  • $\omega_v$, the mortality rate for doubly vaccinated individuals;

  • $\gamma$, the rate of recovery;

  • a matrix specifying the contacts between demographic groups;

  • an Npi object specifying the intervention applied to each age group, see Npi;

  • a Vaccination object, see Vaccination;

source
Epidemics.infectious_period_to_gammaMethod
infectious_period_to_gamma(; infectious_period)

Calculate the recovery rate of the infection $\gamma$ from the infectious period.

Named Arguments

  • infectious_period: A single number for the mean duration in days that individuals are infectious.

Returns

A single number representing the recovery rate of the infectious $\gamma$

source
Epidemics.make_combinationsMethod
make_combinations(v...)

Make combinations of input vectors.

Arguments

  • v...: Any number of input Vectors.

Returns

A Vector of tuples with combinations of Vectors passed in v.... If all vectors in v... have the same length, returns a vector of tuples of length 1. Combinations are returned in ascending order of the elements of each i-th element of the input vectors.

Example

```julia vec1 = [1, 2, 3] vec2 = ["a", "b"]

result = make_combinations(vec1, vec2)

note order of results

println(result)

source
Epidemics.preinfectious_period_to_alphaMethod
preinfectious_period_to_alpha(; r0, preinfectious_period)

Calculate the rate of transition from the 'exposed' to the 'infectious' compartment, $\alpha$ from the mean period between exposure and the initial occurrence of symptoms.

Named Arguments

  • preinfectious_period: A single number for the mean duration in days between individuals being exposed to infection and becoming infectious.

Returns

A single number representing the transmission rate of the infectious $\alpha$

source
Epidemics.prepare_contact_matrixMethod
prepare_contact_matrix(; population)

Prepare a population contact matrix for an epidemic model.

Named Arguments

  • population: A Population object with information about the population affected by the epidemic. Must include a contact matrix, and a demography vector.

Returns

A matrix of ones with the dimensions n_groups * n_groups.

source
Epidemics.prepare_initial_conditionsMethod
prepare_initial_conditions(; population)

Prepare initial conditions from a Population object.

Named Arguments

  • population: A Population object with information about the population affected by the epidemic. Must include a matrix of initial conditions, and a demography vector.

Returns

A matrix with the initial conditions scaled by the demography vector.

source
Epidemics.r0_to_betaMethod
r0_to_beta(; r0, infectious_period)

Calculate the transmission rate $\beta$ from the basic reproductive number $R_0$ and the mean infectious period.

Named Arguments

  • r0: A single number for the basic reproduction number of an infection;
  • infectious_period: A single number for the mean duration in days that individuals are infectious.

Returns

A single number representing the transmission rate of the infection $\beta$

source
Epidemics.run_replicatesFunction

runreplicates(modelfn, replicates; args...)

Run any model function multiple times while passing keyword arguments. Especially useful for capturing uncertainty due to randomness in stochastic models.

Arguments

  • model_fn::Function: A model function. Defaults to epidemic_stochastic() but may be any model function from this or another package.
  • replicates::Number: The number of replicates. Defaults to 100.

Named arguments

  • args...: Any extra arguments; these are typically arguments intended to be passed to model_fn.

Returns

A DataFrame in long format with four columns, "time", "compartment", "value", and "replicate", for the values of each compartment at each time point in each replicate of the simulation run by model_fn.

Examples

# pass some arguments to epidemic_stochastic()
run_replicates(epidemic_stochastic, 100,
    population_size=1000, n_infectious=10,
    β=10, σ=1
)
source