| SIRstoch | R Documentation |
This is a more complicated example for a markov jump process
defined as mjpModel. It is included to the package for
demonstration purposes.
SIRstoch
An object of class mjpModel.
parmsinfection (beta) and recovery rate (gamma).
initThere are three integer variables S,I,R with initial value (10,1,0).
jumpfuncThere are two jumptypes. infections jump from (S,I,R) to
(S-1,I+1,R), recoveries from (S,I,R) to (S,I-1,R+1).
ratefuncA vector of length two determining the probability of a jump being a recovery or infection.
timesThe simulations will start at time t = 0 and end at
t = 10 with step length 0.01.
KendallBD for a simpler example of a
mjpModel and mjpModel-class
for the formal description of the S4 class.
## the code used to generate this model:
SIRstoch <- mjpModel(
descr = "stochastic SIR epidemic",
init = c(S=10,I=1,R=0),
times = c(from = 0, to = 10, by = 0.01),
ratefunc = function(t, x, parms) c(parms[1]*x[1]*x[2],parms[2]*x[2]),
jumpfunc = function(t, x, parms, jtype){
x+switch(jtype,c(-1,1,0),c(0,-1,1))
},
parms=c(beta=1,gamma=1))
## load it and plot a simulation:
data("SIRstoch")
plot(sim(SIRstoch))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.