simulate.egf {epigrowthfit}R Documentation

Simulation and Parametric Bootstrapping

Description

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.

Usage

## S3 method for class 'egf'
simulate(object, nsim = 1, seed = NULL,
         bootstrap = FALSE,
         control = list(), parallel = egf_parallel(),
         trace = FALSE, ...)

Arguments

object

an egf object.

nsim

a positive integer indicating a number of replications.

seed

an integer used to set the RNG state before simulation or, otherwise, NULL; see simulate.

bootstrap

a logical. If TRUE, then a bootstrapping step is performed.

control

passed to nlminb.

parallel

an egf_parallel object defining options for R level parallelization.

trace

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.

Details

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.

Value

A list inheriting from class simulate.egf, with elements:

simulation

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).

bootstrap

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.

See Also

The generic function simulate.

Examples

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")

[Package epigrowthfit version 0.15.3 Index]