Learn R Programming

smooth (version 4.5.2)

simulate.om: Simulate methods for occurrence (om/omg) state-space models

Description

Re-simulates probabilities and occurrence indicators from a fitted om or omg model. The latent ETS is simulated via the shared C++ kernel (the same one simulate.adam uses), the latent series is mapped to a probability via omLinkFunction (or omgLinkFunction for omg), and a binomial draw with that probability gives the 0/1 occurrence series.

Usage

# S3 method for om
simulate(object, nsim = 1, seed = NULL, obs = nobs(object),
  ...)

# S3 method for omg simulate(object, nsim = 1, seed = NULL, obs = nobs(object), ...)

Value

An S3 list of class c("om.sim","oes.sim","smooth.sim")

(or c("omg.sim","oes.sim","smooth.sim") for omg) with fields:

$probability

Simulated probability series of shape (obs, nsim) -- the equivalent of sim.oes()'s $probability output.

$data

0/1 occurrence indicators of shape (obs, nsim), drawn via rbinom with the simulated probability.

$states, $residuals

Latent state cube and the errors used internally.

$model, $occurrence

Identifiers carried over from the fit.

$latent

Pre-link state-space output -- internal, used by simulate.omg to combine sub-models.

Arguments

object

An object of class om (or omg).

nsim

Number of simulated series to draw.

seed

Optional integer; forwarded to set.seed at the start of the simulation. Matches stats::simulate's generic signature. When NULL (default) the global RNG state is used unchanged.

obs

Number of observations per simulated series. Defaults to the in-sample length.

...

Currently unused; kept for forward compatibility.

Details

print() on the returned object dispatches to print.oes.sim via the inherited "oes.sim" class.

Examples

Run this code
if (FALSE) {
set.seed(7)
y <- rbinom(120, 1, prob=0.3 + 0.005*(1:120))
m <- om(y, model="MNN", occurrence="odds-ratio", silent=TRUE)
sim <- simulate(m, nsim=5, seed=42)
range(sim$probability)
table(sim$data)
}

Run the code above in your browser using DataLab