seir_nsimul: Stochastic SEIR model with equal birth and deaths for...

Description Usage Arguments Details Value Examples

View source: R/seir_nsimul.R

Description

A stochastic SEIR model with 4 compartments solved using Gillespie’s direct method.

Usage

1
seir_nsimul(x, params, maxstep = 1000, nsims = 5)

Arguments

x

vector of 5 parameters time, S, E, I and R. time is the initial starting time, S is the Susceptibles, E is the Exposed, I is the Infecteds and R is the Recovereds.

params

vector of 3 parameters beta, gamma, mu and sigma. beta is the transmission rate, gamma is the recovery rate, mu is the per capita death rate, and the population level birth rate and sigma is is the rate at which individuals move from the exposed to the infectious classes.

maxstep

numeric value that indicates the maximum number of transiction between the population. Defaults to 1000.

nsims

numeric value that indicates the number of simulations. Defaults to 5.

Details

S, E, I,R must be positive and S + I + R = N where N is the whole population. Every simulation stops when there are no Infecteds or when the maximum number of steps is reached.

Value

data.frameThe data.frame contains 6 columns. Second, third,fourth, fifth and sixth are the arguments of the input vector x. The first column indicates the specific number of the simulation. The column takes (.n) values from 1 up to nsims increasing by 1.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
library('plyr')
set.seed(0)

nsims <- 8
xstart <- c(time=0,S=595, E= 100, I=5,R=0) #initial conditions
params <- c(mu=0.015,beta=20,gamma=13, sigma = 4) #parameters

res <- seir_nsimul(x = xstart, params = params, nsims = nsims)

par(mfrow=c(3,1), mar=c(2,4,1,1))

plot(S~time,data=res,type='n')
d_ply(res,".n",function(x)lines(S~time,data=x,col=.n))

plot(E~time,data=res,type='n')
d_ply(res,".n",function(x)lines(E~time,data=x,col=.n))

plot(I~time,data=res,type='n')
d_ply(res,".n",function(x)lines(I~time,data=x,col=.n))

plot(R~time,data=res,type='n')
d_ply(res,".n",function(x)lines(R~time,data=x,col=.n))

NicolasPhysentzides/popdyn documentation built on Sept. 11, 2020, 2:26 p.m.