Learn R Programming

insight (version 0.18.6)

get_parameters.BGGM: Get model parameters from Bayesian models

Description

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", ...)

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).

Arguments

x

A fitted model.

component

Which type of parameters to return, such as parameters for the conditional model, the zero-inflated part of the model, the dispersion term, the instrumental variables or marginal effects be returned? Applies to models with zero-inflated and/or dispersion formula, or to models with instrumental variables (so called fixed-effects regressions), or models with marginal effects from mfx. May be abbreviated. Note that the conditional component is also called count or mean component, depending on the model. There are three convenient shortcuts: component = "all" returns all possible parameters. If component = "location", location parameters such as conditional, zero_inflated, smooth_terms, or instruments are returned (everything that are fixed or random effects - depending on the effects argument - but no auxiliary parameters). For component = "distributional" (or "auxiliary"), components like sigma, dispersion, beta or precision (and other auxiliary parameters) are returned.

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, while centrality = "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.

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().

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.

Examples

Run this code
data(mtcars)
m <- lm(mpg ~ wt + cyl + vs, data = mtcars)
get_parameters(m)

Run the code above in your browser using DataLab