Skip to content

Commit d2d8544

Browse files
committed
Document all *_data() functions (#209)
1 parent 7195e72 commit d2d8544

27 files changed

+235
-5
lines changed

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# bayesplot (development version)
22

3-
* Documentation added for `ppc_data()` and `ppc_loo_pit_data()` functions (#209)
3+
* Documentation added for all exported `*_data()` functions (#209)
44
* Improved documentation for `binwidth`, `bins`, and `breaks` arguments to clarify they are passed to `ggplot2::geom_area()` and `ggdist::stat_dots()` in addition to `ggplot2::geom_histogram()`
55
* Improved documentation for `freq` argument to clarify it applies to frequency polygons in addition to histograms
66
* Fixed test in `test-ppc-distributions.R` that incorrectly used `ppc_dens()` instead of `ppd_dens()` when testing PPD functions

R/mcmc-diagnostics.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@
1818
#'
1919
#' @section Plot Descriptions:
2020
#' \describe{
21+
#' \item{`mcmc_rhat_data()`}{
22+
#' Data-preparation back end for `mcmc_rhat()` and `mcmc_rhat_hist()`.
23+
#' Users can call `mcmc_rhat_data()` directly to obtain the data frame of
24+
#' Rhat values with rating labels and create custom Rhat diagnostic
25+
#' visualizations with **ggplot2**.
26+
#' }
27+
#'
28+
#' \item{`mcmc_neff_data()`}{
29+
#' Data-preparation back end for `mcmc_neff()` and `mcmc_neff_hist()`.
30+
#' Users can call `mcmc_neff_data()` directly to obtain the data frame of
31+
#' effective-sample-size ratios with rating labels and create custom Neff
32+
#' diagnostic visualizations with **ggplot2**.
33+
#' }
34+
#'
2135
#' \item{`mcmc_rhat()`, `mcmc_rhat_hist()`}{
2236
#' Rhat values as either points or a histogram. Values are colored using
2337
#' different shades (lighter is better). The chosen thresholds are somewhat

R/mcmc-distributions.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@
1515
#' @param ... For dot plots, optional additional arguments to pass to [ggdist::stat_dots()].
1616
#' @param alpha Passed to the geom to control the transparency.
1717
#'
18-
#' @template return-ggplot
18+
#' @template return-ggplot-or-data
1919
#'
2020
#' @section Plot Descriptions:
2121
#' \describe{
22+
#' \item{`mcmc_dens_chains_data()`}{
23+
#' Data-preparation back end for `mcmc_dens_chains()`. Users can call
24+
#' `mcmc_dens_chains_data()` directly to obtain the prepared long-format
25+
#' data frame of MCMC draws (with chain information retained) and create
26+
#' custom ridgeline density visualizations with **ggplot2**.
27+
#' }
2228
#' \item{`mcmc_hist()`}{
2329
#' Histograms of posterior draws with all chains merged.
2430
#' }

R/mcmc-intervals.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@
3838
#'
3939
#' @section Plot Descriptions:
4040
#' \describe{
41+
#' \item{`mcmc_intervals_data()`, `mcmc_areas_data()`, `mcmc_areas_ridges_data()`}{
42+
#' Data-preparation back ends for `mcmc_intervals()`, `mcmc_areas()`, and
43+
#' `mcmc_areas_ridges()`, respectively. Users can call these functions
44+
#' directly to obtain the prepared data frames of posterior interval
45+
#' summaries and create custom interval or density-area visualizations
46+
#' with **ggplot2**.
47+
#' }
4148
#' \item{`mcmc_intervals()`}{
4249
#' Plots of uncertainty intervals computed from posterior draws with all
4350
#' chains merged.

R/mcmc-parcoord.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
#'
3030
#' @section Plot Descriptions:
3131
#' \describe{
32+
#' \item{`mcmc_parcoord_data()`}{
33+
#' Data-preparation back end for `mcmc_parcoord()`. Users can call
34+
#' `mcmc_parcoord_data()` directly to obtain the prepared long-format data
35+
#' frame of MCMC draws (with optional NUTS diagnostic information) and
36+
#' create custom parallel coordinates visualizations with **ggplot2**.
37+
#' }
3238
#' \item{`mcmc_parcoord()`}{
3339
#' [Parallel coordinates plot](https://en.wikipedia.org/wiki/Parallel_coordinates)
3440
#' of MCMC draws. There is one dimension per parameter along the horizontal

R/mcmc-traces.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@
4545
#'
4646
#' @section Plot Descriptions:
4747
#' \describe{
48+
#' \item{`mcmc_trace_data()`}{
49+
#' Data-preparation back end for `mcmc_trace()`, `mcmc_trace_highlight()`,
50+
#' `mcmc_rank_hist()`, `mcmc_rank_overlay()`, and `mcmc_rank_ecdf()`. The
51+
#' returned data frame contains columns for both the original draw values
52+
#' and their within-parameter ranks, so it can be used to build both trace
53+
#' and rank-based visualizations with **ggplot2**.
54+
#' }
4855
#' \item{`mcmc_trace()`}{
4956
#' Standard trace plots of MCMC draws. For models fit using [NUTS],
5057
#' the `np` argument can be used to also show divergences on the trace plot.

R/ppc-discrete.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
#'
3838
#' @section Plot Descriptions:
3939
#' \describe{
40+
#' \item{`ppc_bars_data()`}{
41+
#' Data-preparation back end for `ppc_bars()` and `ppc_bars_grouped()`.
42+
#' Users can call `ppc_bars_data()` directly to obtain the prepared data
43+
#' frame and create custom bar chart visualizations with **ggplot2**.
44+
#' }
4045
#' \item{`ppc_bars()`}{
4146
#' Bar plot of `y` with `yrep` medians and uncertainty intervals
4247
#' superimposed on the bars.

R/ppc-errors.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
#'
3434
#' @section Plot descriptions:
3535
#' \describe{
36+
#' \item{`ppc_error_data()`}{
37+
#' Data-preparation back end for the `ppc_error_*()` family of plotting
38+
#' functions. Users can call `ppc_error_data()` directly to obtain the
39+
#' data frame of predictive errors (`y - yrep`) and create custom error
40+
#' visualizations with **ggplot2**.
41+
#' }
3642
#' \item{`ppc_error_hist()`}{
3743
#' A separate histogram is plotted for the predictive errors computed from
3844
#' `y` and each dataset (row) in `yrep`. For this plot `yrep` should have
@@ -69,7 +75,7 @@
6975
#' }
7076
#' }
7177
#'
72-
#' @template return-ggplot
78+
#' @template return-ggplot-or-data
7379
#'
7480
#' @templateVar bdaRef (Ch. 6)
7581
#' @template reference-bda

R/ppc-intervals.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
#'
3434
#' @section Plot Descriptions:
3535
#' \describe{
36+
#' \item{`ppc_intervals_data()`, `ppc_ribbon_data()`}{
37+
#' Data-preparation back end for `ppc_intervals()`, `ppc_ribbon()`, and
38+
#' their grouped variants. `ppc_ribbon_data()` is an alias for
39+
#' `ppc_intervals_data()`. Users can call either function directly to
40+
#' obtain the prepared data frame and create custom interval or ribbon
41+
#' visualizations with **ggplot2**.
42+
#' }
3643
#' \item{`ppc_intervals(), ppc_ribbon()`}{
3744
#' `100*prob`% central intervals for `yrep` at each `x`
3845
#' value. `ppc_intervals()` plots intervals as vertical bars with points

R/ppc-scatterplots.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
#'
3030
#' @section Plot Descriptions:
3131
#' \describe{
32+
#' \item{`ppc_scatter_data()`, `ppc_scatter_avg_data()`}{
33+
#' Data-preparation back ends for the `ppc_scatter*()` family of plotting
34+
#' functions. `ppc_scatter_data()` returns a data frame with one row per
35+
#' observation per `yrep` draw, while `ppc_scatter_avg_data()` returns a
36+
#' data frame with one row per observation summarising `yrep` draws with
37+
#' the chosen `stat`. Users can call these functions directly to create
38+
#' custom scatterplot visualizations with **ggplot2**.
39+
#' }
3240
#' \item{`ppc_scatter()`}{
3341
#' For each dataset (row) in `yrep` a scatterplot is generated showing `y`
3442
#' against that row of `yrep`. For this plot `yrep` should only contain a

0 commit comments

Comments
 (0)