Skip to content

Commit d26b850

Browse files
committed
updating documentation and adding tests
1 parent a46260b commit d26b850

File tree

9 files changed

+446
-3
lines changed

9 files changed

+446
-3
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Add `x` argument to `ppc_error_binned` by @behramulukir (#359)
77
* Add `x` argument to `ppc_error_scatter_avg()` by @behramulukir (#367)
88
* Add `discrete` style to `ppc_rootogram` by @behramulukir (#362)
9+
* Add `discrete` argument to `ppc_stat` and `ppd_stat` by @behramulukir (#369)
910

1011
# bayesplot 1.13.0
1112

R/ppc-test-statistics.R

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
#' display the function name(s). If specified as a function (or functions)
2828
#' then generic naming is used in the legend.
2929
#' @param ... Currently unused.
30-
#'
30+
#' @param discrete For `ppc_stat()` and `ppc_stat_grouped()`, if `TRUE` then a
31+
#' bar chart is used instead of a histogram.
3132
#' @template details-binomial
3233
#' @template return-ggplot-or-data
3334
#'
@@ -38,7 +39,7 @@
3839
#' @section Plot Descriptions:
3940
#' \describe{
4041
#' \item{`ppc_stat()`, `ppc_stat_freqpoly()`}{
41-
#' A histogram or frequency polygon of the distribution of a statistic
42+
#' A histogram/bar plot or frequency polygon of the distribution of a statistic
4243
#' computed by applying `stat` to each dataset (row) in `yrep`. The value of
4344
#' the statistic in the observed data, `stat(y)`, is overlaid as a vertical
4445
#' line. More details and example usage of `ppc_stat()` can be found in Gabry
@@ -62,6 +63,12 @@
6263
#' ppc_stat(y, yrep, stat = "median")
6364
#' ppc_stat(y, yrep, stat = "sd") + legend_none()
6465
#'
66+
#' # discrete data example
67+
#' set.seed(0)
68+
#' y_discrete <- rbinom(20, 1, 0.2)
69+
#' yrep_discrete <- matrix(rbinom(2000, 1, prob = 0.4), 1000, 20, byrow = TRUE)
70+
#' ppc_stat(y_discrete, yrep_discrete, stat = "mean", discrete = TRUE)
71+
#'
6572
#' # use your own function for the 'stat' argument
6673
#' color_scheme_set("brightblue")
6774
#' q25 <- function(y) quantile(y, 0.25)
@@ -77,6 +84,10 @@
7784
#' ppc_stat_grouped(y, yrep, group, stat = "median")
7885
#' ppc_stat_grouped(y, yrep, group, stat = "mad") + yaxis_text()
7986
#'
87+
#' # discrete data example with groups
88+
#' group_discrete <- rep(c("First Half","Second Half"), each = 10)
89+
#' ppc_stat_grouped(y_discrete, yrep_discrete, group_discrete, stat = "mean", discrete = TRUE)
90+
#'
8091
#' # force y-axes to have same scales, allow x axis to vary
8192
#' ppc_stat_grouped(y, yrep, group, facet_args = list(scales = "free_x")) + yaxis_text()
8293
#'

man/PPC-test-statistics.Rd

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/PPD-test-statistics.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 73 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)