compileRcpp: Compiles 'SimBIID_model' object

Description Usage Arguments Value See Also Examples

View source: R/compileRcpp.R

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

1
compileRcpp(model)

Arguments

model

An object of class SimBIID_model.

Value

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

See Also

mparseRcpp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## 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)

SimBIID documentation built on Feb. 4, 2021, 9:07 a.m.