Skip to content

Commit c817061

Browse files
authored
Merge pull request #426 from utkarshpawade/fix-209-ppc-data-docs
Add documentation for ppc_data and ppc_loo_pit_data
2 parents e1b1d92 + 5e61b03 commit c817061

25 files changed

+192
-10
lines changed

NEWS.md

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

3+
* Documentation added for all exported `*_data()` functions (#209)
34
* 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()`
45
* Improved documentation for `freq` argument to clarify it applies to frequency polygons in addition to histograms
56
* 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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
#'
1919
#' @section Plot Descriptions:
2020
#' \describe{
21+
#' \item{`mcmc_rhat_data()`, `mcmc_neff_data()`}{
22+
#' Data-preparation back ends for the R-hat and effective sample size plots.
23+
#' Users can call these functions directly to obtain the data frame of
24+
#' diagnostic values with rating labels and create custom diagnostic
25+
#' visualizations with **ggplot2**.
26+
#' }
27+
#'
2128
#' \item{`mcmc_rhat()`, `mcmc_rhat_hist()`}{
2229
#' Rhat values as either points or a histogram. Values are colored using
2330
#' 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,7 +15,7 @@
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{
@@ -48,6 +48,12 @@
4848
#' appear in separate facets; in `mcmc_dens_chains()` they appear in the
4949
#' same panel and can overlap vertically.
5050
#' }
51+
#' \item{`mcmc_dens_chains_data()`}{
52+
#' Data-preparation back end for `mcmc_dens_chains()`. Users can call this
53+
#' function directly to obtain the prepared long-format data frame of MCMC
54+
#' draws (with chain information retained) and create custom visualizations
55+
#' with **ggplot2**.
56+
#' }
5157
#' }
5258
#'
5359
#' @examples

R/mcmc-intervals.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@
5151
#' ridgelines. This plot provides a compact display of (hierarchically)
5252
#' related distributions.
5353
#' }
54+
#' \item{`mcmc_intervals_data()`, `mcmc_areas_data()`, `mcmc_areas_ridges_data()`}{
55+
#' Data-preparation back ends for `mcmc_intervals()`, `mcmc_areas()`, and
56+
#' `mcmc_areas_ridges()`, respectively. Users can call these functions
57+
#' directly to obtain the prepared data frames of posterior interval
58+
#' summaries and create custom interval or density-area visualizations
59+
#' with **ggplot2**.
60+
#' }
5461
#' }
5562
#'
5663
#' @examples

R/mcmc-parcoord.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848
#' when specifying the `transformations` argument to
4949
#' `mcmc_parcoord`. See the **Examples** section for how to do this.
5050
#' }
51+
#' \item{`mcmc_parcoord_data()`}{
52+
#' Data-preparation back end for `mcmc_parcoord()`. Users can call
53+
#' `mcmc_parcoord_data()` directly to obtain the prepared long-format data
54+
#' frame of MCMC draws (with optional NUTS diagnostic information) and
55+
#' create custom visualizations with **ggplot2**.
56+
#' }
5157
#' }
5258
#'
5359
#' @template reference-vis-paper

R/mcmc-traces.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@
7272
#' ECDFs and the theoretical expectation for samples originating from the
7373
#' same distribution is drawn. See Säilynoja et al. (2021) for details.
7474
#' }
75+
#' \item{`mcmc_trace_data()`}{
76+
#' Data-preparation back end for `mcmc_trace()`, `mcmc_trace_highlight()`,
77+
#' `mcmc_rank_hist()`, `mcmc_rank_overlay()`, and `mcmc_rank_ecdf()`. The
78+
#' returned data frame contains columns for both the original draw values
79+
#' and their within-parameter ranks, so it can be used to build both trace
80+
#' and rank-based visualizations with **ggplot2**.
81+
#' }
7582
#' }
7683
#'
7784
#' @template reference-improved-rhat

R/ppc-discrete.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
#' Same as `ppc_bars()` but a separate plot (facet) is generated for each
4646
#' level of a grouping variable.
4747
#' }
48+
#' \item{`ppc_bars_data()`}{
49+
#' Data-preparation back end for `ppc_bars()` and `ppc_bars_grouped()`.
50+
#' Users can call `ppc_bars_data()` directly to obtain the prepared data
51+
#' frame and create custom visualizations with **ggplot2**.
52+
#' }
4853
#' \item{`ppc_rootogram()`}{
4954
#' Rootograms allow for diagnosing problems in count data models such as
5055
#' overdispersion or excess zeros. In `standing`, `hanging`, and `suspended`

R/ppc-distributions.R

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#' \item{`ppc_dots()`}{
3232
#' A dot plot plot is displayed for `y` and each dataset (row) in `yrep`.
3333
#' For these plots `yrep` should therefore contain only a small number of rows.
34-
#' See the **Examples** section. This function requires [ggdist::stat_dots] to be installed.
34+
#' See the **Examples** section.
3535
#' }
3636
#' \item{`ppc_freqpoly_grouped()`}{
3737
#' A separate frequency polygon is plotted for each level of a grouping
@@ -59,7 +59,16 @@
5959
#' confidence intervals are provided to asses if `y` and `yrep` originate
6060
#' from the same distribution. The PIT values can also be provided directly
6161
#' as `pit`.
62-
#' See Säilynoja et al. (2021) for more details.}
62+
#' See Säilynoja et al. (2021) for more details.
63+
#' }
64+
#' \item{`ppc_data()`}{
65+
#' This function prepares data for plotting with **ggplot2** and doesn't
66+
#' itself make any plots. Users can call it directly to obtain the underlying
67+
#' data frame that (in most cases) is passed to **ggplot2**. This is useful
68+
#' when you want to customize the appearance of PPC plots beyond what the
69+
#' built-in plotting functions allow, or when you want to construct new types
70+
#' of PPC visualizations based on the same underlying data.
71+
#' }
6372
#' }
6473
#'
6574
#' @template reference-vis-paper

R/ppc-errors.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,15 @@
6767
#' this plot `y` and `yrep` should contain proportions rather than counts,
6868
#' and `yrep` should have only a small number of rows.
6969
#' }
70+
#' \item{`ppc_error_data()`}{
71+
#' Data-preparation back end for the `ppc_error_*()` family of plotting
72+
#' functions. Users can call `ppc_error_data()` directly to obtain the
73+
#' data frame of predictive errors (`y - yrep`) and create custom error
74+
#' visualizations with **ggplot2**.
75+
#' }
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
@@ -50,6 +50,13 @@
5050
#' Same as `ppc_intervals()` and `ppc_ribbon()`, respectively, but a
5151
#' separate plot (facet) is generated for each level of a grouping variable.
5252
#' }
53+
#' \item{`ppc_intervals_data()`, `ppc_ribbon_data()`}{
54+
#' Data-preparation back end for `ppc_intervals()`, `ppc_ribbon()`, and
55+
#' their grouped variants. `ppc_ribbon_data()` is an alias for
56+
#' `ppc_intervals_data()`. Users can call either function directly to
57+
#' obtain the prepared data frame and create custom interval or ribbon
58+
#' visualizations with **ggplot2**.
59+
#' }
5360
#' }
5461
#'
5562
#' @examples

0 commit comments

Comments
 (0)