Internal Documentation

Documentation for EpiInfModels.jl's internal interface.

Contents

Index

Internal API

EpiAware.EpiInfModels.ConstantRenewalStepType
struct ConstantRenewalStep{T} <: EpiAware.EpiInfModels.AbstractConstantRenewalStep

The renewal process iteration/step function struct with constant generation interval.

Note that the generation interval is stored in reverse order.


Fields

  • rev_gen_int::Vector
source
EpiAware.EpiInfModels.ConstantRenewalStepMethod
function (recurrent_step::ConstantRenewalStep)(recent_incidence, Rt)

Implement the Renewal model iteration/step function, with constant generation interval.

Mathematical specification

The new incidence is given by

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

where I_t is the new incidence, R_t is the reproduction number, I_{t-i} is the recent incidence and g_i is the generation interval.

Arguments

  • recent_incidence: Array of recent incidence values order least recent to most recent.
  • Rt: Reproduction number.

Returns

  • Updated incidence array.
source
EpiAware.EpiInfModels.ConstantRenewalWithPopulationStepType
struct ConstantRenewalWithPopulationStep{T} <: EpiAware.EpiInfModels.AbstractConstantRenewalStep

The renewal process iteration/step function struct with constant generation interval and a fixed population size.

Note that the generation interval is stored in reverse order.


Fields

  • rev_gen_int::Vector

  • pop_size::Any

source
EpiAware.EpiInfModels.ConstantRenewalWithPopulationStepMethod
function (recurrent_step::ConstantRenewalWithPopulationStep)(recent_incidence_and_available_sus, Rt)

Callable on a RenewalWithPopulation struct for compute new incidence based on recent incidence, Rt and depletion of susceptibles.

Mathematical specification

The new incidence is given by

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

where I_t is the new incidence, R_t is the reproduction number, I_{t-i} is the recent incidence and g_i is the generation interval.

Arguments

  • recent_incidence_and_available_sus: A tuple with an array of recent incidence

values and the remaining susceptible/available individuals.

  • Rt: Reproduction number.

Returns

  • Vector containing the updated incidence array and the new recent_incidence_and_available_sus

value.

source
EpiAware.EpiAwareBase.generate_latent_infsMethod
generate_latent_infs(
    epi_model::AbstractTuringRenewal,
    _Rt
) -> Any

Implement the generate_latent_infs function for the Renewal model.

Example usage with Renewal type of model for unobserved infection process

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 renewal_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, θ)
source
EpiAware.EpiAwareBase.generate_latent_infsMethod
generate_latent_infs(
    epi_model::DirectInfections,
    Z_t
) -> Any

Implement the generate_latent_infs function for the DirectInfections model.

Example usage with DirectInfections type of model for unobserved infection 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, θ)
source
EpiAware.EpiAwareBase.generate_latent_infsMethod
generate_latent_infs(epi_model::ExpGrowthRate, rt) -> Any

Implement the generate_latent_infs function for the ExpGrowthRate model.

Example usage with ExpGrowthRate type of model for unobserved infection process

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, θ)
source
EpiAware.EpiAwareUtils.get_stateMethod
get_state(
    acc_step::EpiAware.EpiInfModels.ConstantRenewalStep,
    initial_state,
    state
) -> Any

Method to get the state of the accumulation for a ConstantRenewalStep object.

source
EpiAware.EpiAwareUtils.get_stateMethod
get_state(
    acc_step::EpiAware.EpiInfModels.ConstantRenewalWithPopulationStep,
    initial_state,
    state
) -> Any

Method to get the state of the accumulation for a ConstantRenewalWithPopulationStep object.

source
EpiAware.EpiInfModels.make_renewal_initMethod
make_renewal_init(epi_model::Renewal, I₀, Rt₀) -> Any

Create the initial state of the Renewal model.

Arguments

  • epi_model::Renewal: The Renewal model.
  • I₀: The initial number of infected individuals.
  • Rt₀: The initial time-varying reproduction number.

Returns

The initial vector of infected individuals.

source
EpiAware.EpiInfModels.neg_MGFMethod
neg_MGF(r, w::AbstractVector) -> Any

Compute the negative moment generating function (MGF) for a given rate r and weights w.

Arguments

  • r: The rate parameter.
  • w: An abstract vector of weights.

Returns

The value of the negative MGF.

source
EpiAware.EpiInfModels.renewal_init_stateMethod
renewal_init_state(
    recurrent_step::EpiAware.EpiInfModels.ConstantRenewalStep,
    I₀,
    r_approx,
    len_gen_int
) -> Any

Constructs the initial conditions for a renewal model with ConstantRenewalStep type of step function.

source
EpiAware.EpiInfModels.renewal_init_stateMethod
renewal_init_state(
    recurrent_step::EpiAware.EpiInfModels.ConstantRenewalWithPopulationStep,
    I₀,
    r_approx,
    len_gen_int
) -> Any

Constructs the initial conditions for a renewal model with ConstantRenewalWithPopulationStep type of step function.

source