Skip to content

Commit

Permalink
switch to doc raw
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelBrand1 committed Nov 4, 2024
1 parent 92b88b9 commit 2d1e1c4
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 11 deletions.
48 changes: 42 additions & 6 deletions EpiAware/src/EpiInfModels/odemodels/SEIRParams.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
@doc raw"""
Internal function for the vector field of a basic SEIR model written in density/per-capita
form. The function is used to define the ODE problem for the SIR model.
"""
Expand All @@ -12,15 +12,15 @@ function _seir_vf(du, u, p, t)
return nothing
end

"""
@doc raw"""
Sparse Jacobian matrix prototype for the basic SEIR model written in density/per-capita form.
"""
const _seir_jac_prototype = sparse([1.0 0.0 1.0 0.0;
1.0 1.0 1.0 0.0;
0.0 1.0 1.0 0.0;
0.0 0.0 1.0 0.0])

"""
@doc raw"""
Internal function for the Jacobian of the basic SEIR model written in density/per-capita
form. The function is used to define the ODE problem for the SEIR model. The Jacobian
is used to speed up the solution of the ODE problem when using a stiff solver.
Expand All @@ -39,21 +39,57 @@ function _seir_jac(J, u, p, t)
nothing
end

"""
@doc raw"""
Internal function for the ODE function of the basic SIR model written in density/per-capita
form. The function passes vector field and Jacobian functions to the ODE solver.
"""
_seir_function = ODEFunction(_seir_vf; jac = _seir_jac, jac_prototype = _seir_jac_prototype)

"""
A structure representing the SIR (Susceptible-Infectious-Recovered) model and priors for the
@doc raw"""
A structure representing the SEIR (Susceptible-Exposed-Infectious-Recovered) model and priors for the
infectiousness and recovery rate parameters.
# Constructors
- `SEIRParams(; tspan, infectiousness_prior::Distribution, incubation_rate_prior::Distribution,
recovery_rate_prior::Distribution, initial_prop_infected_prior::Distribution)` :
Construct a `SEIRParams` object with the specified time span for ODE solving, infectiousness
prior, incubation rate prior and recovery rate prior.
## SEIR model
```math
\begin{aligned}
\frac{dS}{dt} &= -\beta SI \\
\frac{dE}{dt} &= \beta SI - \alpha E \\
\frac{dI}{dt} &= \alpha E - \gamma I \\
\frac{dR}{dt} &= \gamma I
\end{aligned}
```
Where `S` is the proportion of the population that is susceptible, `E` is the proportion of the
population that is exposed, `I` is the proportion of the population that is infected and `R` is
the proportion of the population that is recovered. The parameters are the infectiousness `β`,
the incubation rate `α` and the recovery rate `γ`.
```julia
using EpiAware, OrdinaryDiffEq, Distributions
# Define the time span for the ODE problem
tspan = (0.0, 30.0)
# Define prior distributions
infectiousness_prior = LogNormal(log(0.3), 0.05)
incubation_rate_prior = LogNormal(log(0.1), 0.05)
recovery_rate_prior = LogNormal(log(0.1), 0.05)
initial_prop_infected_prior = Beta(1, 99)
# Create an instance of SIRParams
seirparams = SEIRParams(
tspan = tspan,
infectiousness_prior = infectiousness_prior,
incubation_rate_prior = incubation_rate_prior,
recovery_rate_prior = recovery_rate_prior,
initial_prop_infected_prior = initial_prop_infected_prior
)
```
"""
struct SEIRParams{
P <: ODEProblem, D <: Sampleable, E <: Sampleable, F <: Sampleable, G <: Sampleable} <:
Expand Down
41 changes: 36 additions & 5 deletions EpiAware/src/EpiInfModels/odemodels/SIRParams.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
@doc raw"""
Internal function for the vector field of a basic SIR model written in density/per-capita
form. The function is used to define the ODE problem for the SIR model.
"""
Expand All @@ -11,14 +11,14 @@ function _sir_vf(du, u, p, t)
return nothing
end

"""
@doc raw"""
Sparse Jacobian matrix prototype for the basic SIR model written in density/per-capita form.
"""
const _sir_jac_prototype = sparse([1.0 1.0 0.0;
1.0 1.0 0.0;
0.0 1.0 0.0])

"""
@doc raw"""
Internal function for the Jacobian of the basic SIR model written in density/per-capita
form. The function is used to define the ODE problem for the SIR model. The Jacobian
is used to speed up the solution of the ODE problem when using a stiff solver.
Expand All @@ -34,13 +34,13 @@ function _sir_jac(J, u, p, t)
nothing
end

"""
@doc raw"""
Internal function for the ODE function of the basic SIR model written in density/per-capita
form. The function passes vector field and Jacobian functions to the ODE solver.
"""
_sir_function = ODEFunction(_sir_vf; jac = _sir_jac, jac_prototype = _sir_jac_prototype)

"""
@doc raw"""
A structure representing the SIR (Susceptible-Infectious-Recovered) model and priors for the
infectiousness and recovery rate parameters.
Expand All @@ -51,6 +51,37 @@ infectiousness and recovery rate parameters.
initial_prop_infected_prior::Distribution)` :
Construct an `SIRParams` object with the specified time span for ODE solving, infectiousness
prior, and recovery rate prior.
## SIR model
```math
\begin{aligned}
\frac{dS}{dt} &= -\beta SI \\
\frac{dI}{dt} &= \beta SI - \gamma I \\
\frac{dR}{dt} &= \gamma I
\end{aligned}
```
Where `S` is the proportion of the population that is susceptible, `I` is the proportion of the
population that is infected and `R` is the proportion of the population that is recovered. The
parameters are the infectiousness `β` and the recovery rate `γ`.
```julia
using EpiAware, OrdinaryDiffEq, Distributions
# Define the time span for the ODE problem
tspan = (0.0, 30.0)
# Define prior distributions
infectiousness_prior = LogNormal(log(0.3), 0.05)
recovery_rate_prior = LogNormal(log(0.1), 0.05)
initial_prop_infected_prior = Beta(1, 99)
# Create an instance of SIRParams
sirparams = SIRParams(
tspan = tspan,
infectiousness_prior = infectiousness_prior,
recovery_rate_prior = recovery_rate_prior,
initial_prop_infected_prior = initial_prop_infected_prior
)
```
"""
struct SIRParams{P <: ODEProblem, D <: Sampleable, E <: Sampleable, F <: Sampleable} <:
AbstractTuringParamModel
Expand Down

0 comments on commit 2d1e1c4

Please sign in to comment.