SimInf style markupParse custom model using SimInf style markup.
Does not have full functionality of mparse. Currently only supports
simulations on a single node.
mparseRcpp(
transitions = NULL,
compartments = NULL,
pars = NULL,
obsProcess = NULL,
addVars = NULL,
stopCrit = NULL,
tspan = FALSE,
incidence = FALSE,
afterTstar = NULL,
PF = FALSE,
runFromR = TRUE
)An object of class SimBIID_model, which is essentially a list
containing elements:
parsed code to compile;
copy of transitions argument;
copy of compartments argument;
copy of pars argument;
copy of obsProcess argument;
copy of stopCrit argument;
copy of addVars argument;
copy of tspan argument;
copy of incidence argument;
copy of afterTstar argument;
copy of PF argument;
copy of runFromR argument.
This can be compiled into an XPtr or function object
using compileRcpp().
character vector containing transitions on the form "X ->
... -> Y". The left (right) side is the initial (final)
state and the propensity is written in between the
->-signs. The special symbol @ is reserved for the empty
set. For example, transitions = c("S -> k1*S*I -> I", "I ->
k2*I -> R") expresses a SIR model.
contains the names of the involved compartments, for
example, compartments = c("S", "I", "R").
a character vector containing the names of the parameters.
data.frame determining the observation process. Columns must be in the order:
dataNames, dist, p1, p2. dataNames is a character
denoting the name of the variable that will be output from the observation process; dist
is a character specifying the distribution of the observation process (must be one of
"unif", "pois", "norm" or "binom" at the current time); p1 is the first parameter
(the lower bound in the case of "unif", the rate in the case of "pois", the mean in the case of
"norm" or the size in the case of "binom"); and finally p2 is the second parameter
(the upper bound in the case of "unif", NA in the case of "pois", the standard deviation in
the case of "norm", and prob in the case of "binom").
a character vector where the names specify the additional variables to be added to the
function call. These can be used to specify variables that can be used for
e.g. additional stopping criteria.
A character vector including additional stopping criteria for rejecting
simulations early. These will be inserted within if(CRIT){out[0] = 0; return out;} statements
within the underlying Rcpp code, which a return value of 0 corresponds to rejecting
the simulation. Variables in CRIT must match either those in compartments
and/or addVars.
A logical determining whether to return time series counts or not.
A logical specifying whether to return incidence curves in addition to counts.
A character containing code to insert after each new event time is
generated.
A logical determining whether to compile the code for use in a particle filter.
logical determining whether code is to be compiled to run directly in R,
or whether to be compiled as an XPtr object for use in Rcpp.
Uses a SimInf style markup to create compartmental state-space
written using Rcpp. A helper run function exists to compile
and run the model. Another helper function, compileRcpp,
can compile the model to produce a function that can be run directly from R,
or compiled into an external pointer (using the RcppXPtrUtils package).
run, compileRcpp, print.SimBIID_model
# \donttest{
## set up SIR simulation model
transitions <- c(
"S -> beta * S * I -> I",
"I -> gamma * I -> R"
)
compartments <- c("S", "I", "R")
pars <- c("beta", "gamma")
model <- mparseRcpp(
transitions = transitions,
compartments = compartments,
pars = pars
)
## compile and run model
sims <- run(
model = model,
pars = c(beta = 0.001, gamma = 0.1),
tstart = 0,
tstop = 100,
u = c(S = 119, I = 1, R = 0)
)
sims
# }
Run the code above in your browser using DataLab