gillespie: Gillespie exact algorithm

Description Usage Arguments Value Examples

View source: R/rfuncs.R

Description

Function simulating a dynamical system using the Gillespie exact algorithm

Usage

1
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

1
2
3
4
5
6
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)

epimdr documentation built on March 26, 2020, 7:41 p.m.

Related to gillespie in epimdr...