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
"transition" = distribution()
- initialValues
a vector contains the initial values of all compartments defined in the transitions, follows this format
compartment_name = initial_value
- parameters
a vector contains values of any parameters that are not compartments, usually parameters used in
mathexp()
functions- simulationDuration
duration of time to be simulate
- timeStep
set the output time interval. For example, if
simulationDuration = 10
means 10 days andtimeStep = 0.1
, the output will display results for each 0.1 daily interval- 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
errorTolerance = 0.001
(1 - 0.999 = 0.001). Default is 0.001
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)