Title: | Analyze Mathematical Models of Healthcare Facility Transmission |
---|---|
Description: | Calculate useful quantities for a user-defined differential equation model of infectious disease transmission among individuals in a healthcare facility. Input rates of transition between states of individuals with and without the disease-causing organism, distributions of states at facility admission, relative infectivity of transmissible states, and the facility length of stay distribution. Calculate the model equilibrium and the basic facility reproduction number, as described in Toth et al. (2025) <doi:10.1101/2025.02.21.25322698>. |
Authors: | Damon Toth [aut, cre, cph]
|
Maintainer: | Damon Toth <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2025-03-07 13:31:51 UTC |
Source: | CRAN |
Calculate the equilibrium of a linear facility model
equilib(M, init, mgf = NULL)
equilib(M, init, mgf = NULL)
M |
A matrix of state transition rates between facility patient states |
init |
A vector of admission state probabilities to each state |
mgf |
The moment generating function characterizing a time-of-stay-dependent removal hazard |
A vector with the proportion of patients in each state at equilibrium
M <- rbind(c(-0.06,0.03,0),c(0.06,-0.08,0),c(0,0.05,0)) init <- c(0.95,0.05,0) mgf <- function(x, deriv=0) MGFgamma(x, rate = 0.05, shape = 2.5, deriv) equilib(M, init, mgf)
M <- rbind(c(-0.06,0.03,0),c(0.06,-0.08,0),c(0,0.05,0)) init <- c(0.95,0.05,0) mgf <- function(x, deriv=0) MGFgamma(x, rate = 0.05, shape = 2.5, deriv) equilib(M, init, mgf)
Calculate the equilibrium of a facility transmission model
facilityeq(S, C, A, R, transm, init, mgf = NULL)
facilityeq(S, C, A, R, transm, init, mgf = NULL)
S |
A matrix of state transition rates between and removal from the susceptible states in the absence of colonized individuals |
C |
A matrix of state transition rates between and removal from the colonized states |
A |
A matrix describing transitions from susceptible to colonized states at acquisition |
R |
A matrix of recovery rates: state transition rates from colonized to susceptible states |
transm |
A vector of transmission rates from each colonized state |
init |
A vector of admission state probabilities to each state |
mgf |
The moment generating function characterizing a time-of-stay-dependent removal hazard |
A vector with the proportion of patients in each state at equilibrium; the vector contains the equilibrium S states followed by C states
S <- 0 C <- rbind(c(-0.38,0),c(0.08,0)) A <- rbind(1,0) R <- cbind(0.3,0) transm <- c(0.1,0.05) init <- c(0.99,0.01,0) mgf <- function(x, deriv=0) MGFgamma(x, rate=0.2, shape=3, deriv) facilityeq(S, C, A, R, transm, init, mgf)
S <- 0 C <- rbind(c(-0.38,0),c(0.08,0)) A <- rbind(1,0) R <- cbind(0.3,0) transm <- c(0.1,0.05) init <- c(0.99,0.01,0) mgf <- function(x, deriv=0) MGFgamma(x, rate=0.2, shape=3, deriv) facilityeq(S, C, A, R, transm, init, mgf)
Calculate basic reproduction number R0
facilityR0(S, C, A, transm, initS, mgf = NULL)
facilityR0(S, C, A, transm, initS, mgf = NULL)
S |
A matrix of state transition rates between and removal from the susceptible states in the absence of colonized individuals |
C |
A matrix of state transition rates between and removal from the colonized states |
A |
A matrix describing transitions from susceptible to colonized states at acquisition |
transm |
A vector of transmission rates from each colonized state |
initS |
A vector of admission state probabilities to each susceptible state |
mgf |
The moment generating function characterizing the time-of-stay-dependent removal hazard |
A number (R0)
S <- rbind(c(-1,2),c(1,-2)) C <- rbind(c(-1.1,0),c(0.1,-0.9)) A <- rbind(c(1,0),c(0,2)) transm <- c(0.4,0.6) initS <- c(0.9,0.1) mgf <- function(x, deriv=0) MGFgamma(x, rate=0.01, shape=3.1, deriv) facilityR0(S,C,A,transm,initS,mgf)
S <- rbind(c(-1,2),c(1,-2)) C <- rbind(c(-1.1,0),c(0.1,-0.9)) A <- rbind(c(1,0),c(0,2)) transm <- c(0.4,0.6) initS <- c(0.9,0.1) mgf <- function(x, deriv=0) MGFgamma(x, rate=0.01, shape=3.1, deriv) facilityR0(S,C,A,transm,initS,mgf)
Calculate the mean length of stay for a linear facility model
meanlengthofstay(M, init, mgf)
meanlengthofstay(M, init, mgf)
M |
A matrix of state transition rates between facility patient states |
init |
A vector of admission state probabilities to each state |
mgf |
The moment generating function characterizing a time-of-stay-dependent removal hazard |
The mean length of stay
M <- rbind(c(-1.1,2),c(1,-2.2)) init <- c(0.9,0.1) mgf <- function(x, deriv=0) MGFgamma(x, rate=0.2, shape=3, deriv) meanlengthofstay(M, init, mgf)
M <- rbind(c(-1.1,2),c(1,-2.2)) init <- c(0.9,0.1) mgf <- function(x, deriv=0) MGFgamma(x, rate=0.2, shape=3, deriv) meanlengthofstay(M, init, mgf)
Evaluate the moment generating function (MGF) of the exponential distribution or a derivative of the MGF
MGFexponential(x, rate, deriv = 0)
MGFexponential(x, rate, deriv = 0)
x |
The value at which to evaluate the MGF |
rate |
The rate parameter value of the exponential distribution |
deriv |
An integer, the number of derivatives of the MGF to apply |
The number resulting from the function evaluation
# MGF of an exponential distribution, evaluated at -0.1: MGFexponential(-0.1, rate = 0.05) # Second moment of the distribution (second derivative evaluated at zero): MGFexponential(0, rate = 0.05, deriv = 2)
# MGF of an exponential distribution, evaluated at -0.1: MGFexponential(-0.1, rate = 0.05) # Second moment of the distribution (second derivative evaluated at zero): MGFexponential(0, rate = 0.05, deriv = 2)
Evaluate the moment generating function (MGF) of the gamma distribution or a derivative of the MGF
MGFgamma(x, rate, shape, deriv = 0)
MGFgamma(x, rate, shape, deriv = 0)
x |
The value at which to evaluate the MGF |
rate |
The rate parameter value of the gamma distribution |
shape |
The shape parameter values of the gamma distribution |
deriv |
An integer, the number of derivatives of the MGF to apply |
The number resulting from the function evaluation
# MGF of a gamma distributions, evaluated at -0.1: MGFgamma(-0.1, rate = 0.7, shape = 3) # Second moment of the distribution (second derivative evaluated at zero): MGFgamma(0, rate = 0.7, shape = 3, deriv = 2)
# MGF of a gamma distributions, evaluated at -0.1: MGFgamma(-0.1, rate = 0.7, shape = 3) # Second moment of the distribution (second derivative evaluated at zero): MGFgamma(0, rate = 0.7, shape = 3, deriv = 2)
Evaluate the moment generating function (MGF) of the mixed gamma distribution or a derivative of the MGF
MGFmixedgamma(x, prob, rate, shape, deriv = 0)
MGFmixedgamma(x, prob, rate, shape, deriv = 0)
x |
The value at which to evaluate the MGF |
prob |
A vector of probabilities of following each gamma distribution in the mixture |
rate |
A vector of rate parameter values for each gamma distribution in the mixture |
shape |
A vector of shape parameter values for each gamma distribution in the mixture |
deriv |
An integer, the number of derivatives of the MGF to apply |
The number resulting from the function evaluation
# MGF of a 40/60 mixture of two gamma distributions, evaluated at -0.1: MGFmixedgamma(-0.1, prob = c(0.4,0.6), rate = c(0.4,0.7), shape = c(0.5,3)) # Second moment of the distribution (second derivative evaluated at zero): MGFmixedgamma(0, prob = c(0.4,0.6), rate = c(0.4,0.7), shape = c(0.5,3), deriv = 2)
# MGF of a 40/60 mixture of two gamma distributions, evaluated at -0.1: MGFmixedgamma(-0.1, prob = c(0.4,0.6), rate = c(0.4,0.7), shape = c(0.5,3)) # Second moment of the distribution (second derivative evaluated at zero): MGFmixedgamma(0, prob = c(0.4,0.6), rate = c(0.4,0.7), shape = c(0.5,3), deriv = 2)