| mparse | R Documentation |
SimInfDescribe your model in a logical way in R. mparse creates a
SimInf_model object with your model
definition that is ready to run.
mparse(
transitions = NULL,
compartments = NULL,
ldata = NULL,
gdata = NULL,
u0 = NULL,
v0 = NULL,
tspan = NULL,
events = NULL,
E = NULL,
N = NULL,
pts_fun = NULL,
use_enum = FALSE
)
transitions |
character vector containing transitions on the
form |
compartments |
contains the names of the involved
compartments, for example, |
ldata |
optional data for the nodes. Can be specified as a
|
gdata |
optional data that are common to all nodes in the
model. Can be specified either as a optionally named numeric
vector or as as a one-row data.frame. The names are used to
identify the parameters in the transitions. When |
u0 |
A |
v0 |
optional data with the initial continuous state in each
node. |
tspan |
A vector (length >= 1) of increasing time points
where the state of each node is to be returned. Can be either
an |
events |
A |
E |
matrix to handle scheduled events, see
|
N |
matrix to handle scheduled events, see
|
pts_fun |
optional character vector with C code for the post time step function. The C code should contain only the body of the function i.e. the code between the opening and closing curly brackets. |
use_enum |
generate enumeration constants for the indices to
each parameter in the 'u', 'v', 'ldata', and 'gdata' vectors
in the generated C code. The name of each enumeration constant
will be transformed to the upper-case name of the
corresponding parameter, for example, a parameter 'beta' will
become 'BETA'. The enumeration constants 'N_COMPARTMENTS_U'
and 'N_COMPARTMENTS_V' will be automatically added to
facilitate indexing 'u' and 'v' in the C code. These two
enumeration constants cannot be used as a compartment or
variable name. Using enumeration constants can make it easier
to modify the C code afterwards, or when writing C code for
the |
a SimInf_model object
## Not run:
## Use the model parser to create a 'SimInf_model' object that
## expresses the SIR model, where 'beta' is the transmission rate
## and 'gamma' is the recovery rate.
model <- mparse(transitions = c("S -> beta*S*I/N -> I",
"I -> gamma*I -> R",
"N <- S+I+R"),
compartments = c("S", "I", "R"),
gdata = c(beta = 0.16, gamma = 0.077),
u0 = data.frame(S = 100, I = 1, R = 0),
tspan = 1:100)
## Run and plot the result
set.seed(22)
result <- run(model)
plot(result)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.