View source: R/5_simulate_model.R
simulate_model | R Documentation |
Simulate draws from a statistical model to return a data frame of estimates.
simulate_model(model, iterations = 1000, ...)
## S3 method for class 'glmmTMB'
simulate_model(
model,
iterations = 1000,
component = "all",
verbose = FALSE,
...
)
model |
Statistical model (no Bayesian models). |
iterations |
The number of draws to simulate/bootstrap. |
... |
Arguments passed to |
component |
Should all parameters, parameters for the conditional model,
for the zero-inflation part of the model, or the dispersion model be returned?
Applies to models with zero-inflation and/or dispersion component. |
verbose |
Toggle warnings and messages. |
simulate_model()
is a computationally faster alternative
to bootstrap_model()
. Simulated draws for coefficients are based
on a multivariate normal distribution (MASS::mvrnorm()
) with mean
mu = coef(model)
and variance Sigma = vcov(model)
.
For models from packages glmmTMB, pscl, GLMMadaptive and
countreg, the component
argument can be used to specify
which parameters should be simulated. For all other models, parameters
from the conditional component (fixed effects) are simulated. This may
include smooth terms, but not random effects.
A data frame.
simulate_parameters()
, bootstrap_model()
, bootstrap_parameters()
model <- lm(Sepal.Length ~ Species * Petal.Width + Petal.Length, data = iris)
head(simulate_model(model))
if (require("glmmTMB", quietly = TRUE)) {
model <- glmmTMB(
count ~ spp + mined + (1 | site),
ziformula = ~mined,
family = poisson(),
data = Salamanders
)
head(simulate_model(model))
head(simulate_model(model, component = "zero_inflated"))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.