Compute indices relevant to describe and characterize the posterior distributions.
describe_posterior( posteriors, centrality = "median", dispersion = FALSE, ci = 0.89, ci_method = "hdi", test = c("p_direction", "rope"), rope_range = "default", rope_ci = 0.89, ... ) # S3 method for numeric describe_posterior( posteriors, centrality = "median", dispersion = FALSE, ci = 0.89, ci_method = "hdi", test = c("p_direction", "rope"), rope_range = "default", rope_ci = 0.89, bf_prior = NULL, BF = 1, ... ) # S3 method for stanreg describe_posterior( posteriors, centrality = "median", dispersion = FALSE, ci = 0.89, ci_method = "hdi", test = c("p_direction", "rope"), rope_range = "default", rope_ci = 0.89, bf_prior = NULL, diagnostic = c("ESS", "Rhat"), priors = FALSE, effects = c("fixed", "random", "all"), parameters = NULL, BF = 1, ... ) # S3 method for stanmvreg describe_posterior( posteriors, centrality = "median", dispersion = FALSE, ci = 0.89, ci_method = "hdi", test = "p_direction", rope_range = "default", rope_ci = 0.89, bf_prior = NULL, diagnostic = c("ESS", "Rhat"), priors = FALSE, effects = c("fixed", "random", "all"), parameters = NULL, ... ) # S3 method for MCMCglmm describe_posterior( posteriors, centrality = "median", dispersion = FALSE, ci = 0.89, ci_method = "hdi", test = c("p_direction", "rope"), rope_range = "default", rope_ci = 0.89, diagnostic = "ESS", parameters = NULL, ... ) # S3 method for brmsfit describe_posterior( posteriors, centrality = "median", dispersion = FALSE, ci = 0.89, ci_method = "hdi", test = c("p_direction", "rope"), rope_range = "default", rope_ci = 0.89, bf_prior = NULL, diagnostic = c("ESS", "Rhat"), effects = c("fixed", "random", "all"), component = c("conditional", "zi", "zero_inflated", "all"), parameters = NULL, BF = 1, ... ) # S3 method for BFBayesFactor describe_posterior( posteriors, centrality = "median", dispersion = FALSE, ci = 0.89, ci_method = "hdi", test = c("p_direction", "rope", "bf"), rope_range = "default", rope_ci = 0.89, priors = TRUE, ... )
| posteriors | A vector, data frame or model of posterior draws. |
|---|---|
| centrality | The point-estimates (centrality indices) to compute. Character (vector) or list with one or more of these options: |
| dispersion | Logical, if |
| ci | Value or vector of probability of the CI (between 0 and 1)
to be estimated. Default to |
| ci_method | The type of index used for Credible Interval. Can be
|
| test | The indices of effect existence to compute. Character (vector) or
list with one or more of these options: |
| rope_range | ROPE's lower and higher bounds. Should be a list of two
values (e.g., |
| rope_ci | The Credible Interval (CI) probability, corresponding to the proportion of HDI, to use for the percentage in ROPE. |
| ... | Additional arguments to be passed to or from methods. |
| bf_prior | Distribution representing a prior for the computation of Bayes factors / SI. Used if the input is a posterior, otherwise (in the case of models) ignored. |
| BF | The amount of support required to be included in the support interval. |
| diagnostic | Diagnostic metrics to compute. Character (vector) or list with one or more of these options: |
| priors | Add the prior used for each parameter. |
| effects | Should results for fixed effects, random effects or both be returned? Only applies to mixed models. May be abbreviated. |
| parameters | Regular expression pattern that describes the parameters that
should be returned. Meta-parameters (like |
| component | Should results for all parameters, parameters for the conditional model or the zero-inflated part of the model be returned? May be abbreviated. Only applies to brms-models. |
One or more components of point estimates (like posterior mean or median),
intervals and tests can be omitted from the summary output by setting the
related argument to NULL. For example, test = NULL and
centrality = NULL would only return the HDI (or CI).
#> # Description of Posterior Distributions #> #> Parameter | Median | 89% CI | pd | 89% ROPE | % in ROPE #> --------------------------------------------------------------------------- #> Posterior | 0.033 | [-1.542, 1.553] | 51.80% | [-0.100, 0.100] | 8.642 #>describe_posterior(x, centrality = "all", dispersion = TRUE, test = "all")#> Warning: Prior not specified! Please specify a prior (in the form 'prior = distribution_normal(1000, 0, 1)') to get meaningful results.#> # Description of Posterior Distributions #> #> Parameter | Median | MAD | Mean | SD | MAP | 89% CI | p_map | pd | p_ROPE | ps | 89% ROPE | % in ROPE | ROPE_Equivalence | BF #> ------------------------------------------------------------------------------------------------------------------------------------------------------------- #> Posterior | 0.033 | 1.030 | 0.040 | 0.985 | -0.004 | [-1.542, 1.553] | 1.000 | 51.80% | 0.077 | 0.472 | [-0.100, 0.100] | 8.642 | Undecided | 1 #>#> # Description of Posterior Distributions #> #> Parameter | Median | CI | pd | 89% ROPE | % in ROPE #> ---------------------------------------------------------------------------------- #> Posterior | 0.033 | 80% CI [-1.285, 1.205] | 51.80% | [-0.100, 0.100] | 8.642 #> Posterior | 0.033 | 90% CI [-1.624, 1.559] | 51.80% | [-0.100, 0.100] | 8.642 #>#> # Description of Posterior Distributions #> #> Parameter | Median | 89% CI | pd | 89% ROPE | % in ROPE #> --------------------------------------------------------------------------- #> X1 | 0.066 | [-1.510, 1.272] | 51.00% | [-0.100, 0.100] | 4.444 #> X2 | 0.128 | [-1.592, 1.321] | 51.00% | [-0.100, 0.100] | 4.444 #> X3 | -0.072 | [-2.005, 1.201] | 54.00% | [-0.100, 0.100] | 10.000 #> X4 | 0.118 | [-1.241, 1.491] | 57.00% | [-0.100, 0.100] | 7.778 #>describe_posterior(df, centrality = "all", dispersion = TRUE, test = "all")#> Warning: Prior not specified! Please specify priors (with column order matching 'posterior') to get meaningful results.#> # Description of Posterior Distributions #> #> Parameter | Median | MAD | Mean | SD | MAP | 89% CI | p_MAP | pd | p_ROPE | ps | 89% ROPE | % in ROPE | ROPE_Equivalence | BF #> -------------------------------------------------------------------------------------------------------------------------------------------------------------- #> X1 | 0.066 | 0.953 | -0.030 | 0.920 | 0.242 | [-1.510, 1.272] | 0.962 | 51.00% | 0.040 | 0.500 | [-0.100, 0.100] | 4.444 | Undecided | 1 #> X2 | 0.128 | 1.094 | 0.101 | 1.024 | -0.062 | [-1.592, 1.321] | 0.999 | 51.00% | 0.040 | 0.510 | [-0.100, 0.100] | 4.444 | Undecided | 1 #> X3 | -0.072 | 0.937 | -0.165 | 0.988 | 0.108 | [-2.005, 1.201] | 0.991 | 54.00% | 0.090 | 0.490 | [-0.100, 0.100] | 10.000 | Undecided | 1 #> X4 | 0.118 | 1.007 | 0.137 | 0.914 | 0.577 | [-1.241, 1.491] | 0.990 | 57.00% | 0.070 | 0.520 | [-0.100, 0.100] | 7.778 | Undecided | 1 #>#> # Description of Posterior Distributions #> #> Parameter | Median | CI | pd | 89% ROPE | % in ROPE #> ---------------------------------------------------------------------------------- #> X1 | 0.066 | 80% CI [-1.311, 0.876] | 51.00% | [-0.100, 0.100] | 4.444 #> X1 | 0.066 | 90% CI [-1.510, 1.385] | 51.00% | [-0.100, 0.100] | 4.444 #> X2 | 0.128 | 80% CI [-0.922, 1.321] | 51.00% | [-0.100, 0.100] | 4.444 #> X2 | 0.128 | 90% CI [-1.665, 1.321] | 51.00% | [-0.100, 0.100] | 4.444 #> X3 | -0.072 | 80% CI [-1.472, 0.992] | 54.00% | [-0.100, 0.100] | 10.000 #> X3 | -0.072 | 90% CI [-2.159, 1.089] | 54.00% | [-0.100, 0.100] | 10.000 #> X4 | 0.118 | 80% CI [-1.204, 1.085] | 57.00% | [-0.100, 0.100] | 7.778 #> X4 | 0.118 | 90% CI [-1.428, 1.473] | 57.00% | [-0.100, 0.100] | 7.778 #>if (FALSE) { # rstanarm models # ----------------------------------------------- if (require("rstanarm") && require("emmeans")) { model <- stan_glm(mpg ~ wt + gear, data = mtcars, chains = 2, iter = 200, refresh = 0) describe_posterior(model) describe_posterior(model, centrality = "all", dispersion = TRUE, test = "all") describe_posterior(model, ci = c(0.80, 0.90)) # emmeans estimates # ----------------------------------------------- describe_posterior(emtrends(model, ~1, "wt")) } # brms models # ----------------------------------------------- if (require("brms")) { model <- brms::brm(mpg ~ wt + cyl, data = mtcars) describe_posterior(model) describe_posterior(model, centrality = "all", dispersion = TRUE, test = "all") describe_posterior(model, ci = c(0.80, 0.90)) } # BayesFactor objects # ----------------------------------------------- if (require("BayesFactor")) { bf <- ttestBF(x = rnorm(100, 1, 1)) describe_posterior(bf) describe_posterior(bf, centrality = "all", dispersion = TRUE, test = "all") describe_posterior(bf, ci = c(0.80, 0.90)) } }