sim {denim} | R Documentation |
Simulator for deterministic discrete time model with memory
Description
Simulation function that call the C++ simulator
Usage
sim(
transitions,
initialValues,
parameters = NULL,
simulationDuration,
timeStep = 1,
errorTolerance = 0.001
)
Arguments
transitions |
a list of transitions follows this format |
initialValues |
a vector contains the initial values of all compartments defined
in the transitions, follows this format |
parameters |
a vector contains values of any parameters that are not compartments,
usually parameters used in |
simulationDuration |
duration of time to be simulate |
timeStep |
set the output time interval. For example, if |
errorTolerance |
set the threshold so that a cumulative distribution function
can be rounded to 1. For example, if we want a cumulative probability of 0.999 to
be rounded as 1, we set |
Value
a data.frame with class denim
that can be plotted with a plot()
method
Examples
transitions <- list(
"S -> I" = "beta * S * I / N",
"I -> R" = d_gamma(3, 2)
)
initialValues <- c(
S = 999,
I = 1,
R = 0
)
parameters <- c(
beta = 0.012,
N = 1000
)
simulationDuration <- 30
timeStep <- 0.01
mod <- sim(transitions = transitions,
initialValues = initialValues,
parameters = parameters,
simulationDuration = simulationDuration,
timeStep = timeStep)