Public Documentation

Documentation for EpiInfModels.jl's public interface.

See the Internals section of the manual for internal package docs covering all submodules.

Contents

Index

Public API

EpiAware.EpiInfModels.DirectInfectionsType
struct DirectInfections{S<:Distributions.Sampleable} <: AbstractTuringEpiModel

Model unobserved/latent infections as a transformation on a sampled latent process.

Mathematical specification

If $Z_t$ is a realisation of the latent model, then the unobserved/latent infections are given by

\[I_t = g(\hat{I}_0 + Z_t).\]

where $g$ is a transformation function and the unconstrained initial infections $\hat{I}_0$ are sampled from a prior distribution.

DirectInfections are constructed by passing an EpiData object data and an initialisation_prior for the prior distribution of $\hat{I}_0$. The default initialisation_prior is Normal().

Constructors

  • DirectInfections(; data, initialisation_prior)

Example usage with generate_latent_infs

generate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.

First, we construct a DirectInfections struct with an EpiData object, an initialisation prior and a transformation function.

using Distributions, Turing, EpiAware
gen_int = [0.2, 0.3, 0.5]
g = exp

# Create an EpiData object
data = EpiData(gen_int, g)

# Create a DirectInfections model
direct_inf_model = DirectInfections(data = data, initialisation_prior = Normal())

Then, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of direct_inf_model.

# Construct a Turing model
Z_t = randn(100)
latent_inf = generate_latent_infs(direct_inf_model, Z_t)

Now we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.

# Sample from the unobserved infections model

#Sample random parameters from prior
θ = rand(latent_inf)
#Get unobserved infections as a generated quantities from the model
I_t = generated_quantities(latent_inf, θ)

Fields

  • data::EpiData: Epidata object.

  • initialisation_prior::Distributions.Sampleable: Prior distribution for the initialisation of the infections. Default is Normal().

source
EpiAware.EpiInfModels.EpiDataType
struct EpiData{T<:Real, F<:Function}

The EpiData struct represents epidemiological data used in infectious disease modeling.

Constructors

  • EpiData(gen_int, transformation::Function). Constructs an EpiData object with discrete

generation interval gen_int and transformation function transformation.

  • EpiData(;gen_distribution::ContinuousDistribution, D_gen, Δd = 1.0, transformation::Function = exp).

Constructs an EpiData object with double interval censoring discretisation of the continuous next generation interval distribution gen_distribution with additional right truncation at D_gen. Δd sets the interval width (default = 1.0). transformation sets the transformation function

Examples

Construction direct from discrete generation interval and transformation function:

using EpiAware
gen_int = [0.2, 0.3, 0.5]
g = exp
data = EpiData(gen_int, g)

Construction from continuous distribution for generation interval.

using Distributions

gen_distribution = Uniform(0.0, 10.0)

data = EpiData(;gen_distribution
    D_gen = 10.0)

Fields

  • gen_int::Vector{T} where T<:Real: Discrete generation interval.

  • len_gen_int::Integer: Length of the discrete generation interval.

  • transformation::Function: Transformation function defining constrained and unconstrained domain bijections.

source
EpiAware.EpiInfModels.ExpGrowthRateType
struct ExpGrowthRate{S<:Distributions.Sampleable} <: AbstractTuringEpiModel

Model unobserved/latent infections as due to time-varying exponential growth rate $r_t$ which is generated by a latent process.

Mathematical specification

If $Z_t$ is a realisation of the latent model, then the unobserved/latent infections are given by

\[I_t = g(\hat{I}_0) \exp(Z_t).\]

where $g$ is a transformation function and the unconstrained initial infections $\hat{I}_0$ are sampled from a prior distribution.

ExpGrowthRate are constructed by passing an EpiData object data and an initialisation_prior for the prior distribution of $\hat{I}_0$. The default initialisation_prior is Normal().

Constructor

  • ExpGrowthRate(; data, initialisation_prior).

Example usage with generate_latent_infs

generate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.

First, we construct an ExpGrowthRate struct with an EpiData object, an initialisation prior and a transformation function.

using Distributions, Turing, EpiAware
gen_int = [0.2, 0.3, 0.5]
g = exp

# Create an EpiData object
data = EpiData(gen_int, g)

# Create an ExpGrowthRate model
exp_growth_model = ExpGrowthRate(data = data, initialisation_prior = Normal())

Then, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of direct_inf_model.

# Construct a Turing model
Z_t = randn(100) * 0.05
latent_inf = generate_latent_infs(exp_growth_model, Z_t)

Now we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.

# Sample from the unobserved infections model

#Sample random parameters from prior
θ = rand(latent_inf)
#Get unobserved infections as a generated quantities from the model
I_t = generated_quantities(latent_inf, θ)

Fields

  • data::EpiData

  • initialisation_prior::Distributions.Sampleable

source
EpiAware.EpiInfModels.RenewalType
struct Renewal{E, S<:Distributions.Sampleable, A} <: AbstractTuringRenewal

Model unobserved/latent infections as due to time-varying Renewal model with reproduction number $\mathcal{R}_t$ which is generated by a latent process.

Mathematical specification

If $Z_t$ is a realisation of the latent model, then the unobserved/latent infections are given by

\[\begin{align} \mathcal{R}_t &= g(Z_t),\\ I_t &= \mathcal{R}_t \sum_{i=1}^{n-1} I_{t-i} g_i, \qquad t \geq 1, \\ I_t &= g(\hat{I}_0) \exp(r(\mathcal{R}_1) t), \qquad t \leq 0. \end{align}\]

where $g$ is a transformation function and the unconstrained initial infections $\hat{I}_0$ are sampled from a prior distribution. The discrete generation interval is given by $g_i$.

$r(\mathcal{R}_1)$ is the exponential growth rate implied by $\mathcal{R}_1)$ using the implicit relationship between the exponential growth rate and the reproduction number.

\[\mathcal{R} \sum_{j \geq 1} g_j \exp(- r j)= 1.\]

Renewal are constructed by passing an EpiData object data and an initialisation_prior for the prior distribution of $\hat{I}_0$. The default initialisation_prior is Normal().

Constructors

  • Renewal(; data, initialisation_prior). Construct a Renewal model with default update steps.
  • Renewal(data; initialisation_prior). Construct a Renewal model with default update steps.
  • Renewal(data, initialisation_prior, recurrent_step) Construct a Renewal model with recurrent_step update step function.

Example usage with generate_latent_infs

generate_latent_infs can be used to construct a Turing model for the latent infections conditional on the sample path of a latent process. In this example, we generate a sample of a white noise latent process.

First, we construct an Renewal struct with an EpiData object, an initialisation prior and a transformation function.

using Distributions, Turing, EpiAware
gen_int = [0.2, 0.3, 0.5]
g = exp

# Create an EpiData object
data = EpiData(gen_int, g)

# Create an Renewal model
renewal_model = Renewal(data; initialisation_prior = Normal())

Then, we can use generate_latent_infs to construct a Turing model for the unobserved infection generation model set by the type of direct_inf_model.

# Construct a Turing model
Z_t = randn(100) * 0.05
latent_inf = generate_latent_infs(renewal_model, Z_t)

Now we can use the Turing PPL API to sample underlying parameters and generate the unobserved infections.

# Sample from the unobserved infections model

#Sample random parameters from prior
θ = rand(latent_inf)
#Get unobserved infections as a generated quantities from the model
I_t = generated_quantities(latent_inf, θ)

Fields

  • data::Any

  • initialisation_prior::Distributions.Sampleable

  • recurrent_step::Any

source
EpiAware.EpiInfModels.R_to_rMethod
R_to_r(
    R₀,
    w::Array{T<:AbstractFloat, 1};
    newton_steps,
    Δd
) -> Any

This function computes an approximation to the exponential growth rate r given the reproductive ratio R₀ and the discretized generation interval w with discretized interval width Δd. This is based on the implicit solution of

\[G(r) - {1 \over R_0} = 0.\]

where

\[G(r) = \sum_{i=1}^n w_i e^{-r i}.\]

is the negative moment generating function (MGF) of the generation interval distribution.

The two step approximation is based on: 1. Direct solution of implicit equation for a small r approximation. 2. Improving the approximation using Newton's method for a fixed number of steps newton_steps.

Returns:

  • The approximate value of r.
source
EpiAware.EpiInfModels.expected_RtMethod
expected_Rt(
    data::EpiData,
    infections::Vector{<:Real}
) -> Any

Calculate the expected Rt values based on the given EpiData object and infections.

\[R_t = \frac{I_t}{\sum_{i=1}^{n} I_{t-i} g_i}\]

Arguments

  • data::EpiData: An instance of the EpiData type containing generation interval data.
  • infections::Vector{<:Real}: A vector of infection data.

Returns

  • exp_Rt::Vector{Float64}: A vector of expected Rt values.

Examples

using EpiAware

data = EpiData([0.2, 0.3, 0.5], exp)
infections = [100, 200, 300, 400, 500]
expected_Rt(data, infections)
source
EpiAware.EpiInfModels.r_to_RMethod
r_to_R(r, w::AbstractVector) -> Any
r_to_R(r, w)

Compute the reproductive ratio given exponential growth rate r and discretized generation interval w.

Arguments

  • r: The exponential growth rate.
  • w: discretized generation interval.

Returns

  • The reproductive ratio.
source