Skip to content

Commit

Permalink
commit all
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelBrand1 authored and seabbs committed Mar 15, 2024
1 parent 67e5e40 commit 97d8224
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
13 changes: 6 additions & 7 deletions EpiAware/src/abstract-types.jl
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand All @@ -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."
Expand Down
13 changes: 7 additions & 6 deletions EpiAware/src/epimodels/directinfections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
11 changes: 6 additions & 5 deletions EpiAware/src/epimodels/expgrowthrate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
15 changes: 9 additions & 6 deletions EpiAware/src/epimodels/renewal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 97d8224

Please sign in to comment.