diff --git a/DESCRIPTION b/DESCRIPTION index b65812ce..ad495e67 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,7 +13,8 @@ Authors@R: c(person("Jonah", "Gabry", role = c("aut", "cre"), email = "jgabry@gm person("Teemu", "Sailynoja", role = "ctb"), person("Aki", "Vehtari", role = "ctb"), person("Behram", "Ulukır", role = "ctb"), - person("Visruth", "Srimath Kandali", role = "ctb")) + person("Visruth", "Srimath Kandali", role = "ctb"), + person("Mattan S.", "Ben-Shachar", role = "ctb")) Maintainer: Jonah Gabry Description: Plotting functions for posterior analysis, MCMC diagnostics, prior and posterior predictive checks, and other visualizations diff --git a/NEWS.md b/NEWS.md index fceb6a8f..9ad2e1dc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # bayesplot (development version) + +* New `show_marginal` argument to `ppd_*()` functions to show the PPD - the marginal predictive distribution by @mattansb (#425) * `ppc_ecdf_overlay()`, `ppc_ecdf_overlay_grouped()`, and `ppd_ecdf_overlay()` now always use `geom_step()`. The `discrete` argument is deprecated. * Fixed missing `drop = FALSE` in `nuts_params.CmdStanMCMC()`. * Replace `apply()` with `storage.mode()` for integer-to-numeric matrix conversion in `validate_predictions()`. diff --git a/R/helpers-gg.R b/R/helpers-gg.R index 989db1d7..29a1eee4 100644 --- a/R/helpers-gg.R +++ b/R/helpers-gg.R @@ -96,7 +96,7 @@ scale_color_ppc <- labels = NULL, ...) { scale_color_manual( - name = name %||% "", + name = name, values = values %||% get_color(c("dh", "lh")), labels = labels %||% c(y_label(), yrep_label()), ... @@ -109,7 +109,7 @@ scale_fill_ppc <- labels = NULL, ...) { scale_fill_manual( - name = name %||% "", + name = name, values = values %||% get_color(c("d", "l")), labels = labels %||% c(y_label(), yrep_label()), ... @@ -118,22 +118,77 @@ scale_fill_ppc <- scale_color_ppd <- function(name = NULL, - values = get_color("mh"), - labels = ypred_label(), + values = NULL, + labels = NULL, + highlight = TRUE, + show_marginal = FALSE, ...) { - scale_color_ppc(name = name, - values = values, - labels = labels, - ...) + if (isTRUE(show_marginal)) { + if (isTRUE(highlight)) { + cl <- c("dh", "lh") + } else { + cl <- c("d", "l") + } + default_values <- setNames(get_color(cl), nm = c("PPD", "ypred")) + } else { + if (isTRUE(highlight)) { + default_values <- get_color("mh") + } else { + default_values <- get_color("m") + } + } + + scale_color_ppc( + name = name, + values = values %||% default_values, + labels = labels %||% ypred_label(), + ... + ) } scale_fill_ppd <- function(name = NULL, - values = get_color("m"), - labels = ypred_label(), + values = NULL, + labels = NULL, + show_marginal = FALSE, ...) { - scale_fill_ppc(name = name, - values = values, - labels = labels, - ...) + if (isTRUE(show_marginal)) { + default_values <- c(PPD = "white", ypred = get_color("l")) + } else { + default_values <- get_color("m") + } + + scale_fill_ppc( + name = name, + values = values %||% default_values, + labels = labels %||% ypred_label(), + ... + ) + } + + +scale_linetype_ppd <- + function(name = NULL, + values = NULL, + labels = NULL, + ...) { + scale_linetype_manual( + name = name, + values = values %||% c(PPD = "5111", ypred = "solid"), + labels = labels %||% ypred_label(), + ... + ) + } + +scale_shape_ppd <- + function(name = NULL, + values = NULL, + labels = NULL, + ...) { + scale_shape_manual( + name = name, + values = values %||% c(ypred = 21, PPD = 23), + labels = labels %||% ypred_label(), + ... + ) } diff --git a/R/helpers-ppc.R b/R/helpers-ppc.R index 618b9fca..01fad36f 100644 --- a/R/helpers-ppc.R +++ b/R/helpers-ppc.R @@ -589,4 +589,9 @@ u_scale <- function(x) { create_rep_ids <- function(ids) paste('italic(y)[rep] (', ids, ")") y_label <- function() expression(italic(y)) yrep_label <- function() expression(italic(y)[rep]) -ypred_label <- function() expression(italic(y)[pred]) +ypred_label <- function() { + c( + PPD = "PPD", + ypred = expression(italic(y)[pred]) + ) +} diff --git a/R/ppd-distributions.R b/R/ppd-distributions.R index fca2d5ee..03b7e20f 100644 --- a/R/ppd-distributions.R +++ b/R/ppd-distributions.R @@ -10,6 +10,7 @@ #' #' @template args-ypred #' @inheritParams PPC-distributions +#' @param show_marginal Plot the marginal PPD along with the `ypred`s. #' #' @template details-binomial #' @template return-ggplot-or-data @@ -19,6 +20,7 @@ #' color_scheme_set("brightblue") #' preds <- example_yrep_draws() #' ppd_dens_overlay(ypred = preds[1:50, ]) +#' ppd_dens_overlay(ypred = preds[1:50, ], show_marginal = TRUE) #' ppc_dens_overlay(y = example_y_data(), yrep = preds[1:50, ]) #' NULL @@ -37,36 +39,32 @@ ppd_data <- function(ypred, group = NULL) { #' @rdname PPD-distributions #' @export ppd_dens_overlay <- - function(ypred, - ..., - size = 0.25, - alpha = 0.7, - trim = FALSE, - bw = "nrd0", - adjust = 1, - kernel = "gaussian", - bounds = NULL, - n_dens = 1024) { - check_ignored_arguments(...) - bounds <- validate_density_bounds(bounds) + function(ypred, + show_marginal = FALSE, + ..., + size = 0.25, + alpha = 0.7, + trim = FALSE, + bw = "nrd0", + adjust = 1, + kernel = "gaussian", + bounds = NULL, + n_dens = 1024) { + check_ignored_arguments(...) + bounds <- validate_density_bounds(bounds) - data <- ppd_data(ypred) - ggplot(data, mapping = aes(x = .data$value)) + - overlay_ppd_densities( - mapping = aes(group = .data$rep_id, color = "ypred"), + data <- ppd_data(ypred) + p <- ggplot(data, mapping = aes(x = .data$value)) + + overlay_ppd_densities( + mapping = aes(group = .data$rep_id, color = "ypred", linetype = "ypred"), linewidth = size, alpha = alpha, - trim = trim, - bw = bw, - adjust = adjust, - kernel = kernel, - bounds = bounds, - n = n_dens - ) + - scale_color_ppd( - values = get_color("m"), - guide = guide_legend( # in case user turns legend back on - override.aes = list(size = 2 * size, alpha = 1)) + trim = trim, + bw = bw, + adjust = adjust, + kernel = kernel, + bounds = bounds, + n = n_dens ) + bayesplot_theme_get() + dont_expand_axes() + @@ -74,7 +72,32 @@ ppd_dens_overlay <- xaxis_title(FALSE) + yaxis_text(FALSE) + yaxis_ticks(FALSE) + - legend_none() + scale_linetype_ppd() + + scale_color_ppd( + highlight = show_marginal, + show_marginal = show_marginal, + # in case user turns legend back on + guide = guide_legend( + override.aes = list(linewidth = 2 * size, alpha = 1) + ) + ) + + if (isTRUE(show_marginal)) { + p + + overlay_ppd_densities( + mapping = aes(color = "PPD", linetype = "PPD"), + linewidth = 1, + trim = trim, + bw = bw, + adjust = adjust, + kernel = kernel, + bounds = bounds, + n = n_dens + ) + } else { + p + legend_none() + } + } @@ -82,6 +105,7 @@ ppd_dens_overlay <- #' @export ppd_ecdf_overlay <- function(ypred, + show_marginal= FALSE, ..., discrete = deprecated(), pad = TRUE, @@ -98,7 +122,7 @@ ppd_ecdf_overlay <- } data <- ppd_data(ypred) - ggplot(data, mapping = aes(x = .data$value)) + + p <- ggplot(data, mapping = aes(x = .data$value)) + hline_at( c(0, 0.5, 1), linewidth = c(0.2, 0.1, 0.2), @@ -106,22 +130,37 @@ ppd_ecdf_overlay <- color = get_color("dh") ) + stat_ecdf( - mapping = aes(group = .data$rep_id, color = "ypred"), + mapping = aes(group = .data$rep_id, color = "ypred", linetype = "ypred"), geom = "step", linewidth = size, alpha = alpha, pad = pad ) + - scale_color_ppd( - values = get_color("m"), - guide = guide_legend( # in case user turns legend back on - override.aes = list(linewidth = 2 * size, alpha = 1)) - ) + scale_y_continuous(breaks = c(0, 0.5, 1)) + bayesplot_theme_get() + yaxis_title(FALSE) + xaxis_title(FALSE) + - legend_none() + scale_linetype_ppd() + + scale_color_ppd( + highlight = show_marginal, + show_marginal = show_marginal, + # in case user turns legend back on + guide = guide_legend( + override.aes = list(linewidth = 2 * size, alpha = 1) + ) + ) + + if (isTRUE(show_marginal)) { + p + + stat_ecdf( + mapping = aes(color = "PPD", linetype = "PPD"), + geom = "step", + linewidth = 1, + pad = pad + ) + } else { + p + legend_none() + } } @@ -129,6 +168,7 @@ ppd_ecdf_overlay <- #' @export ppd_dens <- function(ypred, + show_marginal = FALSE, ..., trim = FALSE, size = 0.5, @@ -138,73 +178,105 @@ ppd_dens <- bounds <- validate_density_bounds(bounds) data <- ppd_data(ypred) - ggplot(data, mapping = aes( - x = .data$value, - color = "ypred", - fill = "ypred" - )) + + p <- ggplot(data, mapping = aes(.data$value)) + geom_density( + aes(color = "ypred", + fill = "ypred"), linewidth = size, alpha = alpha, trim = trim, bounds = bounds ) + - 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) - } + bayesplot_theme_get() + + facet_wrap_parsed("rep_label") + + force_axes_in_facets() + + dont_expand_y_axis() + + yaxis_text(FALSE) + + yaxis_title(FALSE) + + yaxis_ticks(FALSE) + + xaxis_title(FALSE) + + facet_text(FALSE) + + scale_color_ppd(show_marginal = show_marginal) + + scale_fill_ppd(show_marginal = show_marginal) + + if (isTRUE(show_marginal)) { + data2 <- transform(data, rep_label = "PPD") + + p + + geom_density( + aes(color = "PPD", + fill = "PPD"), + linewidth = size * 1.5, + trim = trim, + bounds = bounds, + data = data2 + ) + } else { + p + + legend_none() + } + } #' @rdname PPD-distributions #' @export ppd_hist <- function(ypred, + show_marginal = FALSE, ..., binwidth = NULL, bins = NULL, breaks = NULL, - freq = TRUE) { + freq = !show_marginal) { check_ignored_arguments(...) data <- ppd_data(ypred) - ggplot(data, mapping = set_hist_aes( - freq, - color = "ypred", - fill = "ypred" - )) + + p <- ggplot(data, mapping = set_hist_aes(freq)) + geom_histogram( + aes(color = "ypred", + fill = "ypred"), linewidth = 0.25, binwidth = binwidth, bins = bins, breaks = breaks ) + - 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) + facet_text(FALSE) + + scale_color_ppd(show_marginal = show_marginal) + + scale_fill_ppd(show_marginal = show_marginal) + + if (isTRUE(show_marginal)) { + data2 <- transform(data, rep_label = "PPD") + + p + + geom_histogram( + aes(color = "PPD", + fill = "PPD"), + linewidth = 0.25, + binwidth = binwidth, + bins = bins, + breaks = breaks, + data = data2 + ) + + } else { + p + + legend_none() + } } #' @rdname PPD-distributions #' @export ppd_dots <- function(ypred, + show_marginal = FALSE, ..., binwidth = NA, quantiles = 100, @@ -214,28 +286,47 @@ ppd_dots <- suggested_package("ggdist") data <- ppd_data(ypred) - ggplot(data, mapping = set_hist_aes( - freq, - color = "ypred", - fill = "ypred" - )) + + + p <- ggplot(data, mapping = set_hist_aes(freq)) + ggdist::stat_dots( + aes(color = "ypred", + fill = "ypred", + shape = "ypred"), binwidth = binwidth, quantiles = quantiles, ... ) + - 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) + facet_text(FALSE) + + scale_shape_ppd() + + scale_color_ppd(show_marginal = show_marginal) + + scale_fill_ppd(show_marginal = show_marginal) + + if (isTRUE(show_marginal)) { + data2 <- transform(data, rep_label = "PPD") + + p + + ggdist::stat_dots( + aes(color = "PPD", + fill = "PPD", + shape = "PPD"), + data = data2, + binwidth = binwidth, + quantiles = quantiles, + ... + ) + + } else { + p + + legend_none() + } } @@ -243,10 +334,11 @@ ppd_dots <- #' @export ppd_freqpoly <- function(ypred, + show_marginal = FALSE, ..., binwidth = NULL, bins = NULL, - freq = TRUE, + freq = !show_marginal, size = 0.5, alpha = 1) { @@ -257,12 +349,10 @@ ppd_freqpoly <- } data <- ppd_data(ypred, group = dots$group) - ggplot(data, mapping = set_hist_aes( - freq, - color = "ypred", - fill = "ypred" - )) + + p <- ggplot(data, mapping = set_hist_aes(freq)) + geom_area( + aes(color = "ypred", + fill = "ypred"), stat = "bin", binwidth = binwidth, bins = bins, @@ -270,8 +360,6 @@ ppd_freqpoly <- alpha = alpha ) + facet_wrap_parsed("rep_label") + - scale_color_ppd() + - scale_fill_ppd() + bayesplot_theme_get() + force_axes_in_facets() + dont_expand_y_axis() + @@ -280,7 +368,28 @@ ppd_freqpoly <- yaxis_ticks(FALSE) + xaxis_title(FALSE) + facet_text(FALSE) + - legend_none() + scale_color_ppd(show_marginal = show_marginal) + + scale_fill_ppd(show_marginal = show_marginal) + + + if (isTRUE(show_marginal)) { + data2 <- transform(data, rep_label = "PPD") + + p + + geom_area( + aes(color = "PPD", + fill = "PPD"), + data = data2, + stat = "bin", + binwidth = binwidth, + bins = bins, + linewidth = size * 1.5, + ) + + } else { + p + + legend_none() + } } @@ -289,10 +398,11 @@ ppd_freqpoly <- ppd_freqpoly_grouped <- function(ypred, group, + show_marginal = FALSE, ..., binwidth = NULL, bins = NULL, - freq = TRUE, + freq = !show_marginal, size = 0.5, alpha = 1) { @@ -315,6 +425,7 @@ ppd_freqpoly_grouped <- #' @export ppd_boxplot <- function(ypred, + show_marginal = FALSE, ..., notch = TRUE, size = 0.5, @@ -322,13 +433,13 @@ ppd_boxplot <- check_ignored_arguments(...) data <- ppd_data(ypred) - ggplot(data, mapping = aes( + p <- ggplot(data, mapping = aes( x = .data$rep_label, - y = .data$value, - color = "ypred", - fill = "ypred" + y = .data$value )) + geom_boxplot( + aes(color = "ypred", + fill = "ypred"), notch = notch, linewidth = size, alpha = alpha, @@ -336,15 +447,31 @@ ppd_boxplot <- outlier.alpha = 2/3, outlier.size = 1 ) + - scale_color_ppd() + - scale_fill_ppd() + + scale_color_ppd(show_marginal = show_marginal) + + scale_fill_ppd(show_marginal = show_marginal) + scale_x_discrete(labels = function(x) parse(text=x)) + bayesplot_theme_get() + yaxis_title(FALSE) + xaxis_ticks(FALSE) + xaxis_text(FALSE) + - xaxis_title(FALSE) + - legend_none() + xaxis_title(FALSE) + + if (isTRUE(show_marginal)) { + p + + geom_boxplot( + aes(x = "PPD", + color = "PPD", + fill = "PPD"), + notch = notch, + linewidth = size * 1.5, + outlier.color = get_color("dh"), + outlier.alpha = 2/3, + outlier.size = 1 + ) + + } else { + p + legend_none() + } } diff --git a/R/ppd-test-statistics.R b/R/ppd-test-statistics.R index f1c9d07d..5e1049cb 100644 --- a/R/ppd-test-statistics.R +++ b/R/ppd-test-statistics.R @@ -13,6 +13,7 @@ #' #' @template args-ypred #' @inheritParams PPC-test-statistics +#' @inheritParams PPD-distributions #' #' @template details-binomial #' @template return-ggplot-or-data @@ -22,11 +23,13 @@ #' yrep <- example_yrep_draws() #' ppd_stat(yrep) #' ppd_stat(yrep, stat = "sd") + legend_none() +#' ppd_stat(yrep, show_marginal = TRUE) #' #' # use your own function for the 'stat' argument #' color_scheme_set("brightblue") #' q25 <- function(y) quantile(y, 0.25) #' ppd_stat(yrep, stat = "q25") # legend includes function name +#' ppd_stat(yrep, stat = "q25", show_marginal = TRUE) NULL #' @rdname PPD-test-statistics @@ -34,12 +37,13 @@ NULL ppd_stat <- function(ypred, stat = "mean", + show_marginal = FALSE, ..., discrete = FALSE, binwidth = NULL, bins = NULL, breaks = NULL, - freq = TRUE) { + freq = !show_marginal) { stopifnot(length(stat) == 1) dots <- list(...) if (!from_grouped(dots)) { @@ -50,34 +54,73 @@ ppd_stat <- data <- ppd_stat_data( ypred = ypred, group = dots$group, - stat = match.fun(stat) + stat = match.fun(stat), + show_marginal = show_marginal ) + data$type <- ifelse(grepl("ypred", data$variable), "ypred", "PPD") + graph <- ggplot(data, mapping = set_hist_aes( - freq, - color = "ypred", - fill = "ypred" + freq || discrete, # this is needed because geom_bar fails otherwise + color = .data$type, + fill = .data$type )) - graph <- graph + if (discrete) { - geom_bar( - color = get_color("lh"), - linewidth = 0.25, - na.rm = TRUE, - position = "identity", - ) + + if (discrete) { + graph <- graph + + geom_bar( + data = data[data$type != "PPD",], + linewidth = 0.25, + na.rm = TRUE, + position = "identity", + ) + } else { + graph <- graph + + geom_histogram( + data = data[data$type != "PPD",], + linewidth = 0.25, + na.rm = TRUE, + binwidth = binwidth, + bins = bins, + breaks = breaks + ) } - else { - geom_histogram( - linewidth = 0.25, - na.rm = TRUE, - binwidth = binwidth, - bins = bins, - breaks = breaks - ) } - graph + - scale_color_ppd(guide = "none") + - scale_fill_ppd(labels = Typred_label(), guide = guide_legend( - title = stat_legend_title(stat, deparse(substitute(stat))) - )) + + + if (isTRUE(show_marginal)) { + graph <- graph + + geom_vline( + aes(xintercept = .data$value, + color = .data$type, + linetype = .data$type), + data = data[data$type == "PPD",], + linewidth = 1.5 + ) + } + + stat_title <- stat_legend_title(stat, deparse(substitute(stat))) + + if (isTRUE(show_marginal)) { + graph <- graph + + scale_color_ppd( + name = stat_title, + labels = Typred_label(), + guide = guide_legend(override.aes = list( + fill = get_color(c("d", "l"))) + ), + show_marginal = show_marginal + ) + + scale_fill_ppd(guide = "none", + show_marginal = show_marginal) + + scale_linetype_ppd(guide = "none") + } else { + graph <- graph + + scale_fill_ppd(name = stat_title, + labels = Typred_label(), + show_marginal = show_marginal) + + scale_color_ppd(guide = "none", + show_marginal = show_marginal) + } + + graph + bayesplot_theme_get() + dont_expand_y_axis() + xaxis_title(FALSE) + @@ -93,13 +136,14 @@ ppd_stat_grouped <- function(ypred, group, stat = "mean", + show_marginal = FALSE, ..., discrete = FALSE, facet_args = list(), binwidth = NULL, bins = NULL, breaks = NULL, - freq = TRUE) { + freq = !show_marginal) { check_ignored_arguments(...) call <- match.call(expand.dots = FALSE) g <- eval(ungroup_call("ppd_stat", call), parent.frame()) @@ -114,6 +158,7 @@ ppd_stat_grouped <- ppd_stat_freqpoly <- function(ypred, stat = "mean", + show_marginal = FALSE, ..., facet_args = list(), binwidth = NULL, @@ -129,19 +174,28 @@ ppd_stat_freqpoly <- data <- ppd_stat_data( ypred = ypred, group = dots$group, - stat = match.fun(stat) + stat = match.fun(stat), + show_marginal = show_marginal ) - ggplot(data, mapping = set_hist_aes(freq)) + + data$type <- ifelse(grepl("ypred", data$variable), "ypred", "PPD") + + p <- ggplot(data, mapping = set_hist_aes(freq, color = .data$type)) + geom_freqpoly( - aes(color = "ypred"), linewidth = 0.5, na.rm = TRUE, binwidth = binwidth, - bins = bins + bins = bins, + data = data[data$type != "PPD",] ) + scale_color_ppd( name = stat_legend_title(stat, deparse(substitute(stat))), - labels = Typred_label() + labels = Typred_label(), + show_marginal = show_marginal, + values = if (show_marginal) { + set_names(get_color(c("m", "dh")), c("ypred", "PPD")) + } else { + get_color("mh") + } ) + dont_expand_y_axis(expansion(mult = 0.005, add = 0)) + bayesplot_theme_get() + @@ -149,6 +203,19 @@ ppd_stat_freqpoly <- yaxis_text(FALSE) + yaxis_ticks(FALSE) + yaxis_title(FALSE) + + if (isTRUE(show_marginal)) { + p <- p + + geom_vline( + aes(xintercept = .data$value, color = .data$type, linetype = .data$type), + data = data[data$type == "PPD",], + key_glyph = "path", + linewidth = 1 + ) + + scale_linetype_ppd(guide = "none") + } + + p } @@ -158,6 +225,7 @@ ppd_stat_freqpoly_grouped <- function(ypred, group, stat = "mean", + show_marginal = FALSE, ..., facet_args = list(), binwidth = NULL, @@ -177,6 +245,7 @@ ppd_stat_freqpoly_grouped <- ppd_stat_2d <- function(ypred, stat = c("mean", "sd"), + show_marginal = FALSE, ..., size = 2.5, alpha = 0.7) { @@ -196,30 +265,55 @@ ppd_stat_2d <- data <- ppd_stat_data( ypred = ypred, group = NULL, - stat = c(match.fun(stat[[1]]), match.fun(stat[[2]])) + stat = c(match.fun(stat[[1]]), match.fun(stat[[2]])), + show_marginal = show_marginal ) - ggplot(data) + + data$type <- ifelse(grepl("ypred", data$variable), "ypred", "PPD") + + graph <- ggplot() + geom_point( mapping = aes( x = .data$value, y = .data$value2, - fill = "ypred", - color = "ypred" + fill = .data$type, + color = .data$type, + shape = .data$type ), - shape = 21, + data = data[data$type == "ypred", ], size = size, alpha = alpha ) + - scale_fill_ppd(lgnd_title, labels = Typred_label()) + - scale_color_ppd(lgnd_title, labels = Typred_label()) + + scale_shape_ppd(lgnd_title, labels = Typred_label()) + + scale_fill_ppd(lgnd_title, labels = Typred_label(), + show_marginal = show_marginal) + + scale_color_ppd(lgnd_title, labels = Typred_label(), + show_marginal = show_marginal) + labs(x = stat_labs[1], y = stat_labs[2]) + bayesplot_theme_get() + + if (show_marginal) { + graph <- graph + + geom_point( + mapping = aes( + x = .data$value, + y = .data$value2, + fill = .data$type, + color = .data$type, + shape = .data$type + ), + data = data[data$type == "PPD", ], + size = size * 1.5, + stroke = 0.75 + ) + } + + graph } #' @rdname PPD-test-statistics #' @export -ppd_stat_data <- function(ypred, group = NULL, stat) { +ppd_stat_data <- function(ypred, group = NULL, stat, show_marginal = FALSE) { if (!(length(stat) %in% 1:2)) { abort("'stat' must have length 1 or 2.") } @@ -239,7 +333,8 @@ ppd_stat_data <- function(ypred, group = NULL, stat) { predictions = ypred, y = NULL, group = group, - stat = stat + stat = stat, + show_marginal = show_marginal ) } @@ -263,7 +358,7 @@ ppd_stat_data <- function(ypred, group = NULL, stat) { #' ppc_stat_data(y, yrep, group, stat = "median") #' #' @importFrom dplyr group_by ungroup summarise rename -.ppd_stat_data <- function(predictions, y = NULL, group = NULL, stat) { +.ppd_stat_data <- function(predictions, y = NULL, group = NULL, stat, show_marginal = FALSE) { stopifnot(length(stat) %in% c(1,2)) if (length(stat) == 1) { stopifnot(is.function(stat)) # sanity check, should already be validated @@ -292,10 +387,10 @@ ppd_stat_data <- function(ypred, group = NULL, stat) { ) colnames(d) <- gsub(".", "_", colnames(d), fixed = TRUE) molten_d <- reshape2::melt(d, id.vars = "group") - molten_d <- group_by(molten_d, .data$group, .data$variable) data <- molten_d %>% + group_by(.data$group, .data$variable) %>% summarise( value1 = stat1(.data$value), value2 = if (!is.null(stat2)) @@ -304,6 +399,22 @@ ppd_stat_data <- function(ypred, group = NULL, stat) { rename(value = "value1") %>% ungroup() + if (isTRUE(show_marginal)) { + data_ppd <- molten_d %>% + dplyr::filter(.data$variable != "y") %>% + group_by(.data$group) %>% + summarise( + variable = "PPD", + value1 = stat1(.data$value), + value2 = if (!is.null(stat2)) + stat2(.data$value) else NA + ) %>% + rename(value = "value1") %>% + ungroup() + + data <- rbind(data, data_ppd) + } + if (is.null(stat2)) { data$value2 <- NULL } @@ -328,4 +439,7 @@ stat_group_facets <- function(facet_args, scales_default = "free") { do.call("facet_wrap", facet_args) } -Typred_label <- function() expression(italic(T)(italic(y)[pred])) +Typred_label <- function() { + expression(PPD = italic(T)(PPD), + ypred = italic(T)(italic(y)[pred])) +} diff --git a/man/PPD-distributions.Rd b/man/PPD-distributions.Rd index 7517ec25..7351d084 100644 --- a/man/PPD-distributions.Rd +++ b/man/PPD-distributions.Rd @@ -17,6 +17,7 @@ ppd_data(ypred, group = NULL) ppd_dens_overlay( ypred, + show_marginal = FALSE, ..., size = 0.25, alpha = 0.7, @@ -30,6 +31,7 @@ ppd_dens_overlay( ppd_ecdf_overlay( ypred, + show_marginal = FALSE, ..., discrete = deprecated(), pad = TRUE, @@ -37,18 +39,42 @@ ppd_ecdf_overlay( alpha = 0.7 ) -ppd_dens(ypred, ..., trim = FALSE, size = 0.5, alpha = 1, bounds = NULL) +ppd_dens( + ypred, + show_marginal = FALSE, + ..., + trim = FALSE, + size = 0.5, + alpha = 1, + bounds = NULL +) -ppd_hist(ypred, ..., binwidth = NULL, bins = NULL, breaks = NULL, freq = TRUE) +ppd_hist( + ypred, + show_marginal = FALSE, + ..., + binwidth = NULL, + bins = NULL, + breaks = NULL, + freq = !show_marginal +) -ppd_dots(ypred, ..., binwidth = NA, quantiles = 100, freq = TRUE) +ppd_dots( + ypred, + show_marginal = FALSE, + ..., + binwidth = NA, + quantiles = 100, + freq = TRUE +) ppd_freqpoly( ypred, + show_marginal = FALSE, ..., binwidth = NULL, bins = NULL, - freq = TRUE, + freq = !show_marginal, size = 0.5, alpha = 1 ) @@ -56,15 +82,23 @@ ppd_freqpoly( ppd_freqpoly_grouped( ypred, group, + show_marginal = FALSE, ..., binwidth = NULL, bins = NULL, - freq = TRUE, + freq = !show_marginal, size = 0.5, alpha = 1 ) -ppd_boxplot(ypred, ..., notch = TRUE, size = 0.5, alpha = 1) +ppd_boxplot( + ypred, + show_marginal = FALSE, + ..., + notch = TRUE, + size = 0.5, + alpha = 1 +) } \arguments{ \item{ypred}{An \code{S} by \code{N} matrix of draws from the posterior (or prior) @@ -77,6 +111,8 @@ 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{show_marginal}{Plot the marginal PPD along with the \code{ypred}s.} + \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 @@ -142,6 +178,7 @@ the input contains the "success" \emph{proportions} (not discrete color_scheme_set("brightblue") preds <- example_yrep_draws() ppd_dens_overlay(ypred = preds[1:50, ]) +ppd_dens_overlay(ypred = preds[1:50, ], show_marginal = TRUE) ppc_dens_overlay(y = example_y_data(), yrep = preds[1:50, ]) } diff --git a/man/PPD-test-statistics.Rd b/man/PPD-test-statistics.Rd index 7c8b41f3..d699c94d 100644 --- a/man/PPD-test-statistics.Rd +++ b/man/PPD-test-statistics.Rd @@ -14,30 +14,33 @@ ppd_stat( ypred, stat = "mean", + show_marginal = FALSE, ..., discrete = FALSE, binwidth = NULL, bins = NULL, breaks = NULL, - freq = TRUE + freq = !show_marginal ) ppd_stat_grouped( ypred, group, stat = "mean", + show_marginal = FALSE, ..., discrete = FALSE, facet_args = list(), binwidth = NULL, bins = NULL, breaks = NULL, - freq = TRUE + freq = !show_marginal ) ppd_stat_freqpoly( ypred, stat = "mean", + show_marginal = FALSE, ..., facet_args = list(), binwidth = NULL, @@ -49,6 +52,7 @@ ppd_stat_freqpoly_grouped( ypred, group, stat = "mean", + show_marginal = FALSE, ..., facet_args = list(), binwidth = NULL, @@ -56,9 +60,16 @@ ppd_stat_freqpoly_grouped( freq = TRUE ) -ppd_stat_2d(ypred, stat = c("mean", "sd"), ..., size = 2.5, alpha = 0.7) +ppd_stat_2d( + ypred, + stat = c("mean", "sd"), + show_marginal = FALSE, + ..., + size = 2.5, + alpha = 0.7 +) -ppd_stat_data(ypred, group = NULL, stat) +ppd_stat_data(ypred, group = NULL, stat, show_marginal = FALSE) } \arguments{ \item{ypred}{An \code{S} by \code{N} matrix of draws from the posterior (or prior) @@ -73,6 +84,8 @@ statistic. If specified as a string (or strings) then the legend will display the function name(s). If specified as a function (or functions) then generic naming is used in the legend.} +\item{show_marginal}{Plot the marginal PPD along with the \code{ypred}s.} + \item{...}{Currently unused.} \item{discrete}{For \code{ppc_stat()} and \code{ppc_stat_grouped()}, if \code{TRUE} then a @@ -130,11 +143,13 @@ the input contains the "success" \emph{proportions} (not discrete yrep <- example_yrep_draws() ppd_stat(yrep) ppd_stat(yrep, stat = "sd") + legend_none() +ppd_stat(yrep, show_marginal = TRUE) # use your own function for the 'stat' argument color_scheme_set("brightblue") q25 <- function(y) quantile(y, 0.25) ppd_stat(yrep, stat = "q25") # legend includes function name +ppd_stat(yrep, stat = "q25", show_marginal = TRUE) } \references{ Gabry, J. , Simpson, D. , Vehtari, A. , Betancourt, M. and diff --git a/man/bayesplot-package.Rd b/man/bayesplot-package.Rd index 77583399..9cbece9c 100644 --- a/man/bayesplot-package.Rd +++ b/man/bayesplot-package.Rd @@ -133,6 +133,7 @@ Other contributors: \item Aki Vehtari [contributor] \item Behram Ulukır [contributor] \item Visruth Srimath Kandali [contributor] + \item Mattan S. Ben-Shachar [contributor] } } diff --git a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-default-2.svg b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-default-2.svg index 197d6d8b..0e018848 100644 --- a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-default-2.svg +++ b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-default-2.svg @@ -61,13 +61,13 @@ 15 20 25 - - -y -y -r -e -p + + +y +y +r +e +p ppc_km_overlay (default 2) diff --git a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-default.svg b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-default.svg index 0bd7bfce..64a04fc1 100644 --- a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-default.svg +++ b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-default.svg @@ -61,13 +61,13 @@ 3 4 5 - - -y -y -r -e -p + + +y +y +r +e +p ppc_km_overlay (default) diff --git a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-default-2.svg b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-default-2.svg index b479b7db..fa9c4847 100644 --- a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-default-2.svg +++ b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-default-2.svg @@ -121,13 +121,13 @@ - - -y -y -r -e -p + + +y +y +r +e +p ppc_km_overlay_grouped (default 2) diff --git a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-default.svg b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-default.svg index 9c575ff8..d0261a00 100644 --- a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-default.svg +++ b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-default.svg @@ -121,13 +121,13 @@ - - -y -y -r -e -p + + +y +y +r +e +p ppc_km_overlay_grouped (default) diff --git a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-left-truncation-y.svg b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-left-truncation-y.svg index a8ea0277..50b0c93f 100644 --- a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-left-truncation-y.svg +++ b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-left-truncation-y.svg @@ -121,13 +121,13 @@ - - -y -y -r -e -p + + +y +y +r +e +p ppc_km_overlay_grouped (left_truncation_y) diff --git a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-max-extrapolation.svg b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-max-extrapolation.svg index 9631fbba..f6e15354 100644 --- a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-max-extrapolation.svg +++ b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-max-extrapolation.svg @@ -117,13 +117,13 @@ - - -y -y -r -e -p + + +y +y +r +e +p ppc_km_overlay_grouped (max extrapolation) diff --git a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-no-extrapolation.svg b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-no-extrapolation.svg index 7b9e4de6..38298470 100644 --- a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-no-extrapolation.svg +++ b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-no-extrapolation.svg @@ -117,13 +117,13 @@ - - -y -y -r -e -p + + +y +y +r +e +p ppc_km_overlay_grouped (no extrapolation) diff --git a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-size-alpha.svg b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-size-alpha.svg index 47b9fa1a..45e221ea 100644 --- a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-size-alpha.svg +++ b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-grouped-size-alpha.svg @@ -121,13 +121,13 @@ - - -y -y -r -e -p + + +y +y +r +e +p ppc_km_overlay_grouped (size, alpha) diff --git a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-left-truncation-y.svg b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-left-truncation-y.svg index 2feec397..062f3332 100644 --- a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-left-truncation-y.svg +++ b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-left-truncation-y.svg @@ -61,13 +61,13 @@ 15 20 25 - - -y -y -r -e -p + + +y +y +r +e +p ppc_km_overlay (left_truncation_y) diff --git a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-max-extrapolation.svg b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-max-extrapolation.svg index 62e16eeb..e6aa9aba 100644 --- a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-max-extrapolation.svg +++ b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-max-extrapolation.svg @@ -59,13 +59,13 @@ 20 30 40 - - -y -y -r -e -p + + +y +y +r +e +p ppc_km_overlay (max extrapolation) diff --git a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-no-extrapolation.svg b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-no-extrapolation.svg index cd7ca333..fa16077e 100644 --- a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-no-extrapolation.svg +++ b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-no-extrapolation.svg @@ -59,13 +59,13 @@ 10 15 20 - - -y -y -r -e -p + + +y +y +r +e +p ppc_km_overlay (no extrapolation) diff --git a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-size-alpha.svg b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-size-alpha.svg index e2b51820..761426e9 100644 --- a/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-size-alpha.svg +++ b/tests/testthat/_snaps/ppc-censoring/ppc-km-overlay-size-alpha.svg @@ -61,13 +61,13 @@ 3 4 5 - - -y -y -r -e -p + + +y +y +r +e +p ppc_km_overlay (size, alpha) diff --git a/tests/testthat/_snaps/ppc-discrete/ppc-bars-default.svg b/tests/testthat/_snaps/ppc-discrete/ppc-bars-default.svg index eebaca55..59b7bb7c 100644 --- a/tests/testthat/_snaps/ppc-discrete/ppc-bars-default.svg +++ b/tests/testthat/_snaps/ppc-discrete/ppc-bars-default.svg @@ -76,8 +76,8 @@ r e p - -y + +y ppc_bars (default) diff --git a/tests/testthat/_snaps/ppc-discrete/ppc-bars-grouped-default.svg b/tests/testthat/_snaps/ppc-discrete/ppc-bars-grouped-default.svg index f315b86b..4be3a5a8 100644 --- a/tests/testthat/_snaps/ppc-discrete/ppc-bars-grouped-default.svg +++ b/tests/testthat/_snaps/ppc-discrete/ppc-bars-grouped-default.svg @@ -140,8 +140,8 @@ r e p - -y + +y ppc_bars_grouped (default) diff --git a/tests/testthat/_snaps/ppc-discrete/ppc-bars-grouped-facet-args-prob-size.svg b/tests/testthat/_snaps/ppc-discrete/ppc-bars-grouped-facet-args-prob-size.svg index ada88498..df089587 100644 --- a/tests/testthat/_snaps/ppc-discrete/ppc-bars-grouped-facet-args-prob-size.svg +++ b/tests/testthat/_snaps/ppc-discrete/ppc-bars-grouped-facet-args-prob-size.svg @@ -138,8 +138,8 @@ r e p - -y + +y ppc_bars_grouped (facet_args, prob, size) diff --git a/tests/testthat/_snaps/ppc-discrete/ppc-bars-prob-0-33-width-size-fatten.svg b/tests/testthat/_snaps/ppc-discrete/ppc-bars-prob-0-33-width-size-fatten.svg index fd35e987..0da7d859 100644 --- a/tests/testthat/_snaps/ppc-discrete/ppc-bars-prob-0-33-width-size-fatten.svg +++ b/tests/testthat/_snaps/ppc-discrete/ppc-bars-prob-0-33-width-size-fatten.svg @@ -78,8 +78,8 @@ r e p - -y + +y ppc_bars (prob=0.33, width, size, fatten) diff --git a/tests/testthat/_snaps/ppc-discrete/ppc-bars-width-size-fatten.svg b/tests/testthat/_snaps/ppc-discrete/ppc-bars-width-size-fatten.svg index c473580a..c0eff814 100644 --- a/tests/testthat/_snaps/ppc-discrete/ppc-bars-width-size-fatten.svg +++ b/tests/testthat/_snaps/ppc-discrete/ppc-bars-width-size-fatten.svg @@ -76,8 +76,8 @@ r e p - -y + +y ppc_bars (width, size, fatten) diff --git a/tests/testthat/_snaps/ppc-discrete/ppc-rootogram-grouped-style-discrete-prob-size.svg b/tests/testthat/_snaps/ppc-discrete/ppc-rootogram-grouped-style-discrete-prob-size.svg deleted file mode 100644 index b5e5448b..00000000 --- a/tests/testthat/_snaps/ppc-discrete/ppc-rootogram-grouped-style-discrete-prob-size.svg +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -1 - - - - - - - - - -2 - - - - - - - - - -0 -1 -2 -3 -4 -5 - - - - - - - -0 -1 -2 -3 -4 -5 - - - - - - -0.0 -2.5 -5.0 -7.5 - - - - -y -Count -y - -w -i -t -h -i -n - -b -o -u -n -d -s - - -In -Out - - -y -r -e -p -ppc_rootogram_grouped (style='discrete', prob, size) - - diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-boxplot-alpha-size.svg b/tests/testthat/_snaps/ppc-distributions/ppc-boxplot-alpha-size.svg index f9b70a1c..9bb9d175 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-boxplot-alpha-size.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-boxplot-alpha-size.svg @@ -83,23 +83,23 @@ - - - - - - - - - - - - -y -y -r -e -p + + + + + + + + + + + + +y +y +r +e +p ppc_boxplot (alpha, size) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-boxplot-default.svg b/tests/testthat/_snaps/ppc-distributions/ppc-boxplot-default.svg index 7d4f66b1..6390c468 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-boxplot-default.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-boxplot-default.svg @@ -83,23 +83,23 @@ - - - - - - - - - - - - -y -y -r -e -p + + + + + + + + + + + + +y +y +r +e +p ppc_boxplot (default) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-boxplot-no-notch.svg b/tests/testthat/_snaps/ppc-distributions/ppc-boxplot-no-notch.svg index f09f3408..c9fc2b48 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-boxplot-no-notch.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-boxplot-no-notch.svg @@ -83,23 +83,23 @@ - - - - - - - - - - - - -y -y -r -e -p + + + + + + + + + + + + +y +y +r +e +p ppc_boxplot (no notch) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-dens-default.svg b/tests/testthat/_snaps/ppc-distributions/ppc-dens-default.svg index 275507ac..2f5d2fba 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-dens-default.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-dens-default.svg @@ -159,15 +159,15 @@ - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_dens (default) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-alpha-size.svg b/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-alpha-size.svg index 2f87f1d6..d2f94500 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-alpha-size.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-alpha-size.svg @@ -61,13 +61,13 @@ -2 0 2 - - -y -y -r -e -p + + +y +y +r +e +p ppc_dens_overlay (alpha, size) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-bounds.svg b/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-bounds.svg index 6447bbf8..7fc77e88 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-bounds.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-bounds.svg @@ -63,13 +63,13 @@ 1 2 3 - - -y -y -r -e -p + + +y +y +r +e +p ppc_dens_overlay (bounds) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-default.svg b/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-default.svg index e1148d09..342c233e 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-default.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-default.svg @@ -61,13 +61,13 @@ -2 0 2 - - -y -y -r -e -p + + +y +y +r +e +p ppc_dens_overlay (default) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-grouped-alpha-size.svg b/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-grouped-alpha-size.svg index 5a55e575..cae810c4 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-grouped-alpha-size.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-grouped-alpha-size.svg @@ -222,13 +222,13 @@ 2 - - -y -y -r -e -p + + +y +y +r +e +p ppc_dens_overlay_grouped (alpha, size) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-grouped-default.svg b/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-grouped-default.svg index 663e2fab..ba6f5d9e 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-grouped-default.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-dens-overlay-grouped-default.svg @@ -222,13 +222,13 @@ 2 - - -y -y -r -e -p + + +y +y +r +e +p ppc_dens_overlay_grouped (default) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-dots-binwidth.svg b/tests/testthat/_snaps/ppc-distributions/ppc-dots-binwidth.svg index e306840e..15eecdfd 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-dots-binwidth.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-dots-binwidth.svg @@ -758,15 +758,15 @@ - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_dots (binwidth) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-dots-default.svg b/tests/testthat/_snaps/ppc-distributions/ppc-dots-default.svg index 081205dc..1cf466c1 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-dots-default.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-dots-default.svg @@ -1041,15 +1041,15 @@ - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_dots (default) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-dots-quantile-binwidth.svg b/tests/testthat/_snaps/ppc-distributions/ppc-dots-quantile-binwidth.svg index 74655216..bda60c3d 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-dots-quantile-binwidth.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-dots-quantile-binwidth.svg @@ -609,15 +609,15 @@ - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_dots (quantile-binwidth) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-dots-quantile.svg b/tests/testthat/_snaps/ppc-distributions/ppc-dots-quantile.svg index 62e017a9..fb0dbce1 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-dots-quantile.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-dots-quantile.svg @@ -609,15 +609,15 @@ - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_dots (quantile) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-default.svg b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-default.svg index 4b7eac4c..ffe9c82a 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-default.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-default.svg @@ -61,13 +61,13 @@ 3 4 5 - - -y -y -r -e -p + + +y +y +r +e +p ppc_ecdf_overlay (default) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-default.svg b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-default.svg index fdd8a439..d75e2c2d 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-default.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-default.svg @@ -121,13 +121,13 @@ - - -y -y -r -e -p + + +y +y +r +e +p ppc_ecdf_overlay_grouped (default) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-size-alpha.svg b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-size-alpha.svg index f42c9330..456f6a56 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-size-alpha.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-size-alpha.svg @@ -121,13 +121,13 @@ - - -y -y -r -e -p + + +y +y +r +e +p ppc_ecdf_overlay_grouped (size, alpha) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-size-alpha.svg b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-size-alpha.svg index e1091089..110688d4 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-size-alpha.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-size-alpha.svg @@ -61,13 +61,13 @@ 3 4 5 - - -y -y -r -e -p + + +y +y +r +e +p ppc_ecdf_overlay (size, alpha) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-freqpoly-alpha-binwidth-size.svg b/tests/testthat/_snaps/ppc-distributions/ppc-freqpoly-alpha-binwidth-size.svg index 5fb2acd0..6b4bd675 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-freqpoly-alpha-binwidth-size.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-freqpoly-alpha-binwidth-size.svg @@ -171,15 +171,15 @@ - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_freqpoly (alpha, binwidth, size) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-freqpoly-default.svg b/tests/testthat/_snaps/ppc-distributions/ppc-freqpoly-default.svg index 7bbb5856..aa45b98a 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-freqpoly-default.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-freqpoly-default.svg @@ -159,15 +159,15 @@ - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_freqpoly (default) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-freqpoly-grouped-default.svg b/tests/testthat/_snaps/ppc-distributions/ppc-freqpoly-grouped-default.svg index 9baeaf05..aa820572 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-freqpoly-grouped-default.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-freqpoly-grouped-default.svg @@ -354,15 +354,15 @@ - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_freqpoly_grouped (default) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-hist-binwidth.svg b/tests/testthat/_snaps/ppc-distributions/ppc-hist-binwidth.svg index 94150931..e2630e6c 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-hist-binwidth.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-hist-binwidth.svg @@ -168,15 +168,15 @@ - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_hist (binwidth) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-hist-default.svg b/tests/testthat/_snaps/ppc-distributions/ppc-hist-default.svg index c54df961..b7eb098a 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-hist-default.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-hist-default.svg @@ -411,15 +411,15 @@ - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_hist (default) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-default.svg b/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-default.svg index ecb58d96..44b5b1aa 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-default.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-default.svg @@ -65,13 +65,13 @@ B C D - - -y -y -r -e -p + + +y +y +r +e +p ppc_violin_grouped (default) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-points-low-jitter.svg b/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-points-low-jitter.svg index 8142349d..4e815ac3 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-points-low-jitter.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-points-low-jitter.svg @@ -161,13 +161,13 @@ B C D - - -y -y -r -e -p + + +y +y +r +e +p ppc_violin_grouped (points, low jitter) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-points-probs.svg b/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-points-probs.svg index 3fb73aea..38a4382c 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-points-probs.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-points-probs.svg @@ -157,13 +157,13 @@ B C D - - -y -y -r -e -p + + +y +y +r +e +p ppc_violin_grouped (points, probs) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-with-points.svg b/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-with-points.svg index 880fa046..e60275ee 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-with-points.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-violin-grouped-with-points.svg @@ -165,14 +165,14 @@ B C D - - - -y -y -r -e -p + + + +y +y +r +e +p ppc_violin_grouped (with points) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-intervals-default.svg b/tests/testthat/_snaps/ppc-intervals/ppc-intervals-default.svg index 4ed73687..8ff083cb 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-intervals-default.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-intervals-default.svg @@ -452,15 +452,15 @@ 75 100 Data point (index) - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_intervals (default) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-intervals-grouped-default.svg b/tests/testthat/_snaps/ppc-intervals/ppc-intervals-grouped-default.svg index 50546836..e37ee1a9 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-intervals-grouped-default.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-intervals-grouped-default.svg @@ -601,15 +601,15 @@ Data point (index) - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_intervals_grouped (default) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-intervals-grouped-x-values.svg b/tests/testthat/_snaps/ppc-intervals/ppc-intervals-grouped-x-values.svg index f5997757..9c418024 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-intervals-grouped-x-values.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-intervals-grouped-x-values.svg @@ -593,15 +593,15 @@ x - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_intervals_grouped (x values) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-intervals-interval-width.svg b/tests/testthat/_snaps/ppc-intervals/ppc-intervals-interval-width.svg index ffac8c6f..8fcd3900 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-intervals-interval-width.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-intervals-interval-width.svg @@ -452,15 +452,15 @@ 75 100 Data point (index) - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_intervals (interval width) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-intervals-x-values.svg b/tests/testthat/_snaps/ppc-intervals/ppc-intervals-x-values.svg index 7103c230..b2be547c 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-intervals-x-values.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-intervals-x-values.svg @@ -454,15 +454,15 @@ 2 3 x - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_intervals (x values) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-default.svg b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-default.svg index 269607c0..d432e146 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-default.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-default.svg @@ -63,14 +63,14 @@ 75 100 Data point (index) - - - -y -y -r -e -p + + + +y +y +r +e +p ppc_ribbon (default) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-default.svg b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-default.svg index 30a836cd..ca72a5d2 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-default.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-default.svg @@ -245,14 +245,14 @@ Data point (index) - - - -y -y -r -e -p + + + +y +y +r +e +p ppc_ribbon_grouped (default) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-x-values.svg b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-x-values.svg index b16cc03f..cb8bef6f 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-x-values.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-x-values.svg @@ -237,14 +237,14 @@ x - - - -y -y -r -e -p + + + +y +y +r +e +p ppc_ribbon_grouped (x values) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-y-draw-both.svg b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-y-draw-both.svg index c2e7fa0a..3d3912cb 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-y-draw-both.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-y-draw-both.svg @@ -345,15 +345,15 @@ Data point (index) - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_ribbon_grouped (y_draw = both) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-y-draw-line.svg b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-y-draw-line.svg index 355ab473..592c3b8e 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-y-draw-line.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-y-draw-line.svg @@ -245,14 +245,14 @@ Data point (index) - - - -y -y -r -e -p + + + +y +y +r +e +p ppc_ribbon_grouped (y_draw = line) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-y-draw-point.svg b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-y-draw-point.svg index 96fcbb41..d15dca9f 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-y-draw-point.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-grouped-y-draw-point.svg @@ -341,14 +341,14 @@ Data point (index) - - - -y -y -r -e -p + + + +y +y +r +e +p ppc_ribbon_grouped (y_draw = point) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-interval-width.svg b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-interval-width.svg index 9c5d5039..3f6f5797 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-interval-width.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-interval-width.svg @@ -63,14 +63,14 @@ 75 100 Data point (index) - - - -y -y -r -e -p + + + +y +y +r +e +p ppc_ribbon (interval width) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-x-values.svg b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-x-values.svg index 0a483910..954f3c6f 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-x-values.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-x-values.svg @@ -65,14 +65,14 @@ 2 3 x - - - -y -y -r -e -p + + + +y +y +r +e +p ppc_ribbon (x values) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-y-draw-both.svg b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-y-draw-both.svg index 0cd270da..2a8ad573 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-y-draw-both.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-y-draw-both.svg @@ -163,15 +163,15 @@ 75 100 Data point (index) - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_ribbon (y_draw = both) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-y-draw-line.svg b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-y-draw-line.svg index b1e5d829..893648f1 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-y-draw-line.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-y-draw-line.svg @@ -63,14 +63,14 @@ 75 100 Data point (index) - - - -y -y -r -e -p + + + +y +y +r +e +p ppc_ribbon (y_draw = line) diff --git a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-y-draw-point.svg b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-y-draw-point.svg index a0f33ee8..92aa7845 100644 --- a/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-y-draw-point.svg +++ b/tests/testthat/_snaps/ppc-intervals/ppc-ribbon-y-draw-point.svg @@ -162,14 +162,14 @@ 75 100 Data point (index) - - - -y -y -r -e -p + + + +y +y +r +e +p ppc_ribbon (y_draw = point) diff --git a/tests/testthat/_snaps/ppc-loo/ppc-loo-intervals-default.svg b/tests/testthat/_snaps/ppc-loo/ppc-loo-intervals-default.svg index 7581eea8..5bf8efc8 100644 --- a/tests/testthat/_snaps/ppc-loo/ppc-loo-intervals-default.svg +++ b/tests/testthat/_snaps/ppc-loo/ppc-loo-intervals-default.svg @@ -446,15 +446,15 @@ 75 100 Data point (index) - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_loo_intervals (default) diff --git a/tests/testthat/_snaps/ppc-loo/ppc-loo-intervals-order.svg b/tests/testthat/_snaps/ppc-loo/ppc-loo-intervals-order.svg index 917cab2c..98aaf8cc 100644 --- a/tests/testthat/_snaps/ppc-loo/ppc-loo-intervals-order.svg +++ b/tests/testthat/_snaps/ppc-loo/ppc-loo-intervals-order.svg @@ -436,15 +436,15 @@ Ordered by median - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_loo_intervals (order) diff --git a/tests/testthat/_snaps/ppc-loo/ppc-loo-intervals-prob.svg b/tests/testthat/_snaps/ppc-loo/ppc-loo-intervals-prob.svg index d847f56f..9aec7108 100644 --- a/tests/testthat/_snaps/ppc-loo/ppc-loo-intervals-prob.svg +++ b/tests/testthat/_snaps/ppc-loo/ppc-loo-intervals-prob.svg @@ -446,15 +446,15 @@ 75 100 Data point (index) - - - - -y -y -r -e -p + + + + +y +y +r +e +p ppc_loo_intervals (prob) diff --git a/tests/testthat/_snaps/ppc-loo/ppc-loo-pit-overlay-boundary.svg b/tests/testthat/_snaps/ppc-loo/ppc-loo-pit-overlay-boundary.svg index 3426f2c2..b64b8ca9 100644 --- a/tests/testthat/_snaps/ppc-loo/ppc-loo-pit-overlay-boundary.svg +++ b/tests/testthat/_snaps/ppc-loo/ppc-loo-pit-overlay-boundary.svg @@ -140,10 +140,10 @@ 0.5 0.7 0.9 - - -PIT -Unif + + +PIT +Unif ppc_loo_pit_overlay (boundary) diff --git a/tests/testthat/_snaps/ppc-loo/ppc-loo-pit-overlay-default.svg b/tests/testthat/_snaps/ppc-loo/ppc-loo-pit-overlay-default.svg index 3d5b9718..8dd4329b 100644 --- a/tests/testthat/_snaps/ppc-loo/ppc-loo-pit-overlay-default.svg +++ b/tests/testthat/_snaps/ppc-loo/ppc-loo-pit-overlay-default.svg @@ -140,10 +140,10 @@ 0.5 0.75 1 - - -PIT -Unif + + +PIT +Unif ppc_loo_pit_overlay (default) diff --git a/tests/testthat/_snaps/ppc-loo/ppc-loo-ribbon-default.svg b/tests/testthat/_snaps/ppc-loo/ppc-loo-ribbon-default.svg index 77f778da..0163ebca 100644 --- a/tests/testthat/_snaps/ppc-loo/ppc-loo-ribbon-default.svg +++ b/tests/testthat/_snaps/ppc-loo/ppc-loo-ribbon-default.svg @@ -57,14 +57,14 @@ 75 100 Data point (index) - - - -y -y -r -e -p + + + +y +y +r +e +p ppc_loo_ribbon (default) diff --git a/tests/testthat/_snaps/ppc-loo/ppc-loo-ribbon-prob.svg b/tests/testthat/_snaps/ppc-loo/ppc-loo-ribbon-prob.svg index dee948d3..3e6845c0 100644 --- a/tests/testthat/_snaps/ppc-loo/ppc-loo-ribbon-prob.svg +++ b/tests/testthat/_snaps/ppc-loo/ppc-loo-ribbon-prob.svg @@ -57,14 +57,14 @@ 75 100 Data point (index) - - - -y -y -r -e -p + + + +y +y +r +e +p ppc_loo_ribbon (prob) diff --git a/tests/testthat/_snaps/ppc-loo/ppc-loo-ribbon-subset.svg b/tests/testthat/_snaps/ppc-loo/ppc-loo-ribbon-subset.svg index 7960cfa5..d06e8ad1 100644 --- a/tests/testthat/_snaps/ppc-loo/ppc-loo-ribbon-subset.svg +++ b/tests/testthat/_snaps/ppc-loo/ppc-loo-ribbon-subset.svg @@ -59,14 +59,14 @@ 7.5 10.0 Data point (index) - - - -y -y -r -e -p + + + +y +y +r +e +p ppc_loo_ribbon (subset) diff --git a/tests/testthat/_snaps/ppc-test-statistics/ppd-stat-discrete-stat.svg b/tests/testthat/_snaps/ppc-test-statistics/ppd-stat-discrete-stat.svg index 4a42b8a7..70ca45cb 100644 --- a/tests/testthat/_snaps/ppc-test-statistics/ppd-stat-discrete-stat.svg +++ b/tests/testthat/_snaps/ppc-test-statistics/ppd-stat-discrete-stat.svg @@ -25,13 +25,13 @@ - - - - - - - + + + + + + + @@ -54,7 +54,7 @@ T = prop0 - + T ( y diff --git a/tests/testthat/_snaps/ppc-test-statistics/ppd-stat-grouped-discrete-stat.svg b/tests/testthat/_snaps/ppc-test-statistics/ppd-stat-grouped-discrete-stat.svg index e075886f..fa1351e6 100644 --- a/tests/testthat/_snaps/ppc-test-statistics/ppd-stat-grouped-discrete-stat.svg +++ b/tests/testthat/_snaps/ppc-test-statistics/ppd-stat-grouped-discrete-stat.svg @@ -25,13 +25,13 @@ - - - - - - - + + + + + + + @@ -43,12 +43,12 @@ - - - - - - + + + + + + @@ -96,7 +96,7 @@ T = prop0 - + T ( y diff --git a/tests/testthat/_snaps/ppd-marginal/ppd-boxplot-marginal.svg b/tests/testthat/_snaps/ppd-marginal/ppd-boxplot-marginal.svg new file mode 100644 index 00000000..b8a6a795 --- /dev/null +++ b/tests/testthat/_snaps/ppd-marginal/ppd-boxplot-marginal.svg @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 + + + + + + + + + + + + + + + + +PPD +y +p +r +e +d +ppd_boxplot (marginal) + + diff --git a/tests/testthat/_snaps/ppd-marginal/ppd-dens-marginal.svg b/tests/testthat/_snaps/ppd-marginal/ppd-dens-marginal.svg new file mode 100644 index 00000000..d12852f8 --- /dev/null +++ b/tests/testthat/_snaps/ppd-marginal/ppd-dens-marginal.svg @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + + +PPD +y +p +r +e +d +ppd_dens (marginal) + + diff --git a/tests/testthat/_snaps/ppd-marginal/ppd-dens-overlay-marginal.svg b/tests/testthat/_snaps/ppd-marginal/ppd-dens-overlay-marginal.svg new file mode 100644 index 00000000..734b3712 --- /dev/null +++ b/tests/testthat/_snaps/ppd-marginal/ppd-dens-overlay-marginal.svg @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 + + +PPD +y +p +r +e +d +ppd_dens_overlay (marginal) + + diff --git a/tests/testthat/_snaps/ppd-marginal/ppd-dots-marginal.svg b/tests/testthat/_snaps/ppd-marginal/ppd-dots-marginal.svg new file mode 100644 index 00000000..33fb0953 --- /dev/null +++ b/tests/testthat/_snaps/ppd-marginal/ppd-dots-marginal.svg @@ -0,0 +1,1054 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + + +PPD +y +p +r +e +d +ppd_dots (marginal) + + diff --git a/tests/testthat/_snaps/ppd-marginal/ppd-ecdf-overlay-marginal.svg b/tests/testthat/_snaps/ppd-marginal/ppd-ecdf-overlay-marginal.svg new file mode 100644 index 00000000..eaae5316 --- /dev/null +++ b/tests/testthat/_snaps/ppd-marginal/ppd-ecdf-overlay-marginal.svg @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0.0 +0.5 +1.0 + + + + + + + + +-2 +0 +2 +4 + + +PPD +y +p +r +e +d +ppd_ecdf_overlay (marginal) + + diff --git a/tests/testthat/_snaps/ppd-marginal/ppd-freqpoly-grouped-marginal.svg b/tests/testthat/_snaps/ppd-marginal/ppd-freqpoly-grouped-marginal.svg new file mode 100644 index 00000000..98ad2942 --- /dev/null +++ b/tests/testthat/_snaps/ppd-marginal/ppd-freqpoly-grouped-marginal.svg @@ -0,0 +1,365 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +A + + + + + + + + + +B + + + + + + + + + +C + + + + + + + + + +D + + + + + + + + + +-2 +-1 +0 +1 +2 +3 + + + + + + +-2 +-1 +0 +1 +2 + + + + + + +-2 +-1 +0 +1 +2 + + + + + + + + +-3 +-2 +-1 +0 +1 +2 +3 + + + + + + +PPD +y +p +r +e +d +ppd_freqpoly_grouped (marginal) + + diff --git a/tests/testthat/_snaps/ppd-marginal/ppd-freqpoly-marginal.svg b/tests/testthat/_snaps/ppd-marginal/ppd-freqpoly-marginal.svg new file mode 100644 index 00000000..56733a8b --- /dev/null +++ b/tests/testthat/_snaps/ppd-marginal/ppd-freqpoly-marginal.svg @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + + +PPD +y +p +r +e +d +ppd_freqpoly (marginal) + + diff --git a/tests/testthat/_snaps/ppd-marginal/ppd-hist-marginal.svg b/tests/testthat/_snaps/ppd-marginal/ppd-hist-marginal.svg new file mode 100644 index 00000000..c6cb6f58 --- /dev/null +++ b/tests/testthat/_snaps/ppd-marginal/ppd-hist-marginal.svg @@ -0,0 +1,424 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + +-2 +0 +2 + + + + + +PPD +y +p +r +e +d +ppd_hist (marginal) + + diff --git a/tests/testthat/_snaps/ppd-marginal/ppd-stat-2d-marginal.svg b/tests/testthat/_snaps/ppd-marginal/ppd-stat-2d-marginal.svg new file mode 100644 index 00000000..1db20286 --- /dev/null +++ b/tests/testthat/_snaps/ppd-marginal/ppd-stat-2d-marginal.svg @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0.90 +0.95 +1.00 +1.05 + + + + + + + + + +-0.1 +0.0 +0.1 +0.2 +mean +sd +T += +( +mean +, + +sd +) + + +T +( +P +P +D +) +T +( +y +p +r +e +d +) +ppd_stat_2d (marginal) + + diff --git a/tests/testthat/_snaps/ppd-marginal/ppd-stat-freqpoly-grouped-marginal.svg b/tests/testthat/_snaps/ppd-marginal/ppd-stat-freqpoly-grouped-marginal.svg new file mode 100644 index 00000000..61f8a814 --- /dev/null +++ b/tests/testthat/_snaps/ppd-marginal/ppd-stat-freqpoly-grouped-marginal.svg @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +C + + + + + + + + + +D + + + + + + + + + +A + + + + + + + + + +B + + + + + + +-0.4 +0.0 +0.4 + + + + + +-0.25 +0.00 +0.25 +0.50 + + + + + +-0.25 +0.00 +0.25 +0.50 + + + + + + +-0.4 +-0.2 +0.0 +0.2 +0.4 + + + + +T += +mean + + +T +( +P +P +D +) +T +( +y +p +r +e +d +) +ppd_stat_freqpoly_grouped (marginal) + + diff --git a/tests/testthat/_snaps/ppd-marginal/ppd-stat-freqpoly-marginal.svg b/tests/testthat/_snaps/ppd-marginal/ppd-stat-freqpoly-marginal.svg new file mode 100644 index 00000000..cfd8647e --- /dev/null +++ b/tests/testthat/_snaps/ppd-marginal/ppd-stat-freqpoly-marginal.svg @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-0.2 +0.0 +0.2 +0.4 +T += +mean + + +T +( +P +P +D +) +T +( +y +p +r +e +d +) +ppd_stat_freqpoly (marginal) + + diff --git a/tests/testthat/_snaps/ppd-marginal/ppd-stat-grouped-marginal.svg b/tests/testthat/_snaps/ppd-marginal/ppd-stat-grouped-marginal.svg new file mode 100644 index 00000000..0d2a5a30 --- /dev/null +++ b/tests/testthat/_snaps/ppd-marginal/ppd-stat-grouped-marginal.svg @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +C + + + + + + + + + +D + + + + + + + + + +A + + + + + + + + + +B + + + + + + + +-0.6 +-0.3 +0.0 +0.3 + + + + + + +-0.4 +-0.2 +0.0 +0.2 +0.4 + + + + + +-0.2 +0.0 +0.2 +0.4 + + + + +-0.2 +0.0 +0.2 + + + + +T += +mean + + +T +( +P +P +D +) +T +( +y +p +r +e +d +) +ppd_stat_grouped (marginal) + + diff --git a/tests/testthat/_snaps/ppd-marginal/ppd-stat-marginal-discrete.svg b/tests/testthat/_snaps/ppd-marginal/ppd-stat-marginal-discrete.svg new file mode 100644 index 00000000..1229f91c --- /dev/null +++ b/tests/testthat/_snaps/ppd-marginal/ppd-stat-marginal-discrete.svg @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0.5 +0.6 +0.7 +0.8 +0.9 +T += +prop0 + + +T +( +P +P +D +) +T +( +y +p +r +e +d +) +ppd_stat (marginal, discrete) + + diff --git a/tests/testthat/_snaps/ppd-marginal/ppd-stat-marginal.svg b/tests/testthat/_snaps/ppd-marginal/ppd-stat-marginal.svg new file mode 100644 index 00000000..ab140218 --- /dev/null +++ b/tests/testthat/_snaps/ppd-marginal/ppd-stat-marginal.svg @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +-0.2 +-0.1 +0.0 +0.1 +0.2 +0.3 +T += +mean + + +T +( +P +P +D +) +T +( +y +p +r +e +d +) +ppd_stat (marginal) + + diff --git a/tests/testthat/test-ppd-marginal.R b/tests/testthat/test-ppd-marginal.R new file mode 100644 index 00000000..6fbb3676 --- /dev/null +++ b/tests/testthat/test-ppd-marginal.R @@ -0,0 +1,91 @@ +source(test_path("data-for-ppc-tests.R")) + +prop0 <- function(x) mean(x == 0) + +# ppd-test-statistics with show_marginal ----------------------------------- + +test_that("ppd_stat_data returns PPD data", { + d <- ppd_stat_data(yrep, group, stat = var, show_marginal = FALSE) + expect_false("PPD" %in% d$variable) + + d <- ppd_stat_data(yrep, group, stat = var, show_marginal = TRUE) + expect_true("PPD" %in% d$variable) + + d_no <- ppd_stat_data(yrep, group, stat = var, show_marginal = FALSE) + expect_false("PPD" %in% d_no$variable) +}) + + +# Visual tests ------------------------------------------------------------- + +test_that("ppd-dist with show_marginal render correctly", { + testthat::skip_on_cran() + testthat::skip_if_not_installed("vdiffr") + skip_on_r_oldrel() + + p <- ppd_dens_overlay(vdiff_yrep, show_marginal = TRUE) + vdiffr::expect_doppelganger("ppd_dens_overlay (marginal)", p) + + p <- ppd_ecdf_overlay(vdiff_yrep, show_marginal = TRUE) + vdiffr::expect_doppelganger("ppd_ecdf_overlay (marginal)", p) + + p <- ppd_dens(vdiff_yrep[1:8, ], show_marginal = TRUE) + vdiffr::expect_doppelganger("ppd_dens (marginal)", p) + + p <- ppd_hist(vdiff_yrep[1:8, ], show_marginal = TRUE) + vdiffr::expect_doppelganger("ppd_hist (marginal)", p) + + p <- ppd_freqpoly(vdiff_yrep[1:8, ], show_marginal = TRUE) + vdiffr::expect_doppelganger("ppd_freqpoly (marginal)", p) + + p <- ppd_freqpoly_grouped( + vdiff_yrep[1:3, ], + vdiff_group, + show_marginal = TRUE + ) + vdiffr::expect_doppelganger("ppd_freqpoly_grouped (marginal)", p) + + p <- ppd_boxplot(vdiff_yrep[1:8, ], show_marginal = TRUE) + vdiffr::expect_doppelganger("ppd_boxplot (marginal)", p) + + testthat::skip_if_not_installed("ggdist") + p <- ppd_dots(vdiff_yrep[1:8, ], show_marginal = TRUE) + vdiffr::expect_doppelganger("ppd_dots (marginal)", p) +}) + +test_that("ppd-stat with show_marginal render correctly", { + testthat::skip_on_cran() + testthat::skip_if_not_installed("vdiffr") + skip_on_r_oldrel() + + p <- ppd_stat(vdiff_yrep, show_marginal = TRUE, binwidth = 0.05) + vdiffr::expect_doppelganger("ppd_stat (marginal)", p) + + set.seed(42) + ypred_bin <- matrix(rbinom(100 * 20, 1, 0.2), nrow = 100) + p <- ppd_stat(ypred_bin, stat = prop0, discrete = TRUE, show_marginal = TRUE) + vdiffr::expect_doppelganger("ppd_stat (marginal, discrete)", p) + set.seed(seed = NULL) + + p <- ppd_stat_grouped( + vdiff_yrep, + vdiff_group, + show_marginal = TRUE, + binwidth = 0.05 + ) + vdiffr::expect_doppelganger("ppd_stat_grouped (marginal)", p) + + p <- ppd_stat_freqpoly(vdiff_yrep, show_marginal = TRUE, binwidth = 0.05) + vdiffr::expect_doppelganger("ppd_stat_freqpoly (marginal)", p) + + p <- ppd_stat_freqpoly_grouped( + vdiff_yrep, + vdiff_group, + show_marginal = TRUE, + binwidth = 0.05 + ) + vdiffr::expect_doppelganger("ppd_stat_freqpoly_grouped (marginal)", p) + + p <- ppd_stat_2d(vdiff_yrep, show_marginal = TRUE) + vdiffr::expect_doppelganger("ppd_stat_2d (marginal)", p) +})