From 97d8224528333a9edbb43aa6e195a4a9ee928703 Mon Sep 17 00:00:00 2001 From: Samuel Brand <48288458+SamuelBrand1@users.noreply.github.com> Date: Tue, 12 Mar 2024 23:08:58 +0000 Subject: [PATCH] commit all --- EpiAware/src/abstract-types.jl | 13 ++++++------- EpiAware/src/epimodels/directinfections.jl | 13 +++++++------ EpiAware/src/epimodels/expgrowthrate.jl | 11 ++++++----- EpiAware/src/epimodels/renewal.jl | 15 +++++++++------ 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/EpiAware/src/abstract-types.jl b/EpiAware/src/abstract-types.jl index 48d1a6503..bbb95eadb 100644 --- a/EpiAware/src/abstract-types.jl +++ b/EpiAware/src/abstract-types.jl @@ -1,10 +1,8 @@ abstract type AbstractModel end """ - abstract type AbstractEpiModel <: AbstractModel end - The abstract supertype for all structs that define a model for generating unobserved/latent - infections. +infections. """ abstract type AbstractEpiModel <: AbstractModel end @@ -17,8 +15,8 @@ abstract type AbstractLatentModel <: AbstractModel end abstract type AbstractObservationModel <: AbstractModel end @doc raw""" -Generate unobserved/latent infections based on the given `epi_model <: AbstractEpimodel` - and a latent process path ``Z_t``. +Constructor function for unobserved/latent infections based on the type of +`epi_model <: AbstractEpimodel` and a latent process path ``Z_t``. The `generate_latent_infs` function implements a model of generating unobserved/latent infections conditional on a latent process. Which model of generating unobserved/latent @@ -29,9 +27,10 @@ defined for the given `epi_model`, then `EpiAware` will return a warning and ret ## Interface to `Turing.jl` probablilistic programming language (PPL) Apart from the no implementation fallback method, the `generate_latent_infs` implementation -function should be a constructor function for a +function returns a constructor function for a [`DynamicPPL.Model`](https://turinglang.org/DynamicPPL.jl/stable/api/#DynamicPPL.Model) - object. +object where the unobserved/latent infections are a generated quantity. Priors for model +parameters are fields of `epi_model`. """ function generate_latent_infs(epi_model::AbstractEpiModel, Z_t) @warn "No concrete implementation for `generate_latent_infs` is defined." diff --git a/EpiAware/src/epimodels/directinfections.jl b/EpiAware/src/epimodels/directinfections.jl index b65a5c5dc..06e579aad 100644 --- a/EpiAware/src/epimodels/directinfections.jl +++ b/EpiAware/src/epimodels/directinfections.jl @@ -11,14 +11,15 @@ 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, `initialisation_prior` which must -be supplied to the `DirectInfections` constructor. The default `initialisation_prior` is -the standard Normal `Distributions.Normal()`. + ``\hat{I}_0`` are sampled from a prior distribution. -## Constructor +`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()`. -`DirectInfections` can be constructed by passing an `EpiData` object and subtype of -[`Distributions.Sampleable`](https://juliastats.org/Distributions.jl/latest/types/#Sampleable). +## Constructors + +- `DirectInfections(; data, initialisation_prior)` ## Example usage with `generate_latent_infs` diff --git a/EpiAware/src/epimodels/expgrowthrate.jl b/EpiAware/src/epimodels/expgrowthrate.jl index 593de1a51..fcc204490 100644 --- a/EpiAware/src/epimodels/expgrowthrate.jl +++ b/EpiAware/src/epimodels/expgrowthrate.jl @@ -12,14 +12,15 @@ 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, `initialisation_prior` which must -be supplied to the `DirectInfections` constructor. The default `initialisation_prior` is -the standard Normal `Distributions.Normal()`. + ``\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` can be constructed by passing an `EpiData` object and and subtype of -[`Distributions.Sampleable`](https://juliastats.org/Distributions.jl/latest/types/#Sampleable). +- `ExpGrowthRate(; data, initialisation_prior)`. ## Example usage with `generate_latent_infs` diff --git a/EpiAware/src/epimodels/renewal.jl b/EpiAware/src/epimodels/renewal.jl index ce6761233..e94aa9f7a 100644 --- a/EpiAware/src/epimodels/renewal.jl +++ b/EpiAware/src/epimodels/renewal.jl @@ -16,10 +16,8 @@ I_t &= g(\hat{I}_0) \exp(r(\mathcal{R}_1) t), \qquad t \leq 0. ``` where ``g`` is a transformation function and the unconstrained initial infections -``\hat{I}_0`` are sampled from a prior distribution, `initialisation_prior` which must -be supplied to the `DirectInfections` constructor. The default `initialisation_prior` is -the standard Normal `Distributions.Normal()`. The discrete generation interval is given by -``g_i``. +``\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 @@ -29,10 +27,13 @@ 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()`. + ## Constructor -`Renewal` can be constructed by passing an `EpiData` object and and subtype of -[`Distributions.Sampleable`](https://juliastats.org/Distributions.jl/latest/types/#Sampleable). +- `Renewal(; data, initialisation_prior)`. ## Example usage with `generate_latent_infs` @@ -82,6 +83,8 @@ I_t = generated_quantities(latent_inf, θ) end @doc """ + function (epi_model::Renewal)(recent_incidence, Rt) + Callable on a `Renewal` struct for compute new incidence based on recent incidence and Rt. ## Mathematical specification