-
-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathbayesplot-extractors.Rd
116 lines (93 loc) · 3.57 KB
/
bayesplot-extractors.Rd
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
% 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}
}