From d1e5353e1713ffb0809e0c5f6b157619ac076d2d Mon Sep 17 00:00:00 2001 From: BehramUlukir Date: Fri, 20 Jun 2025 17:53:58 +0300 Subject: [PATCH 1/8] Adding 2 possible quantile dot plot functions --- DESCRIPTION | 2 +- R/ppc-distributions.R | 102 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index cd86c2bc..e65de114 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -39,7 +39,7 @@ Imports: tibble (>= 2.0.0), tidyr, tidyselect, - utils + utils, Suggests: ggfortify, gridExtra (>= 2.2.1), diff --git a/R/ppc-distributions.R b/R/ppc-distributions.R index e05d3ac7..616550ba 100644 --- a/R/ppc-distributions.R +++ b/R/ppc-distributions.R @@ -507,6 +507,108 @@ ppc_boxplot <- xaxis_title(FALSE) } +#' @rdname PPC-distributions +#' @export +ppc_qdotplot <- + function(y, + yrep, + ..., + binwidth = NULL, + freq = TRUE) { + check_ignored_arguments(...) + + data <- ppc_data(y, yrep) + + # Calculate adaptive binwidth if not provided + if (is.null(binwidth)) { + data_range <- diff(range(data$value, na.rm = TRUE)) + binwidth <- data_range / 30 + } + + # Create a test plot to understand the data structure per facet + test_plot <- ggplot(data, aes(x = .data$value)) + + geom_dotplot( + binwidth = binwidth, + method = "histodot", + ) + + facet_wrap_parsed("rep_label") + + # Build the plot to extract scaling information + built_plot <- ggplot_build(test_plot) + + # Find the maximum count across all facets + max_count_per_facet <- built_plot$data[[1]] %>% + group_by(PANEL) %>% + summarise(max_count = max(count, na.rm = TRUE), .groups = "drop") + overall_max_count <- max(max_count_per_facet$max_count, na.rm = TRUE) + + # More aggressive scaling for high counts + if (overall_max_count <= 9) { + optimal_dotsize <- 1.0 + } else { + optimal_dotsize <- 3 / sqrt(overall_max_count) + } + + ggplot(data, mapping = set_hist_aes( + freq = freq, + fill = !!quote(is_y_label), + color = !!quote(is_y_label), + )) + + geom_dotplot( + binwidth = binwidth, + method = "histodot", + dotsize = optimal_dotsize, + ) + + scale_fill_ppc() + + scale_color_ppc() + + facet_wrap_parsed("rep_label") + + force_axes_in_facets() + + bayesplot_theme_get() + + space_legend_keys() + + yaxis_text(FALSE) + + yaxis_title(FALSE) + + yaxis_ticks(FALSE) + + xaxis_title(FALSE) + + facet_text(FALSE) + + facet_bg(FALSE) + } + +### GGDIST VERSION +library(ggdist) +ppc_qdotplot_ggdist <- + function(y, + yrep, + ..., + binwidth = NA, + quantiles = NA, + freq = TRUE) { + check_ignored_arguments(...) + + data <- ppc_data(y, yrep) + + ggplot(data, mapping = aes( + x = .data$value, + fill = .data$is_y_label, + color = .data$is_y_label + )) + + stat_dots( + binwidth = binwidth, + quantiles = quantiles, + overflow = "warn" + ) + + scale_fill_ppc() + + scale_color_ppc() + + facet_wrap_parsed("rep_label") + + force_axes_in_facets() + + bayesplot_theme_get() + + space_legend_keys() + + yaxis_text(FALSE) + + yaxis_title(FALSE) + + yaxis_ticks(FALSE) + + xaxis_title(FALSE) + + facet_text(FALSE) + + facet_bg(FALSE) + } #' @rdname PPC-distributions #' @export From f800103e07f41c28a0abf9ea070838caf2b906e5 Mon Sep 17 00:00:00 2001 From: BehramUlukir Date: Mon, 23 Jun 2025 13:58:19 +0300 Subject: [PATCH 2/8] removing comma at DESCRIPTION which may be leading to fails in some tests --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index e65de114..cd86c2bc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -39,7 +39,7 @@ Imports: tibble (>= 2.0.0), tidyr, tidyselect, - utils, + utils Suggests: ggfortify, gridExtra (>= 2.2.1), From 1407e3516e2389f888fcdce2187bbd382030b7e7 Mon Sep 17 00:00:00 2001 From: BehramUlukir Date: Thu, 26 Jun 2025 14:02:30 +0300 Subject: [PATCH 3/8] removing unused function and writing documentation --- DESCRIPTION | 3 +- R/ppc-distributions.R | 85 +++++++------------------------------ man-roxygen/args-qdotplot.R | 3 ++ 3 files changed, 20 insertions(+), 71 deletions(-) create mode 100644 man-roxygen/args-qdotplot.R diff --git a/DESCRIPTION b/DESCRIPTION index cd86c2bc..2d2c0912 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -55,7 +55,8 @@ Suggests: shinystan (>= 2.3.0), survival, testthat (>= 2.0.0), - vdiffr (>= 1.0.2) + vdiffr (>= 1.0.2), + ggdist RoxygenNote: 7.3.2 VignetteBuilder: knitr Encoding: UTF-8 diff --git a/R/ppc-distributions.R b/R/ppc-distributions.R index 616550ba..98bffe71 100644 --- a/R/ppc-distributions.R +++ b/R/ppc-distributions.R @@ -28,6 +28,11 @@ #' dataset (row) in `yrep`. For these plots `yrep` should therefore #' contain only a small number of rows. See the **Examples** section. #' } +#' \item{`ppc_qdotplot()`}{ +#' A dot plot plot is displayed for `y` and each dataset (row) in `yrep`. +#' For these plots `yrep` should therefore contain only a small number of rows. +#' See the **Examples** section. This function requires [ggdist::stat_dots] to be installed. +#' } #' \item{`ppc_freqpoly_grouped()`}{ #' A separate frequency polygon is plotted for each level of a grouping #' variable for `y` and each dataset (row) in `yrep`. For this plot @@ -80,7 +85,7 @@ #' ppc_pit_ecdf(y, yrep, prob = 0.99, plot_diff = TRUE) #' } #' -#' # for ppc_hist,dens,freqpoly,boxplot definitely use a subset yrep rows so +#' # for ppc_hist,dens,freqpoly,boxplot,qdotplot definitely use a subset yrep rows so #' # only a few (instead of nrow(yrep)) histograms are plotted #' ppc_hist(y, yrep[1:8, ]) #' \donttest{ @@ -90,6 +95,9 @@ #' # wizard hat plot #' color_scheme_set("blue") #' ppc_dens(y, yrep[200:202, ]) +#' +#' # dot plot +#' ppc_qdotplot(y, yrep[1:8, ]) #' } #' #' \donttest{ @@ -509,73 +517,8 @@ ppc_boxplot <- #' @rdname PPC-distributions #' @export +#' @template args-qdotplot ppc_qdotplot <- - function(y, - yrep, - ..., - binwidth = NULL, - freq = TRUE) { - check_ignored_arguments(...) - - data <- ppc_data(y, yrep) - - # Calculate adaptive binwidth if not provided - if (is.null(binwidth)) { - data_range <- diff(range(data$value, na.rm = TRUE)) - binwidth <- data_range / 30 - } - - # Create a test plot to understand the data structure per facet - test_plot <- ggplot(data, aes(x = .data$value)) + - geom_dotplot( - binwidth = binwidth, - method = "histodot", - ) + - facet_wrap_parsed("rep_label") - - # Build the plot to extract scaling information - built_plot <- ggplot_build(test_plot) - - # Find the maximum count across all facets - max_count_per_facet <- built_plot$data[[1]] %>% - group_by(PANEL) %>% - summarise(max_count = max(count, na.rm = TRUE), .groups = "drop") - overall_max_count <- max(max_count_per_facet$max_count, na.rm = TRUE) - - # More aggressive scaling for high counts - if (overall_max_count <= 9) { - optimal_dotsize <- 1.0 - } else { - optimal_dotsize <- 3 / sqrt(overall_max_count) - } - - ggplot(data, mapping = set_hist_aes( - freq = freq, - fill = !!quote(is_y_label), - color = !!quote(is_y_label), - )) + - geom_dotplot( - binwidth = binwidth, - method = "histodot", - dotsize = optimal_dotsize, - ) + - scale_fill_ppc() + - scale_color_ppc() + - facet_wrap_parsed("rep_label") + - force_axes_in_facets() + - bayesplot_theme_get() + - space_legend_keys() + - yaxis_text(FALSE) + - yaxis_title(FALSE) + - yaxis_ticks(FALSE) + - xaxis_title(FALSE) + - facet_text(FALSE) + - facet_bg(FALSE) - } - -### GGDIST VERSION -library(ggdist) -ppc_qdotplot_ggdist <- function(y, yrep, ..., @@ -584,14 +527,16 @@ ppc_qdotplot_ggdist <- freq = TRUE) { check_ignored_arguments(...) + suggested_package("ggdist") + data <- ppc_data(y, yrep) - ggplot(data, mapping = aes( - x = .data$value, + ggplot(data, mapping = set_hist_aes( + freq = freq, fill = .data$is_y_label, color = .data$is_y_label )) + - stat_dots( + ggdist::stat_dots( binwidth = binwidth, quantiles = quantiles, overflow = "warn" diff --git a/man-roxygen/args-qdotplot.R b/man-roxygen/args-qdotplot.R new file mode 100644 index 00000000..aa163428 --- /dev/null +++ b/man-roxygen/args-qdotplot.R @@ -0,0 +1,3 @@ +#' @param quantiles For dot plots, optional integer `quantiles` defines the +#' number of quantiles to plot in dot plot to produce a quantile dot plot. +#' If `quantiles` is `NA` (the default) then all data points are plotted. From 529b492dd87608de1079bb8f9f5d94ce180bd934 Mon Sep 17 00:00:00 2001 From: BehramUlukir Date: Thu, 26 Jun 2025 18:00:00 +0300 Subject: [PATCH 4/8] add ppd_qdotplot and all tests --- R/ppd-distributions.R | 37 + .../ppc-qdotplot-binwidth.svg | 950 +++++++++++++ .../ppc-qdotplot-default.svg | 1265 +++++++++++++++++ .../ppc-qdotplot-quantile-binwidth.svg | 867 +++++++++++ .../ppc-qdotplot-quantile.svg | 869 +++++++++++ .../ppd-qdotplot-binwidth.svg | 809 +++++++++++ .../ppd-qdotplot-default.svg | 1138 +++++++++++++++ .../ppd-qdotplot-quantile-binwidth.svg | 780 ++++++++++ .../ppd-qdotplot-quantile.svg | 787 ++++++++++ tests/testthat/test-ppc-distributions.R | 48 + 10 files changed, 7550 insertions(+) create mode 100644 tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-binwidth.svg create mode 100644 tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-default.svg create mode 100644 tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile-binwidth.svg create mode 100644 tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile.svg create mode 100644 tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-binwidth.svg create mode 100644 tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-default.svg create mode 100644 tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile-binwidth.svg create mode 100644 tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile.svg diff --git a/R/ppd-distributions.R b/R/ppd-distributions.R index 7c868311..01a9cacd 100644 --- a/R/ppd-distributions.R +++ b/R/ppd-distributions.R @@ -187,6 +187,43 @@ ppd_hist <- facet_text(FALSE) } +#' @rdname PPD-distributions +#' @export +ppd_qdotplot <- + function(ypred, + ..., + binwidth = NA, + quantiles = NA, + freq = TRUE) { + check_ignored_arguments(...) + + suggested_package("ggdist") + + data <- ppd_data(ypred) + ggplot(data, mapping = set_hist_aes( + freq, + color = "ypred", + fill = "ypred" + )) + + ggdist::stat_dots( + binwidth = binwidth, + quantiles = quantiles, + overflow = "warn" + ) + + scale_color_ppd() + + scale_fill_ppd() + + bayesplot_theme_get() + + facet_wrap_parsed("rep_label") + + force_axes_in_facets() + + dont_expand_y_axis() + + legend_none() + + yaxis_text(FALSE) + + yaxis_title(FALSE) + + yaxis_ticks(FALSE) + + xaxis_title(FALSE) + + facet_text(FALSE) + } + #' @rdname PPD-distributions #' @export diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-binwidth.svg b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-binwidth.svg new file mode 100644 index 00000000..fafdc7de --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-binwidth.svg @@ -0,0 +1,950 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 +-2 +0 +2 +-2 +0 +2 + + + + +y +y +r +e +p +ppc_qdotplot (binwidth) + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-default.svg b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-default.svg new file mode 100644 index 00000000..7a219b97 --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-default.svg @@ -0,0 +1,1265 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 +-2 +0 +2 +-2 +0 +2 + + + + +y +y +r +e +p +ppc_qdotplot (default) + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile-binwidth.svg b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile-binwidth.svg new file mode 100644 index 00000000..3260ca6f --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile-binwidth.svg @@ -0,0 +1,867 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +-1 +0 +1 +2 +3 +-2 +-1 +0 +1 +2 +3 +-2 +-1 +0 +1 +2 +3 + + + + +y +y +r +e +p +ppc_qdotplot (quantile-binwidth) + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile.svg b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile.svg new file mode 100644 index 00000000..b8dd373d --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile.svg @@ -0,0 +1,869 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +-1 +0 +1 +2 +3 +-2 +-1 +0 +1 +2 +3 +-2 +-1 +0 +1 +2 +3 + + + + +y +y +r +e +p +ppc_qdotplot (quantile) + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-binwidth.svg b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-binwidth.svg new file mode 100644 index 00000000..08e1cfb9 --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-binwidth.svg @@ -0,0 +1,809 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 +-2 +0 +2 +-2 +0 +2 +ppd_qdotplot (binwidth) + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-default.svg b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-default.svg new file mode 100644 index 00000000..d097abd9 --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-default.svg @@ -0,0 +1,1138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 +-2 +0 +2 +-2 +0 +2 +ppd_qdotplot (default) + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile-binwidth.svg b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile-binwidth.svg new file mode 100644 index 00000000..9b14e634 --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile-binwidth.svg @@ -0,0 +1,780 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +-1 +0 +1 +2 +3 +-2 +-1 +0 +1 +2 +3 +-2 +-1 +0 +1 +2 +3 +ppd_qdotplot (quantile-binwidth) + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile.svg b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile.svg new file mode 100644 index 00000000..aea53bce --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile.svg @@ -0,0 +1,787 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +-1 +0 +1 +2 +3 +-2 +-1 +0 +1 +2 +3 +-2 +-1 +0 +1 +2 +3 +ppd_qdotplot (quantile) + + diff --git a/tests/testthat/test-ppc-distributions.R b/tests/testthat/test-ppc-distributions.R index e544e144..cad882d3 100644 --- a/tests/testthat/test-ppc-distributions.R +++ b/tests/testthat/test-ppc-distributions.R @@ -58,6 +58,22 @@ test_that("ppc_dens,pp_hist,ppc_freqpoly,ppc_boxplot return ggplot objects", { expect_gg(ppd_boxplot(yrep2, notch = FALSE)) }) +test_that("ppc_qdotplot returns a ggplot object", { + testthat::skip_if_not_installed("ggdist") + + expect_gg(ppc_qdotplot(y, yrep[1:8, ])) + expect_gg(ppc_qdotplot(y, yrep[1,, drop = FALSE], quantiles=25)) + expect_gg(ppc_qdotplot(y, yrep[1:8, ], binwidth = 0.1)) + expect_gg(ppc_qdotplot(y2, yrep2, binwidth = 0.1, quantiles = 25)) + + + # ppd versions + expect_gg(ppd_qdotplot(y, yrep[1:8, ])) + expect_gg(ppd_qdotplot(yrep[1,, drop = FALSE], quantiles = 25)) + expect_gg(ppd_qdotplot(yrep[1:8, ], binwidth = 0.1)) + expect_gg(ppd_qdotplot(yrep2, binwidth = 0.1, quantiles = 25)) +}) + test_that("ppc_pit_ecdf, ppc_pit_ecdf_grouped returns a ggplot object", { expect_gg(ppc_pit_ecdf(y, yrep, interpolate_adj = FALSE)) expect_gg(ppc_pit_ecdf_grouped(y, yrep, group = group, interpolate_adj = FALSE)) @@ -177,6 +193,38 @@ test_that("ppc_boxplot renders correctly", { vdiffr::expect_doppelganger("ppd_boxplot (alpha, size)", p_custom) }) +test_that("ppc_qdotplot renders correctly", { + testthat::skip_on_cran() + testthat::skip_if_not_installed("vdiffr") + testthat::skip_if_not_installed("ggdist") + skip_on_r_oldrel() + + p_base <- ppc_qdotplot(vdiff_y, vdiff_yrep[1:8, ]) + vdiffr::expect_doppelganger("ppc_qdotplot (default)", p_base) + + p_binwidth <- ppc_qdotplot(vdiff_y, vdiff_yrep[1:8, ], binwidth = 3) + vdiffr::expect_doppelganger("ppc_qdotplot (binwidth)", p_binwidth) + + p_quantile <- ppc_qdotplot(vdiff_y, vdiff_yrep[1:8, ], quantiles = 50) + vdiffr::expect_doppelganger("ppc_qdotplot (quantile)", p_quantile) + + p_quantile_binwidth <- ppc_qdotplot(vdiff_y, vdiff_yrep[1:8, ], binwidth = 3, quantiles = 50) + vdiffr::expect_doppelganger("ppc_qdotplot (quantile-binwidth)", p_quantile_binwidth) + + # ppd versions + p_base <- ppd_qdotplot(vdiff_yrep[1:8, ]) + vdiffr::expect_doppelganger("ppd_qdotplot (default)", p_base) + + p_binwidth <- ppd_qdotplot(vdiff_yrep[1:8, ], binwidth = 3) + vdiffr::expect_doppelganger("ppd_qdotplot (binwidth)", p_binwidth) + + p_quantile <- ppd_qdotplot(vdiff_yrep[1:8, ], quantiles = 50) + vdiffr::expect_doppelganger("ppd_qdotplot (quantile)", p_quantile) + + p_quantile_binwidth <- ppd_qdotplot(vdiff_yrep[1:8, ], binwidth = 3, quantiles = 50) + vdiffr::expect_doppelganger("ppd_qdotplot (quantile-binwidth)", p_quantile_binwidth) +}) + test_that("ppc_ecdf_overlay renders correctly", { testthat::skip_on_cran() testthat::skip_if_not_installed("vdiffr") From afcc2de02959032572a97921972b1b83f61a4f8d Mon Sep 17 00:00:00 2001 From: BehramUlukir Date: Sun, 29 Jun 2025 19:39:47 +0300 Subject: [PATCH 5/8] fixing errors, updating documentation and adding new capabilities to functions --- DESCRIPTION | 4 +- R/ppc-distributions.R | 6 +- R/ppd-distributions.R | 4 +- man-roxygen/args-qdotplot.R | 7 +- .../ppc-qdotplot-binwidth.new.svg | 853 +++++++++++++ .../ppc-qdotplot-default.new.svg | 1136 +++++++++++++++++ .../ppc-qdotplot-quantile-binwidth.new.svg | 704 ++++++++++ .../ppc-qdotplot-quantile.new.svg | 704 ++++++++++ .../ppd-qdotplot-binwidth.new.svg | 720 +++++++++++ .../ppd-qdotplot-default.new.svg | 1025 +++++++++++++++ .../ppd-qdotplot-quantile-binwidth.new.svg | 639 ++++++++++ .../ppd-qdotplot-quantile.new.svg | 643 ++++++++++ tests/testthat/test-ppc-distributions.R | 18 +- 13 files changed, 6446 insertions(+), 17 deletions(-) create mode 100644 tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-binwidth.new.svg create mode 100644 tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-default.new.svg create mode 100644 tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile-binwidth.new.svg create mode 100644 tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile.new.svg create mode 100644 tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-binwidth.new.svg create mode 100644 tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-default.new.svg create mode 100644 tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile-binwidth.new.svg create mode 100644 tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile.new.svg diff --git a/DESCRIPTION b/DESCRIPTION index 2d2c0912..8181d1f0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -41,6 +41,7 @@ Imports: tidyselect, utils Suggests: + ggdist, ggfortify, gridExtra (>= 2.2.1), hexbin, @@ -55,8 +56,7 @@ Suggests: shinystan (>= 2.3.0), survival, testthat (>= 2.0.0), - vdiffr (>= 1.0.2), - ggdist + vdiffr (>= 1.0.2) RoxygenNote: 7.3.2 VignetteBuilder: knitr Encoding: UTF-8 diff --git a/R/ppc-distributions.R b/R/ppc-distributions.R index 98bffe71..2d96f29d 100644 --- a/R/ppc-distributions.R +++ b/R/ppc-distributions.R @@ -15,7 +15,7 @@ #' @template args-pit-ecdf #' @param size,alpha Passed to the appropriate geom to control the appearance of #' the predictive distributions. -#' @param ... Currently unused. +#' @param ... For dot plots, optional additional arguments to pass to [ggdist::stat_dots()]. #' #' @template details-binomial #' @template return-ggplot-or-data @@ -525,7 +525,7 @@ ppc_qdotplot <- binwidth = NA, quantiles = NA, freq = TRUE) { - check_ignored_arguments(...) + check_ignored_arguments(..., ok_args = c("dotsize", "layout", "stackratio", "overflow")) suggested_package("ggdist") @@ -539,7 +539,7 @@ ppc_qdotplot <- ggdist::stat_dots( binwidth = binwidth, quantiles = quantiles, - overflow = "warn" + ... ) + scale_fill_ppc() + scale_color_ppc() + diff --git a/R/ppd-distributions.R b/R/ppd-distributions.R index 01a9cacd..d8682348 100644 --- a/R/ppd-distributions.R +++ b/R/ppd-distributions.R @@ -195,7 +195,7 @@ ppd_qdotplot <- binwidth = NA, quantiles = NA, freq = TRUE) { - check_ignored_arguments(...) + check_ignored_arguments(..., ok_args = c("dotsize", "layout", "stackratio", "overflow")) suggested_package("ggdist") @@ -208,7 +208,7 @@ ppd_qdotplot <- ggdist::stat_dots( binwidth = binwidth, quantiles = quantiles, - overflow = "warn" + ... ) + scale_color_ppd() + scale_fill_ppd() + diff --git a/man-roxygen/args-qdotplot.R b/man-roxygen/args-qdotplot.R index aa163428..4e820d1e 100644 --- a/man-roxygen/args-qdotplot.R +++ b/man-roxygen/args-qdotplot.R @@ -1,3 +1,4 @@ -#' @param quantiles For dot plots, optional integer `quantiles` defines the -#' number of quantiles to plot in dot plot to produce a quantile dot plot. -#' If `quantiles` is `NA` (the default) then all data points are plotted. +#' @param quantiles For dot plots, an optional integer passed to +#' [ggdist::stat_dots()] specifying the number of quantiles to use for a +#' quantile dot plot. If `quantiles` is `NA` (the default) then all data +#' points are plotted. diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-binwidth.new.svg b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-binwidth.new.svg new file mode 100644 index 00000000..ad4a5ff6 --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-binwidth.new.svg @@ -0,0 +1,853 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + + + + +y +y +r +e +p +ppc_qdotplot (binwidth) + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-default.new.svg b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-default.new.svg new file mode 100644 index 00000000..56bf8f97 --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-default.new.svg @@ -0,0 +1,1136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + + + + +y +y +r +e +p +ppc_qdotplot (default) + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile-binwidth.new.svg b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile-binwidth.new.svg new file mode 100644 index 00000000..5a93daae --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile-binwidth.new.svg @@ -0,0 +1,704 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +-1 +0 +1 +2 +3 + + + + + + + +-2 +-1 +0 +1 +2 +3 + + + + + + + +-2 +-1 +0 +1 +2 +3 + + + + + + + +y +y +r +e +p +ppc_qdotplot (quantile-binwidth) + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile.new.svg b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile.new.svg new file mode 100644 index 00000000..506e9ced --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile.new.svg @@ -0,0 +1,704 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +-1 +0 +1 +2 +3 + + + + + + + +-2 +-1 +0 +1 +2 +3 + + + + + + + +-2 +-1 +0 +1 +2 +3 + + + + + + + +y +y +r +e +p +ppc_qdotplot (quantile) + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-binwidth.new.svg b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-binwidth.new.svg new file mode 100644 index 00000000..64ab32e3 --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-binwidth.new.svg @@ -0,0 +1,720 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + +ppd_qdotplot (binwidth) + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-default.new.svg b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-default.new.svg new file mode 100644 index 00000000..6dcd41f0 --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-default.new.svg @@ -0,0 +1,1025 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + +ppd_qdotplot (default) + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile-binwidth.new.svg b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile-binwidth.new.svg new file mode 100644 index 00000000..db99e744 --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile-binwidth.new.svg @@ -0,0 +1,639 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +-1 +0 +1 +2 +3 + + + + + + + +-2 +-1 +0 +1 +2 +3 + + + + + + + +-2 +-1 +0 +1 +2 +3 + + + +ppd_qdotplot (quantile-binwidth) + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile.new.svg b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile.new.svg new file mode 100644 index 00000000..20a76421 --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile.new.svg @@ -0,0 +1,643 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +-1 +0 +1 +2 +3 + + + + + + + +-2 +-1 +0 +1 +2 +3 + + + + + + + +-2 +-1 +0 +1 +2 +3 + + + +ppd_qdotplot (quantile) + + diff --git a/tests/testthat/test-ppc-distributions.R b/tests/testthat/test-ppc-distributions.R index cad882d3..a7e41dbd 100644 --- a/tests/testthat/test-ppc-distributions.R +++ b/tests/testthat/test-ppc-distributions.R @@ -62,16 +62,16 @@ test_that("ppc_qdotplot returns a ggplot object", { testthat::skip_if_not_installed("ggdist") expect_gg(ppc_qdotplot(y, yrep[1:8, ])) - expect_gg(ppc_qdotplot(y, yrep[1,, drop = FALSE], quantiles=25)) + expect_gg(ppc_qdotplot(y, yrep[1,, drop = FALSE], quantiles = 25)) expect_gg(ppc_qdotplot(y, yrep[1:8, ], binwidth = 0.1)) expect_gg(ppc_qdotplot(y2, yrep2, binwidth = 0.1, quantiles = 25)) - # ppd versions - expect_gg(ppd_qdotplot(y, yrep[1:8, ])) + expect_gg(ppd_qdotplot(yrep[1:8, ])) expect_gg(ppd_qdotplot(yrep[1,, drop = FALSE], quantiles = 25)) expect_gg(ppd_qdotplot(yrep[1:8, ], binwidth = 0.1)) expect_gg(ppd_qdotplot(yrep2, binwidth = 0.1, quantiles = 25)) + }) test_that("ppc_pit_ecdf, ppc_pit_ecdf_grouped returns a ggplot object", { @@ -203,26 +203,30 @@ test_that("ppc_qdotplot renders correctly", { vdiffr::expect_doppelganger("ppc_qdotplot (default)", p_base) p_binwidth <- ppc_qdotplot(vdiff_y, vdiff_yrep[1:8, ], binwidth = 3) - vdiffr::expect_doppelganger("ppc_qdotplot (binwidth)", p_binwidth) + expect_warning(vdiffr::expect_doppelganger("ppc_qdotplot (binwidth)", p_binwidth), + "The provided binwidth will cause dots to overflow the boundaries of the geometry.") p_quantile <- ppc_qdotplot(vdiff_y, vdiff_yrep[1:8, ], quantiles = 50) vdiffr::expect_doppelganger("ppc_qdotplot (quantile)", p_quantile) p_quantile_binwidth <- ppc_qdotplot(vdiff_y, vdiff_yrep[1:8, ], binwidth = 3, quantiles = 50) - vdiffr::expect_doppelganger("ppc_qdotplot (quantile-binwidth)", p_quantile_binwidth) + expect_warning(vdiffr::expect_doppelganger("ppc_qdotplot (quantile-binwidth)", p_quantile_binwidth), + "The provided binwidth will cause dots to overflow the boundaries of the geometry.") # ppd versions p_base <- ppd_qdotplot(vdiff_yrep[1:8, ]) vdiffr::expect_doppelganger("ppd_qdotplot (default)", p_base) p_binwidth <- ppd_qdotplot(vdiff_yrep[1:8, ], binwidth = 3) - vdiffr::expect_doppelganger("ppd_qdotplot (binwidth)", p_binwidth) + expect_warning(vdiffr::expect_doppelganger("ppd_qdotplot (binwidth)", p_binwidth), + "The provided binwidth will cause dots to overflow the boundaries of the geometry.") p_quantile <- ppd_qdotplot(vdiff_yrep[1:8, ], quantiles = 50) vdiffr::expect_doppelganger("ppd_qdotplot (quantile)", p_quantile) p_quantile_binwidth <- ppd_qdotplot(vdiff_yrep[1:8, ], binwidth = 3, quantiles = 50) - vdiffr::expect_doppelganger("ppd_qdotplot (quantile-binwidth)", p_quantile_binwidth) + expect_warning(vdiffr::expect_doppelganger("ppd_qdotplot (quantile-binwidth)", p_quantile_binwidth), + "The provided binwidth will cause dots to overflow the boundaries of the geometry.") }) test_that("ppc_ecdf_overlay renders correctly", { From e96f6252913fa4923ba245d39fee20b2c23c5145 Mon Sep 17 00:00:00 2001 From: BehramUlukir Date: Wed, 2 Jul 2025 01:00:51 +0300 Subject: [PATCH 6/8] updating documentation and fixing tests --- NAMESPACE | 2 + R/ppc-distributions.R | 10 +- R/ppd-distributions.R | 2 +- man-roxygen/{args-qdotplot.R => args-dots.R} | 0 man/PPC-distributions.Rd | 20 +- man/PPD-distributions.Rd | 10 +- ...binwidth.new.svg => ppc-dots-binwidth.svg} | 2 +- ...t-default.new.svg => ppc-dots-default.svg} | 2 +- ...new.svg => ppc-dots-quantile-binwidth.svg} | 2 +- ...quantile.new.svg => ppc-dots-quantile.svg} | 2 +- .../ppc-qdotplot-binwidth.svg | 950 ------------- .../ppc-qdotplot-default.svg | 1265 ----------------- .../ppc-qdotplot-quantile-binwidth.svg | 867 ----------- .../ppc-qdotplot-quantile.svg | 869 ----------- ...binwidth.new.svg => ppd-dots-binwidth.svg} | 2 +- ...t-default.new.svg => ppd-dots-default.svg} | 2 +- ...new.svg => ppd-dots-quantile-binwidth.svg} | 2 +- ...quantile.new.svg => ppd-dots-quantile.svg} | 2 +- .../ppd-qdotplot-binwidth.svg | 809 ----------- .../ppd-qdotplot-default.svg | 1138 --------------- .../ppd-qdotplot-quantile-binwidth.svg | 780 ---------- .../ppd-qdotplot-quantile.svg | 787 ---------- tests/testthat/test-ppc-distributions.R | 60 +- 23 files changed, 73 insertions(+), 7512 deletions(-) rename man-roxygen/{args-qdotplot.R => args-dots.R} (100%) rename tests/testthat/_snaps/ppc-distributions/{ppc-qdotplot-binwidth.new.svg => ppc-dots-binwidth.svg} (99%) rename tests/testthat/_snaps/ppc-distributions/{ppc-qdotplot-default.new.svg => ppc-dots-default.svg} (99%) rename tests/testthat/_snaps/ppc-distributions/{ppc-qdotplot-quantile-binwidth.new.svg => ppc-dots-quantile-binwidth.svg} (99%) rename tests/testthat/_snaps/ppc-distributions/{ppc-qdotplot-quantile.new.svg => ppc-dots-quantile.svg} (99%) delete mode 100644 tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-binwidth.svg delete mode 100644 tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-default.svg delete mode 100644 tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile-binwidth.svg delete mode 100644 tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile.svg rename tests/testthat/_snaps/ppc-distributions/{ppd-qdotplot-binwidth.new.svg => ppd-dots-binwidth.svg} (99%) rename tests/testthat/_snaps/ppc-distributions/{ppd-qdotplot-default.new.svg => ppd-dots-default.svg} (99%) rename tests/testthat/_snaps/ppc-distributions/{ppd-qdotplot-quantile-binwidth.new.svg => ppd-dots-quantile-binwidth.svg} (99%) rename tests/testthat/_snaps/ppc-distributions/{ppd-qdotplot-quantile.new.svg => ppd-dots-quantile.svg} (99%) delete mode 100644 tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-binwidth.svg delete mode 100644 tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-default.svg delete mode 100644 tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile-binwidth.svg delete mode 100644 tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile.svg diff --git a/NAMESPACE b/NAMESPACE index 614fe4e7..4823d8df 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -123,6 +123,7 @@ export(ppc_data) export(ppc_dens) export(ppc_dens_overlay) export(ppc_dens_overlay_grouped) +export(ppc_dots) export(ppc_ecdf_overlay) export(ppc_ecdf_overlay_grouped) export(ppc_error_binned) @@ -170,6 +171,7 @@ export(ppd_boxplot) export(ppd_data) export(ppd_dens) export(ppd_dens_overlay) +export(ppd_dots) export(ppd_ecdf_overlay) export(ppd_freqpoly) export(ppd_freqpoly_grouped) diff --git a/R/ppc-distributions.R b/R/ppc-distributions.R index 2d96f29d..cd81bbea 100644 --- a/R/ppc-distributions.R +++ b/R/ppc-distributions.R @@ -28,7 +28,7 @@ #' dataset (row) in `yrep`. For these plots `yrep` should therefore #' contain only a small number of rows. See the **Examples** section. #' } -#' \item{`ppc_qdotplot()`}{ +#' \item{`ppc_dots()`}{ #' A dot plot plot is displayed for `y` and each dataset (row) in `yrep`. #' For these plots `yrep` should therefore contain only a small number of rows. #' See the **Examples** section. This function requires [ggdist::stat_dots] to be installed. @@ -85,7 +85,7 @@ #' ppc_pit_ecdf(y, yrep, prob = 0.99, plot_diff = TRUE) #' } #' -#' # for ppc_hist,dens,freqpoly,boxplot,qdotplot definitely use a subset yrep rows so +#' # for ppc_hist,dens,freqpoly,boxplot,dots definitely use a subset yrep rows so #' # only a few (instead of nrow(yrep)) histograms are plotted #' ppc_hist(y, yrep[1:8, ]) #' \donttest{ @@ -97,7 +97,7 @@ #' ppc_dens(y, yrep[200:202, ]) #' #' # dot plot -#' ppc_qdotplot(y, yrep[1:8, ]) +#' ppc_dots(y, yrep[1:8, ]) #' } #' #' \donttest{ @@ -517,8 +517,8 @@ ppc_boxplot <- #' @rdname PPC-distributions #' @export -#' @template args-qdotplot -ppc_qdotplot <- +#' @template args-dots +ppc_dots <- function(y, yrep, ..., diff --git a/R/ppd-distributions.R b/R/ppd-distributions.R index d8682348..83e8baef 100644 --- a/R/ppd-distributions.R +++ b/R/ppd-distributions.R @@ -189,7 +189,7 @@ ppd_hist <- #' @rdname PPD-distributions #' @export -ppd_qdotplot <- +ppd_dots <- function(ypred, ..., binwidth = NA, diff --git a/man-roxygen/args-qdotplot.R b/man-roxygen/args-dots.R similarity index 100% rename from man-roxygen/args-qdotplot.R rename to man-roxygen/args-dots.R diff --git a/man/PPC-distributions.Rd b/man/PPC-distributions.Rd index b178dc08..c4646eac 100644 --- a/man/PPC-distributions.Rd +++ b/man/PPC-distributions.Rd @@ -12,6 +12,7 @@ \alias{ppc_freqpoly} \alias{ppc_freqpoly_grouped} \alias{ppc_boxplot} +\alias{ppc_dots} \alias{ppc_violin_grouped} \alias{ppc_pit_ecdf} \alias{ppc_pit_ecdf_grouped} @@ -104,6 +105,8 @@ ppc_freqpoly_grouped( ppc_boxplot(y, yrep, ..., notch = TRUE, size = 0.5, alpha = 1) +ppc_dots(y, yrep, ..., binwidth = NA, quantiles = NA, freq = TRUE) + ppc_violin_grouped( y, yrep, @@ -157,7 +160,7 @@ Will be coerced to \link[base:factor]{factor} if not already a factor. Each value in \code{group} is interpreted as the group level pertaining to the corresponding observation.} -\item{...}{Currently unused.} +\item{...}{For dot plots, optional additional arguments to pass to \code{\link[ggdist:stat_dots]{ggdist::stat_dots()}}.} \item{size, alpha}{Passed to the appropriate geom to control the appearance of the predictive distributions.} @@ -194,6 +197,11 @@ function.)} \code{\link[ggplot2:geom_boxplot]{ggplot2::geom_boxplot()}}. Note: unlike \code{geom_boxplot()}, the default is \code{notch=TRUE}.} +\item{quantiles}{For dot plots, an optional integer passed to +\code{\link[ggdist:stat_dots]{ggdist::stat_dots()}} specifying the number of quantiles to use for a +quantile dot plot. If \code{quantiles} is \code{NA} (the default) then all data +points are plotted.} + \item{probs}{A numeric vector passed to \code{\link[ggplot2:geom_violin]{ggplot2::geom_violin()}}'s \code{draw_quantiles} argument to specify at which quantiles to draw horizontal lines. Set to \code{NULL} to remove the lines.} @@ -259,6 +267,11 @@ estimate, or box and whiskers plot is displayed for \code{y} and each dataset (row) in \code{yrep}. For these plots \code{yrep} should therefore contain only a small number of rows. See the \strong{Examples} section. } +\item{\code{ppc_dots()}}{ +A dot plot plot is displayed for \code{y} and each dataset (row) in \code{yrep}. +For these plots \code{yrep} should therefore contain only a small number of rows. +See the \strong{Examples} section. This function requires \link[ggdist:stat_dots]{ggdist::stat_dots} to be installed. +} \item{\code{ppc_freqpoly_grouped()}}{ A separate frequency polygon is plotted for each level of a grouping variable for \code{y} and each dataset (row) in \code{yrep}. For this plot @@ -306,7 +319,7 @@ ppc_pit_ecdf(y, yrep, prob = 0.99, plot_diff = FALSE) ppc_pit_ecdf(y, yrep, prob = 0.99, plot_diff = TRUE) } -# for ppc_hist,dens,freqpoly,boxplot definitely use a subset yrep rows so +# for ppc_hist,dens,freqpoly,boxplot,dots definitely use a subset yrep rows so # only a few (instead of nrow(yrep)) histograms are plotted ppc_hist(y, yrep[1:8, ]) \donttest{ @@ -316,6 +329,9 @@ ppc_boxplot(y, yrep[1:8, ]) # wizard hat plot color_scheme_set("blue") ppc_dens(y, yrep[200:202, ]) + +# dot plot +ppc_dots(y, yrep[1:8, ]) } \donttest{ diff --git a/man/PPD-distributions.Rd b/man/PPD-distributions.Rd index d74570cf..6a3c2da4 100644 --- a/man/PPD-distributions.Rd +++ b/man/PPD-distributions.Rd @@ -7,6 +7,7 @@ \alias{ppd_ecdf_overlay} \alias{ppd_dens} \alias{ppd_hist} +\alias{ppd_dots} \alias{ppd_freqpoly} \alias{ppd_freqpoly_grouped} \alias{ppd_boxplot} @@ -39,6 +40,8 @@ ppd_dens(ypred, ..., trim = FALSE, size = 0.5, alpha = 1) ppd_hist(ypred, ..., binwidth = NULL, bins = NULL, breaks = NULL, freq = TRUE) +ppd_dots(ypred, ..., binwidth = NA, quantiles = NA, freq = TRUE) + ppd_freqpoly( ypred, ..., @@ -73,7 +76,7 @@ Will be coerced to \link[base:factor]{factor} if not already a factor. Each value in \code{group} is interpreted as the group level pertaining to the corresponding observation.} -\item{...}{Currently unused.} +\item{...}{For dot plots, optional additional arguments to pass to \code{\link[ggdist:stat_dots]{ggdist::stat_dots()}}.} \item{size, alpha}{Passed to the appropriate geom to control the appearance of the predictive distributions.} @@ -106,6 +109,11 @@ plots the y-axis text is off by default. To view the count or density labels on the y-axis see the \code{\link[=yaxis_text]{yaxis_text()}} convenience function.)} +\item{quantiles}{For dot plots, an optional integer passed to +\code{\link[ggdist:stat_dots]{ggdist::stat_dots()}} specifying the number of quantiles to use for a +quantile dot plot. If \code{quantiles} is \code{NA} (the default) then all data +points are plotted.} + \item{notch}{For the box plot, a logical scalar passed to \code{\link[ggplot2:geom_boxplot]{ggplot2::geom_boxplot()}}. Note: unlike \code{geom_boxplot()}, the default is \code{notch=TRUE}.} diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-binwidth.new.svg b/tests/testthat/_snaps/ppc-distributions/ppc-dots-binwidth.svg similarity index 99% rename from tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-binwidth.new.svg rename to tests/testthat/_snaps/ppc-distributions/ppc-dots-binwidth.svg index ad4a5ff6..78c9415f 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-binwidth.new.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-dots-binwidth.svg @@ -848,6 +848,6 @@ r e p -ppc_qdotplot (binwidth) +ppc_dots (binwidth) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-default.new.svg b/tests/testthat/_snaps/ppc-distributions/ppc-dots-default.svg similarity index 99% rename from tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-default.new.svg rename to tests/testthat/_snaps/ppc-distributions/ppc-dots-default.svg index 56bf8f97..d39bf59f 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-default.new.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-dots-default.svg @@ -1131,6 +1131,6 @@ r e p -ppc_qdotplot (default) +ppc_dots (default) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile-binwidth.new.svg b/tests/testthat/_snaps/ppc-distributions/ppc-dots-quantile-binwidth.svg similarity index 99% rename from tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile-binwidth.new.svg rename to tests/testthat/_snaps/ppc-distributions/ppc-dots-quantile-binwidth.svg index 5a93daae..0ebf6d45 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile-binwidth.new.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-dots-quantile-binwidth.svg @@ -699,6 +699,6 @@ r e p -ppc_qdotplot (quantile-binwidth) +ppc_dots (quantile-binwidth) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile.new.svg b/tests/testthat/_snaps/ppc-distributions/ppc-dots-quantile.svg similarity index 99% rename from tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile.new.svg rename to tests/testthat/_snaps/ppc-distributions/ppc-dots-quantile.svg index 506e9ced..df31be97 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile.new.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-dots-quantile.svg @@ -699,6 +699,6 @@ r e p -ppc_qdotplot (quantile) +ppc_dots (quantile) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-binwidth.svg b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-binwidth.svg deleted file mode 100644 index fafdc7de..00000000 --- a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-binwidth.svg +++ /dev/null @@ -1,950 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --2 -0 -2 --2 -0 -2 --2 -0 -2 - - - - -y -y -r -e -p -ppc_qdotplot (binwidth) - - diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-default.svg b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-default.svg deleted file mode 100644 index 7a219b97..00000000 --- a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-default.svg +++ /dev/null @@ -1,1265 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --2 -0 -2 --2 -0 -2 --2 -0 -2 - - - - -y -y -r -e -p -ppc_qdotplot (default) - - diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile-binwidth.svg b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile-binwidth.svg deleted file mode 100644 index 3260ca6f..00000000 --- a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile-binwidth.svg +++ /dev/null @@ -1,867 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --2 --1 -0 -1 -2 -3 --2 --1 -0 -1 -2 -3 --2 --1 -0 -1 -2 -3 - - - - -y -y -r -e -p -ppc_qdotplot (quantile-binwidth) - - diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile.svg b/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile.svg deleted file mode 100644 index b8dd373d..00000000 --- a/tests/testthat/_snaps/ppc-distributions/ppc-qdotplot-quantile.svg +++ /dev/null @@ -1,869 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --2 --1 -0 -1 -2 -3 --2 --1 -0 -1 -2 -3 --2 --1 -0 -1 -2 -3 - - - - -y -y -r -e -p -ppc_qdotplot (quantile) - - diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-binwidth.new.svg b/tests/testthat/_snaps/ppc-distributions/ppd-dots-binwidth.svg similarity index 99% rename from tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-binwidth.new.svg rename to tests/testthat/_snaps/ppc-distributions/ppd-dots-binwidth.svg index 64ab32e3..0795a172 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-binwidth.new.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppd-dots-binwidth.svg @@ -715,6 +715,6 @@ -ppd_qdotplot (binwidth) +ppd_dots (binwidth) diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-default.new.svg b/tests/testthat/_snaps/ppc-distributions/ppd-dots-default.svg similarity index 99% rename from tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-default.new.svg rename to tests/testthat/_snaps/ppc-distributions/ppd-dots-default.svg index 6dcd41f0..84684e53 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-default.new.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppd-dots-default.svg @@ -1020,6 +1020,6 @@ -ppd_qdotplot (default) +ppd_dots (default) diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile-binwidth.new.svg b/tests/testthat/_snaps/ppc-distributions/ppd-dots-quantile-binwidth.svg similarity index 99% rename from tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile-binwidth.new.svg rename to tests/testthat/_snaps/ppc-distributions/ppd-dots-quantile-binwidth.svg index db99e744..4ccf85d5 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile-binwidth.new.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppd-dots-quantile-binwidth.svg @@ -634,6 +634,6 @@ -ppd_qdotplot (quantile-binwidth) +ppd_dots (quantile-binwidth) diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile.new.svg b/tests/testthat/_snaps/ppc-distributions/ppd-dots-quantile.svg similarity index 99% rename from tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile.new.svg rename to tests/testthat/_snaps/ppc-distributions/ppd-dots-quantile.svg index 20a76421..58765580 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile.new.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppd-dots-quantile.svg @@ -638,6 +638,6 @@ -ppd_qdotplot (quantile) +ppd_dots (quantile) diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-binwidth.svg b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-binwidth.svg deleted file mode 100644 index 08e1cfb9..00000000 --- a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-binwidth.svg +++ /dev/null @@ -1,809 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --2 -0 -2 --2 -0 -2 --2 -0 -2 -ppd_qdotplot (binwidth) - - diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-default.svg b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-default.svg deleted file mode 100644 index d097abd9..00000000 --- a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-default.svg +++ /dev/null @@ -1,1138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --2 -0 -2 --2 -0 -2 --2 -0 -2 -ppd_qdotplot (default) - - diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile-binwidth.svg b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile-binwidth.svg deleted file mode 100644 index 9b14e634..00000000 --- a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile-binwidth.svg +++ /dev/null @@ -1,780 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --2 --1 -0 -1 -2 -3 --2 --1 -0 -1 -2 -3 --2 --1 -0 -1 -2 -3 -ppd_qdotplot (quantile-binwidth) - - diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile.svg b/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile.svg deleted file mode 100644 index aea53bce..00000000 --- a/tests/testthat/_snaps/ppc-distributions/ppd-qdotplot-quantile.svg +++ /dev/null @@ -1,787 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --2 --1 -0 -1 -2 -3 --2 --1 -0 -1 -2 -3 --2 --1 -0 -1 -2 -3 -ppd_qdotplot (quantile) - - diff --git a/tests/testthat/test-ppc-distributions.R b/tests/testthat/test-ppc-distributions.R index a7e41dbd..6ab88d6e 100644 --- a/tests/testthat/test-ppc-distributions.R +++ b/tests/testthat/test-ppc-distributions.R @@ -58,19 +58,19 @@ test_that("ppc_dens,pp_hist,ppc_freqpoly,ppc_boxplot return ggplot objects", { expect_gg(ppd_boxplot(yrep2, notch = FALSE)) }) -test_that("ppc_qdotplot returns a ggplot object", { +test_that("ppc_dots returns a ggplot object", { testthat::skip_if_not_installed("ggdist") - expect_gg(ppc_qdotplot(y, yrep[1:8, ])) - expect_gg(ppc_qdotplot(y, yrep[1,, drop = FALSE], quantiles = 25)) - expect_gg(ppc_qdotplot(y, yrep[1:8, ], binwidth = 0.1)) - expect_gg(ppc_qdotplot(y2, yrep2, binwidth = 0.1, quantiles = 25)) + expect_gg(ppc_dots(y, yrep[1:8, ])) + expect_gg(ppc_dots(y, yrep[1,, drop = FALSE], quantiles = 25)) + expect_gg(ppc_dots(y, yrep[1:8, ], binwidth = 0.1)) + expect_gg(ppc_dots(y2, yrep2, binwidth = 0.1, quantiles = 25)) # ppd versions - expect_gg(ppd_qdotplot(yrep[1:8, ])) - expect_gg(ppd_qdotplot(yrep[1,, drop = FALSE], quantiles = 25)) - expect_gg(ppd_qdotplot(yrep[1:8, ], binwidth = 0.1)) - expect_gg(ppd_qdotplot(yrep2, binwidth = 0.1, quantiles = 25)) + expect_gg(ppd_dots(yrep[1:8, ])) + expect_gg(ppd_dots(yrep[1,, drop = FALSE], quantiles = 25)) + expect_gg(ppd_dots(yrep[1:8, ], binwidth = 0.1)) + expect_gg(ppd_dots(yrep2, binwidth = 0.1, quantiles = 25)) }) @@ -193,40 +193,40 @@ test_that("ppc_boxplot renders correctly", { vdiffr::expect_doppelganger("ppd_boxplot (alpha, size)", p_custom) }) -test_that("ppc_qdotplot renders correctly", { +test_that("ppc_dots renders correctly", { testthat::skip_on_cran() testthat::skip_if_not_installed("vdiffr") testthat::skip_if_not_installed("ggdist") skip_on_r_oldrel() - p_base <- ppc_qdotplot(vdiff_y, vdiff_yrep[1:8, ]) - vdiffr::expect_doppelganger("ppc_qdotplot (default)", p_base) + p_base <- ppc_dots(vdiff_y, vdiff_yrep[1:8, ]) + vdiffr::expect_doppelganger("ppc_dots (default)", p_base) - p_binwidth <- ppc_qdotplot(vdiff_y, vdiff_yrep[1:8, ], binwidth = 3) - expect_warning(vdiffr::expect_doppelganger("ppc_qdotplot (binwidth)", p_binwidth), - "The provided binwidth will cause dots to overflow the boundaries of the geometry.") + p_binwidth <- ppc_dots(vdiff_y, vdiff_yrep[1:8, ], binwidth = 3) + expect_warning(vdiffr::expect_doppelganger("ppc_dots (binwidth)", p_binwidth), + "The provided binwidth will cause dots to overflow the boundaries") - p_quantile <- ppc_qdotplot(vdiff_y, vdiff_yrep[1:8, ], quantiles = 50) - vdiffr::expect_doppelganger("ppc_qdotplot (quantile)", p_quantile) + p_quantile <- ppc_dots(vdiff_y, vdiff_yrep[1:8, ], quantiles = 50) + vdiffr::expect_doppelganger("ppc_dots (quantile)", p_quantile) - p_quantile_binwidth <- ppc_qdotplot(vdiff_y, vdiff_yrep[1:8, ], binwidth = 3, quantiles = 50) - expect_warning(vdiffr::expect_doppelganger("ppc_qdotplot (quantile-binwidth)", p_quantile_binwidth), - "The provided binwidth will cause dots to overflow the boundaries of the geometry.") + p_quantile_binwidth <- ppc_dots(vdiff_y, vdiff_yrep[1:8, ], binwidth = 3, quantiles = 50) + expect_warning(vdiffr::expect_doppelganger("ppc_dots (quantile-binwidth)", p_quantile_binwidth), + "The provided binwidth will cause dots to overflow the boundaries") # ppd versions - p_base <- ppd_qdotplot(vdiff_yrep[1:8, ]) - vdiffr::expect_doppelganger("ppd_qdotplot (default)", p_base) + p_base <- ppd_dots(vdiff_yrep[1:8, ]) + vdiffr::expect_doppelganger("ppd_dots (default)", p_base) - p_binwidth <- ppd_qdotplot(vdiff_yrep[1:8, ], binwidth = 3) - expect_warning(vdiffr::expect_doppelganger("ppd_qdotplot (binwidth)", p_binwidth), - "The provided binwidth will cause dots to overflow the boundaries of the geometry.") + p_binwidth <- ppd_dots(vdiff_yrep[1:8, ], binwidth = 3) + expect_warning(vdiffr::expect_doppelganger("ppd_dots (binwidth)", p_binwidth), + "The provided binwidth will cause dots to overflow the boundaries") - p_quantile <- ppd_qdotplot(vdiff_yrep[1:8, ], quantiles = 50) - vdiffr::expect_doppelganger("ppd_qdotplot (quantile)", p_quantile) + p_quantile <- ppd_dots(vdiff_yrep[1:8, ], quantiles = 50) + vdiffr::expect_doppelganger("ppd_dots (quantile)", p_quantile) - p_quantile_binwidth <- ppd_qdotplot(vdiff_yrep[1:8, ], binwidth = 3, quantiles = 50) - expect_warning(vdiffr::expect_doppelganger("ppd_qdotplot (quantile-binwidth)", p_quantile_binwidth), - "The provided binwidth will cause dots to overflow the boundaries of the geometry.") + p_quantile_binwidth <- ppd_dots(vdiff_yrep[1:8, ], binwidth = 3, quantiles = 50) + expect_warning(vdiffr::expect_doppelganger("ppd_dots (quantile-binwidth)", p_quantile_binwidth), + "The provided binwidth will cause dots to overflow the boundaries") }) test_that("ppc_ecdf_overlay renders correctly", { From 8a22488bf285252a2c751a5876874debc2c39e1f Mon Sep 17 00:00:00 2001 From: jgabry Date: Wed, 2 Jul 2025 10:35:39 -0600 Subject: [PATCH 7/8] Update ppc-distributions.R --- R/ppc-distributions.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/ppc-distributions.R b/R/ppc-distributions.R index cd81bbea..75bbe2b2 100644 --- a/R/ppc-distributions.R +++ b/R/ppc-distributions.R @@ -39,8 +39,8 @@ #' `yrep` should therefore contain only a small number of rows. See the #' **Examples** section. #' } -#' \item{`ppc_ecdf_overlay(), ppc_dens_overlay(), -#' ppc_ecdf_overlay_grouped(), ppc_dens_overlay_grouped()`}{ +#' \item{`ppc_ecdf_overlay()`, `ppc_dens_overlay()`, +#' `ppc_ecdf_overlay_grouped()`, `ppc_dens_overlay_grouped()`}{ #' Kernel density or empirical CDF estimates of each dataset (row) in #' `yrep` are overlaid, with the distribution of `y` itself on top #' (and in a darker shade). When using `ppc_ecdf_overlay()` with discrete From cd9f63fd274fcd8ef70769331a3279372296c403 Mon Sep 17 00:00:00 2001 From: jgabry Date: Wed, 2 Jul 2025 10:35:42 -0600 Subject: [PATCH 8/8] Update PPC-distributions.Rd --- man/PPC-distributions.Rd | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man/PPC-distributions.Rd b/man/PPC-distributions.Rd index c4646eac..628a3ad5 100644 --- a/man/PPC-distributions.Rd +++ b/man/PPC-distributions.Rd @@ -278,7 +278,8 @@ variable for \code{y} and each dataset (row) in \code{yrep}. For this plot \code{yrep} should therefore contain only a small number of rows. See the \strong{Examples} section. } -\item{\verb{ppc_ecdf_overlay(), ppc_dens_overlay(), ppc_ecdf_overlay_grouped(), ppc_dens_overlay_grouped()}}{ +\item{\code{ppc_ecdf_overlay()}, \code{ppc_dens_overlay()}, +\code{ppc_ecdf_overlay_grouped()}, \code{ppc_dens_overlay_grouped()}}{ Kernel density or empirical CDF estimates of each dataset (row) in \code{yrep} are overlaid, with the distribution of \code{y} itself on top (and in a darker shade). When using \code{ppc_ecdf_overlay()} with discrete