Learn R Programming

SimBIID (version 0.2.2)

compileRcpp: Compiles SimBIID_model object

Description

Compiles an object of class SimBIID_model into an XPtr object for use in Rcpp functions, or an object of class function for calling directly from R.

Usage

compileRcpp(model)

Value

An object of class XPtr that points to the compiled function, or an R function object for calling directly from R.

Arguments

model

An object of class SimBIID_model.

See Also

mparseRcpp

Examples

Run this code
# \donttest{
## set up SIR simulationmodel
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 model to be run directly
model <- compileRcpp(model)
model

## set initial states (1 initial infection 
## in population of 120)
iniStates <- c(S = 119, I = 1, R = 0)

## set parameters
pars <- c(beta = 0.001, gamma = 0.1)

## run compiled model
model(pars, 0, 100, iniStates)
# }

Run the code above in your browser using DataLab