From 2d1e1c4f22adf9b34aaf689fa179d6acc1ca1414 Mon Sep 17 00:00:00 2001 From: Samuel Brand Date: Mon, 4 Nov 2024 13:06:06 +0000 Subject: [PATCH] switch to doc raw --- .../src/EpiInfModels/odemodels/SEIRParams.jl | 48 ++++++++++++++++--- .../src/EpiInfModels/odemodels/SIRParams.jl | 41 ++++++++++++++-- 2 files changed, 78 insertions(+), 11 deletions(-) diff --git a/EpiAware/src/EpiInfModels/odemodels/SEIRParams.jl b/EpiAware/src/EpiInfModels/odemodels/SEIRParams.jl index 9138bf728..9c302feb4 100644 --- a/EpiAware/src/EpiInfModels/odemodels/SEIRParams.jl +++ b/EpiAware/src/EpiInfModels/odemodels/SEIRParams.jl @@ -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. """ @@ -12,7 +12,7 @@ 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; @@ -20,7 +20,7 @@ const _seir_jac_prototype = sparse([1.0 0.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. @@ -39,14 +39,14 @@ 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 @@ -54,6 +54,42 @@ infectiousness and recovery rate parameters. 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} <: diff --git a/EpiAware/src/EpiInfModels/odemodels/SIRParams.jl b/EpiAware/src/EpiInfModels/odemodels/SIRParams.jl index 7d64e474f..e06cd60cc 100644 --- a/EpiAware/src/EpiInfModels/odemodels/SIRParams.jl +++ b/EpiAware/src/EpiInfModels/odemodels/SIRParams.jl @@ -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. """ @@ -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. @@ -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. @@ -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