Learn R Programming

epimdr (version 0.6-5)

gillespie: Gillespie exact algorithm

Description

Function simulating a dynamical system using the Gillespie exact algorithm

Usage

gillespie(rateqs, eventmatrix, parameters, initialvals, numevents)

Arguments

rateqs

a list with rate equations

eventmatrix

a matrix of changes in state variables associated with each event

parameters

a vector of parameter values

initialvals

a vector of initial values for the states

numevents

number of events to be simulated

Value

A data frame with simulated time series

Examples

Run this code
# NOT RUN {
rlist=c(quote(mu * (S+I+R)), quote(mu * S), quote(beta * S * I /(S+I+R)), 
 quote(mu * I), quote(gamma * I), quote(mu*R))
emat=matrix(c(1,0,0,-1,0,0,-1,1,0,0,-1,0,0,-1,1,0,0,-1),ncol=3, byrow=TRUE)
paras  = c(mu = 1, beta =  1000, gamma = 365/20)
inits = c(S=100, I=2, R=0)
sim=gillespie(rlist, emat, paras, inits, 100)
# }

Run the code above in your browser using DataLab