Compute simulated draws of parameters and their related indices such as Confidence Intervals (CI) and p-values. Simulating parameter draws can be seen as a (computationally faster) alternative to bootstrapping.
Usage
simulate_parameters(model, ...)
# Default S3 method
simulate_parameters(
model,
iterations = 1000,
centrality = "median",
ci = 0.95,
ci_method = "quantile",
test = "p-value",
...
)
Arguments
- model
Statistical model (no Bayesian models).
- ...
Arguments passed to
insight::get_varcov()
, e.g. to allow simulated draws to be based on heteroscedasticity consistent variance covariance matrices.- iterations
The number of draws to simulate/bootstrap.
- centrality
The point-estimates (centrality indices) to compute. Character (vector) or list with one or more of these options:
"median"
,"mean"
,"MAP"
(seemap_estimate()
),"trimmed"
(which is justmean(x, trim = threshold)
),"mode"
or"all"
.- ci
Value or vector of probability of the CI (between 0 and 1) to be estimated. Default to
0.95
(95%
).- ci_method
The type of index used for Credible Interval. Can be
"ETI"
(default, seeeti()
),"HDI"
(seehdi()
),"BCI"
(seebci()
),"SPI"
(seespi()
), or"SI"
(seesi()
).- test
The indices of effect existence to compute. Character (vector) or list with one or more of these options:
"p_direction"
(or"pd"
),"rope"
,"p_map"
,"equivalence_test"
(or"equitest"
),"bayesfactor"
(or"bf"
) or"all"
to compute all tests. For each "test", the corresponding bayestestR function is called (e.g.rope()
orp_direction()
) and its results included in the summary output.
Details
Technical Details
simulate_parameters()
is a computationally faster alternative
to bootstrap_parameters()
. Simulated draws for coefficients are based
on a multivariate normal distribution (MASS::mvrnorm()
) with mean
mu = coef(model)
and variance Sigma = vcov(model)
.
Models with Zero-Inflation Component
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.
Note
There is also a plot()
-method implemented in the see-package.
References
Gelman A, Hill J. Data analysis using regression and multilevel/hierarchical models. Cambridge; New York: Cambridge University Press 2007: 140-143
Examples
model <- lm(Sepal.Length ~ Species * Petal.Width + Petal.Length, data = iris)
simulate_parameters(model)
#> # Fixed Effects
#>
#> Parameter | Coefficient | 95% CI | p
#> ---------------------------------------------------------------------
#> (Intercept) | 3.53 | [ 3.21, 3.84] | < .001
#> Speciesversicolor | -1.15 | [-1.85, -0.46] | < .001
#> Speciesvirginica | -2.26 | [-3.13, -1.44] | < .001
#> Petal.Width | 0.40 | [-0.40, 1.34] | 0.358
#> Petal.Length | 0.94 | [ 0.79, 1.09] | < .001
#> Speciesversicolor:Petal.Width | -0.75 | [-1.82, 0.25] | 0.142
#> Speciesvirginica:Petal.Width | -0.34 | [-1.36, 0.47] | 0.436
#>
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed)
#> computed using a simulated multivariate normal distribution
#> approximation.
# \donttest{
if (require("glmmTMB", quietly = TRUE)) {
model <- glmmTMB(
count ~ spp + mined + (1 | site),
ziformula = ~mined,
family = poisson(),
data = Salamanders
)
simulate_parameters(model, centrality = "mean")
simulate_parameters(model, ci = c(.8, .95), component = "zero_inflated")
}
#> # Fixed Effects
#>
#> Parameter | Coefficient | 80% CI | 95% CI | p
#> --------------------------------------------------------------------
#> (Intercept) | 0.81 | [ 0.44, 1.16] | [ 0.25, 1.35] | 0.006
#> minedno | -1.85 | [-2.27, -1.43] | [-2.45, -1.23] | < .001
#>
#> Uncertainty intervals (equal-tailed) and p-values (two-tailed)
#> computed using a MCMC distribution approximation.
# }