Simulates incidence data conditional on a fitted nonlinear mixed effects model of epidemic growth. Optionally re-estimates the model given the simulated data, thus generating samples from the conditional distribution of the bottom level parameter vector.
# S3 method for egf
simulate(object, nsim = 1, seed = NULL,
bootstrap = FALSE,
control = list(), parallel = egf_parallel(),
trace = FALSE, ...)
A list inheriting from class simulate.egf
, with elements:
a data frame containing simulated incidence data. It has variables
ts
, window
, time
, and X
, where X
is a numeric matrix with nsim
columns. It corresponds rowwise
to model.frame(object)
.
a numeric matrix with nsim
columns, each a sample from the
conditional distribution of the parameter vector represented by
coef(object)
. NULL
if the method
call did not set bootstrap = TRUE
.
Attribute RNGstate
preserves the RNG state prior to simulation,
making the result reproducible.
an egf
object.
a positive integer indicating a number of replications.
an integer used to set the RNG state before simulation or,
otherwise, NULL
; see simulate
.
a logical. If TRUE
, then a bootstrapping step is performed.
passed to nlminb
.
an egf_parallel
object defining options for R level
parallelization.
a logical. If TRUE
, then basic tracing messages indicating
progress are printed. These may be mixed with optimizer output
depending on object[["control"]][["trace"]]
.
additional arguments passed from or to other methods.
Bootstrap optimizations are typically expensive for nontrivial models.
They are parallelized at the C++ level when there is OpenMP
support and object[["control"]][["omp_num_threads"]]
is set
to an integer greater than 1. When there is no OpenMP support, they
can still be parallelized at the R level with appropriate setting
of argument parallel
.
Arguments control
, parallel
, and trace
are unused
when bootstrap = FALSE
.
The generic function simulate
.
example("egf", package = "epigrowthfit")
zz <- simulate(m2, nsim = 6L, seed = 181952L, bootstrap = TRUE)
str(zz)
matplot(t(zz[["bootstrap"]][!m2[["random"]], ]),
type = "o", las = 1, xlab = "simulation", ylab = "value")
Run the code above in your browser using DataLab