| bayesplot-extractors {bayesplot} | R Documentation |
Generics and methods for extracting quantities needed for plotting from various types of model objects. Currently methods are only provided for stanfit (rstan) and stanreg (rstanarm) objects, but adding new methods should be relatively straightforward.
log_posterior(object, ...) nuts_params(object, ...) rhat(object, ...) neff_ratio(object, ...) ## S3 method for class 'stanfit' log_posterior(object, inc_warmup = FALSE, ...) ## S3 method for class 'stanreg' log_posterior(object, inc_warmup = FALSE, ...) ## S3 method for class 'stanfit' nuts_params(object, pars = NULL, inc_warmup = FALSE, ...) ## S3 method for class 'stanreg' nuts_params(object, pars = NULL, inc_warmup = FALSE, ...) ## S3 method for class 'list' nuts_params(object, pars = NULL, ...) ## S3 method for class 'stanfit' rhat(object, pars = NULL, ...) ## S3 method for class 'stanreg' rhat(object, pars = NULL, regex_pars = NULL, ...) ## S3 method for class 'stanfit' neff_ratio(object, pars = NULL, ...) ## S3 method for class 'stanreg' neff_ratio(object, pars = NULL, regex_pars = NULL, ...)
object |
The object to use. |
... |
Arguments passed to individual methods. |
inc_warmup |
A logical scalar (defaulting to |
pars |
An optional character vector of parameter names. For
|
regex_pars |
An optional regular expression to use for
parameter selection. Can be specified instead of |
log_posteriorlog_posterior methods return a molten data frame (see
melt). The data frame should have columns
"Iteration" (integer), "Chain" (integer), and "Value"
(numeric). See Examples, below.
nuts_paramsnuts_params methods return a molten data frame (see
melt). The data frame should have columns
"Parameter" (factor), "Iteration" (integer), "Chain"
(integer), and "Value" (numeric). See Examples, below.
rhat, neff_ratioMethods return (named) vectors.
## Not run: library(rstanarm) fit <- stan_glm(mpg ~ wt, data = mtcars) np <- nuts_params(fit) head(np) tail(np) lp <- log_posterior(fit) head(lp) tail(lp) ## End(Not run)