point_estimate: Point-estimates of posterior distributions In DominiqueMakowski/bayestestR: Understand and Describe Bayesian Models and Posterior Distributions

Description

Compute various point-estimates, such as the mean, the median or the MAP, to describe posterior distributions.

Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30``` ```point_estimate(x, centrality = "all", dispersion = FALSE, ...) ## S3 method for class 'numeric' point_estimate(x, centrality = "all", dispersion = FALSE, threshold = 0.1, ...) ## S3 method for class 'stanreg' point_estimate( x, centrality = "all", dispersion = FALSE, effects = c("fixed", "random", "all"), component = c("location", "all", "conditional", "smooth_terms", "sigma", "distributional", "auxiliary"), parameters = NULL, ... ) ## S3 method for class 'brmsfit' point_estimate( x, centrality = "all", dispersion = FALSE, effects = c("fixed", "random", "all"), component = c("conditional", "zi", "zero_inflated", "all"), parameters = NULL, ... ) ## S3 method for class 'BFBayesFactor' point_estimate(x, centrality = "all", dispersion = FALSE, ...) ```

Arguments

 `x` Vector representing a posterior distribution, or a data frame of such vectors. Can also be a Bayesian model (`stanreg`, `brmsfit`, `MCMCglmm`, `mcmc` or `bcplm`) or a `BayesFactor` model. `centrality` The point-estimates (centrality indices) to compute. Character (vector) or list with one or more of these options: `"median"`, `"mean"`, `"MAP"` or `"all"`. `dispersion` Logical, if `TRUE`, computes indices of dispersion related to the estimate(s) (`SD` and `MAD` for `mean` and `median`, respectively). `...` Additional arguments to be passed to or from methods. `threshold` For `centrality = "trimmed"` (i.e. trimmed mean), indicates the fraction (0 to 0.5) of observations to be trimmed from each end of the vector before the mean is computed. `effects` Should results for fixed effects, random effects or both be returned? Only applies to mixed models. May be abbreviated. `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. `parameters` Regular expression pattern that describes the parameters that should be returned. Meta-parameters (like `lp__` or `prior_`) are filtered by default, so only parameters that typically appear in the `summary()` are returned. Use `parameters` to select specific parameters for the output.

Note

There is also a `plot()`-method implemented in the see-package.

Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38``` ```library(bayestestR) point_estimate(rnorm(1000)) point_estimate(rnorm(1000), centrality = "all", dispersion = TRUE) point_estimate(rnorm(1000), centrality = c("median", "MAP")) df <- data.frame(replicate(4, rnorm(100))) point_estimate(df, centrality = "all", dispersion = TRUE) point_estimate(df, centrality = c("median", "MAP")) ## Not run: # rstanarm models # ----------------------------------------------- library(rstanarm) model <- rstanarm::stan_glm(mpg ~ wt + cyl, data = mtcars) point_estimate(model, centrality = "all", dispersion = TRUE) point_estimate(model, centrality = c("median", "MAP")) # emmeans estimates # ----------------------------------------------- library(emmeans) point_estimate(emtrends(model, ~1, "wt"), centrality = c("median", "MAP")) # brms models # ----------------------------------------------- library(brms) model <- brms::brm(mpg ~ wt + cyl, data = mtcars) point_estimate(model, centrality = "all", dispersion = TRUE) point_estimate(model, centrality = c("median", "MAP")) # BayesFactor objects # ----------------------------------------------- library(BayesFactor) bf <- ttestBF(x = rnorm(100, 1, 1)) point_estimate(bf, centrality = "all", dispersion = TRUE) point_estimate(bf, centrality = c("median", "MAP")) ## End(Not run) ```

DominiqueMakowski/bayestestR documentation built on July 27, 2021, 4:12 p.m.