insight (version 0.11.0)

get_parameters: Get model parameters

Description

Returns the coefficients (or posterior samples for Bayesian models) from a model.

Usage

get_parameters(x, ...)

# S3 method for betamfx get_parameters( x, component = c("all", "conditional", "precision", "marginal"), ... )

# S3 method for logitmfx get_parameters(x, component = c("all", "conditional", "marginal"), ...)

# S3 method for emmGrid get_parameters(x, summary = FALSE, merge_parameters = FALSE, ...)

# S3 method for averaging get_parameters(x, component = c("conditional", "full"), ...)

# S3 method for betareg get_parameters(x, component = c("all", "conditional", "precision"), ...)

# S3 method for DirichletRegModel get_parameters(x, component = c("all", "conditional", "precision"), ...)

# S3 method for clm2 get_parameters(x, component = c("all", "conditional", "scale"), ...)

# S3 method for coxme get_parameters(x, effects = c("fixed", "random"), ...)

# S3 method for merMod get_parameters(x, effects = c("fixed", "random"), ...)

# S3 method for mixed get_parameters(x, effects = c("fixed", "random"), ...)

# S3 method for glmmTMB get_parameters( x, effects = c("fixed", "random"), component = c("all", "conditional", "zi", "zero_inflated", "dispersion"), ... )

# S3 method for BBmm get_parameters(x, effects = c("fixed", "random"), ...)

# S3 method for glimML get_parameters(x, effects = c("fixed", "random", "all"), ...)

# S3 method for gam get_parameters(x, component = c("all", "conditional", "smooth_terms"), ...)

# S3 method for zeroinfl get_parameters( x, component = c("all", "conditional", "zi", "zero_inflated"), ... )

# S3 method for zcpglm get_parameters( x, component = c("all", "conditional", "zi", "zero_inflated"), ... )

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

# 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 = c("fixed", "random", "all"), component = c("all", "conditional", "zi", "zero_inflated", "dispersion", "simplex", "sigma", "smooth_terms"), parameters = NULL, summary = FALSE, centrality = "mean", ... )

# S3 method for stanreg get_parameters( x, effects = c("fixed", "random", "all"), 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", ... )

Arguments

x

A fitted model.

...

Currently not used.

component

Should all parameters, 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.

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.

merge_parameters

Logical, if TRUE and x has multiple columns for parameter names (like emmGrid objects may have), these are merged into a single parameter column, with parameters names and values as values.

effects

Should parameters for fixed effects, random effects or both be returned? Only applies to mixed models. May be abbreviated.

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.

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

  • for non-Bayesian models and if effects = "fixed", a data frame with two columns: the parameter names and the related point estimates

  • if effects = "random", a list of data frames with the random effects (as returned by ranef()), unless the random effects have the same simplified structure as fixed effects (e.g. for models from MCMCglmm)

  • for Bayesian models, the posterior samples from the requested parameters as data frame

  • for Anova (aov()) with error term, a list of parameters for the conditional and the random effects parameters

  • for models with smooth terms or zero-inflation component, a data frame with three columns: the parameter names, the related point estimates and the component

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

get_parameters() is comparable to coef(), however, the coefficients are returned as data frame (with columns for names and point estimates of coefficients). For Bayesian models, the posterior samples of parameters are returned.

Examples

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

Run the code above in your browser using DataLab