
Simulate new responses from a fitted gllvmTMB model
Source:R/methods-gllvmTMB.R
simulate.gllvmTMB_multi.RdDraws nsim new response vectors from a fitted model. By default
(condition_on_RE = FALSE) the random effects are redrawn from the
fitted covariance and the response is drawn from the fitted family — the
unconditional simulation appropriate for a parametric bootstrap. Redraw is
not implemented for every tier; a fit using an unhandled tier falls back to
conditional simulation with a warning, and intervals derived from it are too
narrow. Set condition_on_RE = TRUE for the older conditional behaviour,
which reuses the fitted random-effect modes and only adds residual noise.
Usage
# S3 method for class 'gllvmTMB_multi'
simulate(
object,
nsim = 1,
seed = NULL,
newdata = NULL,
condition_on_RE = FALSE,
...
)Arguments
- object
A fit returned by
gllvmTMB().- nsim
Number of replicate response vectors to draw. Default 1.
- seed
Optional RNG seed.
- newdata
Optional new data frame; if supplied, predictions are computed at
newdataand noise is drawn around them. The newdata must contain enough columns to rebuild the fixed-effects design and any random-effect grouping that was active.- condition_on_RE
Logical (default
FALSE). WhenFALSE(the default), random effects are redrawn from the fitted covariance — the unconditional simulation appropriate for parametric bootstrap. Redraw is currently implemented for therr_B,diag_B,rr_W,diag_W,propto,lv_B,phylo_rr, anddiag_speciestiers.Not every tier is covered. A fit using any other active tier — notably the SPDE spatial tier (
spde) and the diagonal phylogenetic tier (phylo_diag) — falls back to conditional simulation and emits a one-shot warning naming the unhandled tiers. Because conditional simulation reuses the fitted random- effect modes rather than redrawing them, it understates between-unit variability: intervals derived from it (for example viabootstrap_Sigma()) are too narrow and should not be read as calibrated. Treat the warning as a signal that simulate-based uncertainty is not trustworthy for that fit.When
TRUE, the existing fitted RE modes are reused (the older glmmTMB-style conditional simulation that only adds Gaussian noise on top offit$report$eta). Forced toTRUEwhennewdatais supplied (RE modes for unseen levels cannot be redrawn).- ...
Currently unused.