simulate {pomp}R Documentation

Simulations of a partially-observed Markov process

Description

simulate generates simulations of the state and measurement processes.

Usage

## S4 method for signature 'missing'
simulate(
  nsim = 1,
  seed = NULL,
  times,
  t0,
  params,
  rinit,
  rprocess,
  rmeasure,
  format = c("pomps", "arrays", "data.frame"),
  include.data = FALSE,
  ...,
  verbose = getOption("verbose", FALSE)
)

## S4 method for signature 'data.frame'
simulate(
  object,
  nsim = 1,
  seed = NULL,
  times,
  t0,
  params,
  rinit,
  rprocess,
  rmeasure,
  format = c("pomps", "arrays", "data.frame"),
  include.data = FALSE,
  ...,
  verbose = getOption("verbose", FALSE)
)

## S4 method for signature 'pomp'
simulate(
  object,
  nsim = 1,
  seed = NULL,
  format = c("pomps", "arrays", "data.frame"),
  include.data = FALSE,
  ...,
  verbose = getOption("verbose", FALSE)
)

## S4 method for signature 'objfun'
simulate(object, nsim = 1, seed = NULL, ...)

Arguments

nsim

The number of simulations to perform. Note that the number of replicates will be nsim times ncol(params).

seed

optional integer; if set, the pseudorandom number generator (RNG) will be initialized with seed. The RNG will be restored to its original state afterward.

times

the sequence of observation times. times must indicate the column of observation times by name or index. The time vector must be numeric and non-decreasing.

t0

The zero-time, i.e., the time of the initial state. This must be no later than the time of the first observation, i.e., t0 <= times[1].

params

a named numeric vector or a matrix with rownames containing the parameters at which the simulations are to be performed.

rinit

simulator of the initial-state distribution. This can be furnished either as a C snippet, an R function, or the name of a pre-compiled native routine available in a dynamically loaded library. Setting rinit=NULL sets the initial-state simulator to its default. For more information, see rinit specification.

rprocess

simulator of the latent state process, specified using one of the rprocess plugins. Setting rprocess=NULL removes the latent-state simulator. For more information, see rprocess specification for the documentation on these plugins.

rmeasure

simulator of the measurement model, specified either as a C snippet, an R function, or the name of a pre-compiled native routine available in a dynamically loaded library. Setting rmeasure=NULL removes the measurement model simulator. For more information, see rmeasure specification.

format

the format in which to return the results.

format = "pomps" causes the results to be returned as a single “pomp” object, if params is a vector, or a list of “pomp” objects, if params is a matrix with more than one column. Each of these will be identical to object except in that the latent states and observations will have been replaced by their simulated values.

format = "arrays" causes the results to be returned as a list of two arrays. The “states” element will contain the simulated state trajectories in a rank-3 array with dimensions nvar x (ncol(params)*nsim) x ntimes. Here, nvar is the number of state variables and ntimes the length of the argument times. The “obs” element will contain the simulated data, returned as a rank-3 array with dimensions nobs x (ncol(params)*nsim) x ntimes. Here, nobs is the number of observables.

format = "data.frame" causes the results to be returned as a single data frame containing the time, states, and observations. An ordered factor variable, ‘.id’, distinguishes one simulation from another.

include.data

if TRUE, the original data and covariates (if any) are included (with .id = "data"). This option is ignored unless format = "data.frame".

...

additional arguments are passed to pomp.

verbose

logical; if TRUE, diagnostic messages will be printed to the console.

object

optional; if present, it should be a data frame or a ‘pomp’ object.

Value

A single “pomp” object, a “pompList” object, a named list of two arrays, or a data frame, according to the format option.

If params is a matrix, each column is treated as a distinct parameter set. In this case, if nsim=1, then simulate will return one simulation for each parameter set. If nsim>1, then simulate will yield nsim simulations for each parameter set. These will be ordered such that the first ncol(params) simulations represent one simulation from each of the distinct parameter sets, the second ncol(params) simulations represent a second simulation from each, and so on.

Adding column names to params can be helpful.

Note for Windows users

Some Windows users report problems when using C snippets in parallel computations. These appear to arise when the temporary files created during the C snippet compilation process are not handled properly by the operating system. To circumvent this problem, use the cdir and cfile options to cause the C snippets to be written to a file of your choice, thus avoiding the use of temporary files altogether.

Author(s)

Aaron A. King

See Also

More on pomp elementary algorithms: elementary_algorithms, kalman, pfilter(), pomp-package, probe(), spect(), trajectory(), wpfilter()


[Package pomp version 5.11.0.0 Index]