Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# bayesplot (development version)

* Use `rlang::warn()` and `rlang::inform()` for selected PPC user messages instead of base `warning()` and `message()`.
* Standardize input validation errors in `ppc_km_overlay()` and interpolation helpers to use `rlang::abort()` for consistent error handling.
* Fix assignment-in-call bug in `mcmc_rank_ecdf()` (#).
* Replaced deprecated `dplyr` and `tidyselect` functions (`top_n`, `one_of`, `group_indices`) with their modern equivalents to ensure future compatibility. (#431)
Expand Down
4 changes: 2 additions & 2 deletions R/ppc-censoring.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ ppc_km_overlay <- function(
abort("`extrapolation_factor` must be greater than or equal to 1.")
}
if (extrapolation_factor == 1.2) {
message(
inform(paste0(
"Note: `extrapolation_factor` now defaults to 1.2 (20%).\n",
"To display all posterior predictive draws, set `extrapolation_factor = Inf`."
)
))
}

data <- ppc_data(y, yrep, group = status_y)
Expand Down
11 changes: 5 additions & 6 deletions R/ppc-loo.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,14 @@ ppc_loo_pit_overlay <- function(y,
)

if (!missing(y) && all(y %in% 0:1)) {
warning(
warn(paste0(
"This plot is not recommended for binary data. ",
"For plots that are more suitable see ",
"\nhttps://avehtari.github.io/modelselection/diabetes.html#44_calibration_of_predictions",
call. = FALSE
)
"\nhttps://avehtari.github.io/modelselection/diabetes.html#44_calibration_of_predictions"
))
}

message(paste(
inform(paste(
"NOTE: The kernel density estimate assumes continuous observations",
"and is not optimal for discrete observations."
))
Expand Down Expand Up @@ -797,7 +796,7 @@ ppc_loo_ribbon <-
# 1-D Gaussian window filter. This method uses the "reflection method"
# to estimate these pvalues and helps speed up the code
if (any(is.infinite(x))) {
warning(paste(
warn(paste(
"Ignored", sum(is.infinite(x)),
"Non-finite PIT values are invalid for KDE boundary correction method"
))
Expand Down
4 changes: 2 additions & 2 deletions R/ppc-test-statistics.R
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,9 @@ Tyrep_label <- function() expression(italic(T)(italic(y)[rep]))

message_if_using_mean <- function(stat) {
if (is.character(stat) && stat == "mean") {
message(
inform(paste0(
"Note: in most cases the default test statistic 'mean' is ",
"too weak to detect anything of interest."
)
))
}
}
13 changes: 13 additions & 0 deletions tests/testthat/test-ppc-loo.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ test_that("ppc_loo_pit_overlay works with boundary_correction=FALSE", {
expect_gg(p1)
})

test_that(".kde_correction warns when PIT values are non-finite", {
set.seed(123)
pit_vals <- c(stats::runif(500), Inf)
expect_warning(
out <- .kde_correction(pit_vals, bw = "nrd0", grid_len = 128),
"Non-finite PIT values are invalid"
)
expect_type(out, "list")
expect_true(all(c("xs", "bc_pvals") %in% names(out)))
expect_equal(length(out$xs), 128)
expect_equal(length(out$bc_pvals), 128)
})

test_that("ppc_loo_pit_qq returns ggplot object", {
skip_if_not_installed("rstanarm")
skip_if_not_installed("loo")
Expand Down
Loading