From d639646923530103490e3c58b24dc9370e8d74b9 Mon Sep 17 00:00:00 2001 From: "Mattan S. Ben-Shachar" Date: Thu, 20 Jul 2023 22:39:49 +0300 Subject: [PATCH] init --- NEWS.md | 3 +++ R/plot.check_normality.R | 17 +++++++++++++---- man/plot.see_check_normality.Rd | 5 +++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 51fd504e4..971084590 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,9 @@ * The `print()` method for `performance::check_model()` now also evaluates the default plot type for posterior predictive checks. +* QQ/PP-plots now default to drawing simultaneous testing bands (when the + `qqplotr` package is available). Previous behavior can be restored by setting + `method = "pointwise"`. # see 0.8.0 diff --git a/R/plot.check_normality.R b/R/plot.check_normality.R index e7b991b79..23ee396ba 100644 --- a/R/plot.check_normality.R +++ b/R/plot.check_normality.R @@ -10,6 +10,9 @@ #' @param colors Character vector of length two, indicating the colors (in #' hex-format) for points and line. #' @param detrend Logical that decides if the plot should be detrended. +#' @param method The method used for estimating the qq/pp bands. Default to +#' `"ell"` (equal local levels / simultaneous testing - recommended). See +#' `qqplotr::stat_qq_band()` for more options and details. #' @inheritParams data_plot #' @inheritParams plot.see_bayesfactor_parameters #' @@ -31,6 +34,7 @@ plot.see_check_normality <- function(x, dot_alpha = 0.8, colors = c("#3aaf85", "#1b6ca8"), detrend = FALSE, + method = "ell", ...) { type <- match.arg(type) @@ -75,7 +79,8 @@ plot.see_check_normality <- function(x, alpha_level = alpha, detrend = detrend, dot_alpha_level = dot_alpha, - model_info = model_info + model_info = model_info, + method = method ) } else if (type == "density") { r <- suppressMessages(stats::residuals(model)) @@ -95,7 +100,8 @@ plot.see_check_normality <- function(x, size_line = size_line, alpha_level = alpha, detrend = detrend, - dot_alpha_level = dot_alpha + dot_alpha_level = dot_alpha, + method = method ) } } @@ -145,6 +151,7 @@ plot.see_check_normality <- function(x, size_line, alpha_level = 0.2, detrend = FALSE, + method = "ell", theme_style = theme_lucid, colors = unname(social_colors(c("green", "blue", "red"))), dot_alpha_level = 0.8, @@ -175,7 +182,8 @@ plot.see_check_normality <- function(x, qq_stuff <- list( qqplotr::stat_qq_band( alpha = alpha_level, - detrend = detrend + detrend = detrend, + bandType = method ), qqplotr::stat_qq_point( shape = 16, @@ -246,12 +254,13 @@ plot.see_check_normality <- function(x, size_line, alpha_level = 0.2, detrend = FALSE, + method = "ell", theme_style = theme_lucid, colors = unname(social_colors(c("green", "blue", "red"))), dot_alpha_level = 0.8) { if (requireNamespace("qqplotr", quietly = TRUE)) { p_plot <- ggplot2::ggplot(x, ggplot2::aes(sample = .data$res)) + - qqplotr::stat_pp_band(alpha = alpha_level, detrend = detrend) + + qqplotr::stat_pp_band(alpha = alpha_level, detrend = detrend, bandType = method) + qqplotr::stat_pp_line( linewidth = size_line, colour = colors[1], diff --git a/man/plot.see_check_normality.Rd b/man/plot.see_check_normality.Rd index 413c21df4..029abda8c 100644 --- a/man/plot.see_check_normality.Rd +++ b/man/plot.see_check_normality.Rd @@ -14,6 +14,7 @@ dot_alpha = 0.8, colors = c("#3aaf85", "#1b6ca8"), detrend = FALSE, + method = "ell", ... ) } @@ -38,6 +39,10 @@ hex-format) for points and line.} \item{detrend}{Logical that decides if the plot should be detrended.} +\item{method}{The method used for estimating the qq/pp bands. Default to +\code{"ell"} (equal local levels / simultaneous testing - recommended). See +\code{qqplotr::stat_qq_band()} for more options and details.} + \item{...}{Arguments passed to or from other methods.} } \value{