metaSIR: Discrete-time SIR epidemic model

View source: R/metaSIR.R

metaSIRR Documentation

Discrete-time SIR epidemic model

Description

Returns functions to simulate or calculate the log-density of a discrete-time SIR Process with a meta-population structure, given a parameter set.

Progresses the epidemic one day forward and returns the state after the progression along with how many of each event happened in each metapopulation.

Usage

metaSIR(N_M, endTime)

Arguments

N_M

The size of each meta-population. The length of this vector will determine how many meta-populations there are.

endTime

At what time does simulation of the epidemic stop. By default, endTime is infinite meaning the epidemic is simulated until it dies out.

X_t

A vector of length three holding information about the total number of individuals in each epidemic state across all metapopulations.

beta_G

Global infection parameter. The rate at which an infective from one metapopulation infects a susceptible in another metapopulation

beta_L

Local infection parameter. The rate at which an infective from one metapopulation infects a susceptible from the same metapopulation.

gamma

Removal rate parameter. The rate at which one moves from the infective state to the removal state.

X

A 3-dimensional array whose 2 matrix slices are the state of the epidemic at time t and the state at time t + 1 respectively.

theta

Epidemic parameters. Three parameters need to be given corresponding to beta_G, beta_L and gamma in that order (see dailyProg).

Value

Returns three functions. A sim function to simulate from the generated model, given a set of parameters. A dailyProg function, whose behaviour is identical to sim but simulates for one time unit only. Finally, a llh function to calculate he log-density for an epidemic, given a set of parameters.

Returns the propagate StateX and Mstate along with the number of infections and removals which occured in each metapopulation (Infections, Removals) Calculate the log-likelihood of an SIR epidemic which is assumed to take place in a metapopulation structure occurs, given a parameter set.

    Returns log-likelihood value corresponding to
            the given epidemic and parameter set.

Examples

M <- 5
N_M <- rep(1e4, 5)
epiModel <- metaSIR(N_M, endTime)        

# Simulate Epidemic
I0 <- 50
X0 <- matrix(nrow = M, ncol = 3)
X0[1, ] <- c(N_M[1] - I0, I0, 0)
for(i in 2:M){
    X0[i, ] <- c(N_M[i], 0, 0)
}
theta <- c(0.05, 1, 0.25)
X <- epiModel$sim(list(X0, theta))        

# Calculate Log-density
epiModel$llh(X, theta)


JMacDonaldPhD/REpi documentation built on Aug. 2, 2022, 2:09 p.m.