Description Usage Arguments Details Value Examples
A stochastic SEIR model with 4 compartments solved using Gillespie’s direct method.
1 | seir_nsimul(x, params, maxstep = 1000, nsims = 5)
|
x |
|
params |
|
maxstep |
|
nsims |
|
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.
data.frame
The 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.
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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.