
Get model parameters from Bayesian models
Source:R/get_parameters_bayesian.R
get_parameters.BGGM.Rd
Returns the coefficients (or posterior samples for Bayesian models) from a model.
Usage
# S3 method for BGGM
get_parameters(
x,
component = c("correlation", "conditional", "intercept", "all"),
summary = FALSE,
centrality = "mean",
...
)
# S3 method for MCMCglmm
get_parameters(
x,
effects = c("fixed", "random", "all"),
summary = FALSE,
centrality = "mean",
...
)
# S3 method for BFBayesFactor
get_parameters(
x,
effects = c("all", "fixed", "random"),
component = c("all", "extra"),
iterations = 4000,
progress = FALSE,
verbose = TRUE,
summary = FALSE,
centrality = "mean",
...
)
# S3 method for stanmvreg
get_parameters(
x,
effects = c("fixed", "random", "all"),
parameters = NULL,
summary = FALSE,
centrality = "mean",
...
)
# S3 method for brmsfit
get_parameters(
x,
effects = "fixed",
component = "all",
parameters = NULL,
summary = FALSE,
centrality = "mean",
...
)
# S3 method for stanreg
get_parameters(
x,
effects = c("fixed", "random", "all"),
component = c("location", "all", "conditional", "smooth_terms", "sigma",
"distributional", "auxiliary"),
parameters = NULL,
summary = FALSE,
centrality = "mean",
...
)
# S3 method for bayesx
get_parameters(
x,
component = c("conditional", "smooth_terms", "all"),
summary = FALSE,
centrality = "mean",
...
)
# S3 method for bamlss
get_parameters(
x,
component = c("all", "conditional", "smooth_terms", "location", "distributional",
"auxiliary"),
parameters = NULL,
summary = FALSE,
centrality = "mean",
...
)
# S3 method for sim.merMod
get_parameters(
x,
effects = c("fixed", "random", "all"),
parameters = NULL,
summary = FALSE,
centrality = "mean",
...
)
# S3 method for sim
get_parameters(x, parameters = NULL, summary = FALSE, centrality = "mean", ...)
Arguments
- x
A fitted model.
- component
Should all predictor variables, predictor variables for the conditional model, the zero-inflated part of the model, the dispersion term or the instrumental variables be returned? Applies to models with zero-inflated and/or dispersion formula, or to models with instrumental variable (so called fixed-effects regressions). May be abbreviated. Note that the conditional component is also called count or mean component, depending on the model.
- summary
Logical, indicates whether the full posterior samples (
summary = FALSE
)) or the summarized centrality indices of the posterior samples (summary = TRUE
)) should be returned as estimates.- centrality
Only for models with posterior samples, and when
summary = TRUE
. In this case,centrality = "mean"
would calculate means of posterior samples for each parameter, whilecentrality = "median"
would use the more robust median value as measure of central tendency.- ...
Currently not used.
- effects
Should parameters for fixed effects, random effects or both be returned? Only applies to mixed models. May be abbreviated.
- iterations
Number of posterior draws.
- progress
Display progress.
- verbose
Toggle messages and warnings.
- parameters
Regular expression pattern that describes the parameters that should be returned.
Value
The posterior samples from the requested parameters as data frame.
If summary = TRUE
, returns a data frame with two columns: the
parameter names and the related point estimates (based on centrality
).
Details
In most cases when models either return different "effects" (fixed,
random) or "components" (conditional, zero-inflated, ...), the arguments
effects
and component
can be used.
BFBayesFactor Models
Note that for BFBayesFactor
models (from the BayesFactor package),
posteriors are only extracted from the first numerator model (i.e.,
model[1]
). If you want to apply some function foo()
to another
model stored in the BFBayesFactor
object, index it directly, e.g.
foo(model[2])
, foo(1/model[5])
, etc.
See also bayestestR::weighted_posteriors()
.
Examples
data(mtcars)
m <- lm(mpg ~ wt + cyl + vs, data = mtcars)
get_parameters(m)
#> Parameter Estimate
#> 1 (Intercept) 38.7460642
#> 2 wt -3.2463673
#> 3 cyl -1.3641033
#> 4 vs 0.5241721