Description Usage Format Slots See Also Examples
This is a more complicated example for a markov jump process
defined as mjpModel
. It is included to the package for
demonstration purposes.
1 |
An object of class mjpModel
.
parms
infection (beta
) and recovery rate (gamma
).
init
There are three integer variables S,I,R
with initial value (10,1,0).
jumpfunc
There 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)
.
ratefunc
A vector of length two determining the probability of a jump being a recovery or infection.
times
The 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## 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.