Description Usage Arguments Value See Also Examples
Wrapper function that compiles (if necessary) and runs
a SimBIID_model
object. Returns results in a
user-friendly manner as a SimBIID_run
object,
for which print()
and plot()
generics
are provided.
1 2 3 4 5 6 7 8 9 10 11 |
model |
An object of class |
pars |
A named vector of parameters. |
tstart |
The time at which to start the simulation. |
tstop |
The time at which to stop the simulation. |
u |
A named vector of initial states. |
tspan |
A numeric vector containing the times at which to save the states of the system. |
nrep |
Specifies the number of simulations to run. |
parallel |
A |
mc.cores |
Number of cores to use if using parallel processing. |
An object of class SimBIID_run
, essentially a list
containing elements:
sums: a data.frame()
with summaries of the model runs. This
includes columns run
, completed
, t
, u*
(see help file for SimBIID_model
for more details);
runs: a data.frame()
object, containing columns: run
,
t
, u*
(see help file for SimBIID_model
for more details).
These contain time series counts for the simulations. Note that this will
only be returned if tspan = TRUE
in the original SimBIID_model
object.
bootEnd: a time point denoting when bootstrapped estimates end and predictions
begin (for predict.PMCMC()
method).
mparseRcpp
, print.SimBIID_runs
, plot.SimBIID_runs
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | ## 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
## add tspan option to return
## time series counts at different
## time points
model <- mparseRcpp(
transitions = transitions,
compartments = compartments,
pars = pars,
tspan = TRUE
)
sims <- run(
model = model,
pars = c(beta = 0.001, gamma = 0.1),
tstart = 0,
tstop = 100,
u = c(S = 119, I = 1, R = 0),
tspan = seq(1, 100, length.out = 10)
)
sims
## run 100 replicate simulations and
## plot outputs
sims <- run(
model = model,
pars = c(beta = 0.001, gamma = 0.1),
tstart = 0,
tstop = 100,
u = c(S = 119, I = 1, R = 0),
tspan = seq(1, 100, length.out = 10),
nrep = 100
)
sims
plot(sims)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.