The goal of facilityepimath is to provide functions to calculate useful quantities for a user-defined differential equation model of infectious disease transmission among individuals in a healthcare facility, including the basic facility reproduction number and model equilibrium.
You can install the development version of facilityepimath from GitHub with:
# install.packages("pak")
pak::pak("damontoth/facilityepimath")
The functions in this package analyze compartmental differential equation models, where the compartments are states of individuals who are co-located in a healthcare facility, for example, patients in a hospital or patients/residents of long-term care facility.
Our example here is a hospital model with four compartments: two
compartments
A system of differential equations with those 4 compartments may take the following general form:
The acquisition rate
We will demonstrate how to calculate the basic reproduction number facilityR0
function. The following components
of the system are required as inputs to the function call below.
A matrix S
governing the transitions between, and out of, the states
A matrix C
governing the transitions between, and out of, the states
A matrix A
describing the S-to-C state transitions when an acquisition
occurs:
A vector transm
containing the
A vector initS
containing the admission state probabilities for the
susceptible compartments only (i.e., the pre-invasion system before a
colonized patient is introduced):
A function mgf(x,deriv)
that is the moment-generating function (and
its derivatives) of the distribution for which the
time-of-stay-dependent removal rate h(t)
is the hazard function. This
is the length of stay distribution when the state-dependent removal
rates
library(facilityepimath)
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)
MGFmixedgamma <- function(x, prob, rate, shape, deriv=0)
sum(exp(log(prob)+lgamma(shape+deriv)-lgamma(shape)-shape*log(1-x/rate)-deriv*log(rate-x)))
mgf <- function(x, deriv=0) MGFmixedgamma(x, prob=1, rate=0.01, shape=3.1, deriv)
facilityR0(S,C,A,transm,initS,mgf)
#> [1] 0.7244774