% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/bayesplot-extractors.R
\name{bayesplot-extractors}
\alias{bayesplot-extractors}
\alias{log_posterior}
\alias{nuts_params}
\alias{rhat}
\alias{neff_ratio}
\alias{log_posterior.stanfit}
\alias{log_posterior.stanreg}
\alias{log_posterior.CmdStanMCMC}
\alias{nuts_params.stanfit}
\alias{nuts_params.stanreg}
\alias{nuts_params.list}
\alias{nuts_params.CmdStanMCMC}
\alias{rhat.stanfit}
\alias{rhat.stanreg}
\alias{rhat.CmdStanMCMC}
\alias{neff_ratio.stanfit}
\alias{neff_ratio.stanreg}
\alias{neff_ratio.CmdStanMCMC}
\title{Extract quantities needed for plotting from model objects}
\usage{
log_posterior(object, ...)

nuts_params(object, ...)

rhat(object, ...)

neff_ratio(object, ...)

\method{log_posterior}{stanfit}(object, inc_warmup = FALSE, ...)

\method{log_posterior}{stanreg}(object, inc_warmup = FALSE, ...)

\method{log_posterior}{CmdStanMCMC}(object, inc_warmup = FALSE, ...)

\method{nuts_params}{stanfit}(object, pars = NULL, inc_warmup = FALSE, ...)

\method{nuts_params}{stanreg}(object, pars = NULL, inc_warmup = FALSE, ...)

\method{nuts_params}{list}(object, pars = NULL, ...)

\method{nuts_params}{CmdStanMCMC}(object, pars = NULL, ...)

\method{rhat}{stanfit}(object, pars = NULL, ...)

\method{rhat}{stanreg}(object, pars = NULL, regex_pars = NULL, ...)

\method{rhat}{CmdStanMCMC}(object, pars = NULL, ...)

\method{neff_ratio}{stanfit}(object, pars = NULL, ...)

\method{neff_ratio}{stanreg}(object, pars = NULL, regex_pars = NULL, ...)

\method{neff_ratio}{CmdStanMCMC}(object, pars = NULL, ...)
}
\arguments{
\item{object}{The object to use.}

\item{...}{Arguments passed to individual methods.}

\item{inc_warmup}{A logical scalar (defaulting to \code{FALSE}) indicating
whether to include warmup draws, if applicable.}

\item{pars}{An optional character vector of parameter names. For
\code{nuts_params()} these will be NUTS sampler parameter names rather than
model parameters. If \code{pars} is omitted all parameters are included.}

\item{regex_pars}{An optional \link[base:grep]{regular expression} to use for
parameter selection. Can be specified instead of \code{pars} or in addition to
\code{pars}. When using \code{pars} for tidy parameter selection, the \code{regex_pars}
argument is ignored since \link[tidyselect:language]{select helpers}
perform a similar function.}
}
\value{
\describe{
\item{\code{log_posterior()}}{
\code{log_posterior()} methods return a molten data frame (see \code{\link[reshape2:melt]{reshape2::melt()}}).
The data frame should have columns \code{"Iteration"} (integer), \code{"Chain"}
(integer), and \code{"Value"} (numeric). See \strong{Examples}, below.
}
\item{\code{nuts_params()}}{
\code{nuts_params()} methods return a molten data frame (see \code{\link[reshape2:melt]{reshape2::melt()}}).
The data frame should have columns \code{"Parameter"} (factor), \code{"Iteration"}
(integer), \code{"Chain"} (integer), and \code{"Value"} (numeric). See \strong{Examples}, below.
}
\item{\code{rhat()}, \code{neff_ratio()}}{
Methods return (named) vectors.
}
}
}
\description{
Generics and methods for extracting quantities needed for plotting from
various types of model objects. Currently methods are provided for stanfit
(\strong{rstan}), CmdStanMCMC (\strong{cmdstanr}), and stanreg (\strong{rstanarm}) objects,
but adding new methods should be relatively straightforward.
}
\examples{
\dontrun{
library(rstanarm)
fit <- stan_glm(mpg ~ wt, data = mtcars, refresh = 0)

np <- nuts_params(fit)
head(np)
tail(np)

lp <- log_posterior(fit)
head(lp)
tail(lp)
}

}
\seealso{
\link{MCMC-nuts}, \link{MCMC-diagnostics}
}
