@@ -302,7 +302,10 @@ ppc_loo_pit_data <-
302302 boundary_correction = TRUE ,
303303 grid_len = 512 ) {
304304 if (! is.null(pit )) {
305- stopifnot(is.numeric(pit ), is_vector_or_1Darray(pit ))
305+ pit <- validate_pit(pit )
306+ if (boundary_correction && length(pit ) < 2L ) {
307+ abort(" At least 2 PIT values are required when 'boundary_correction' is TRUE." )
308+ }
306309 inform(" 'pit' specified so ignoring 'y','yrep','lw' if specified." )
307310 } else {
308311 suggested_package(" rstantools" )
@@ -348,7 +351,7 @@ ppc_loo_pit_qq <- function(y,
348351
349352 compare <- match.arg(compare )
350353 if (! is.null(pit )) {
351- stopifnot(is.numeric( pit ), is_vector_or_1Darray (pit ) )
354+ pit <- validate_pit (pit )
352355 inform(" 'pit' specified so ignoring 'y','yrep','lw' if specified." )
353356 } else {
354357 suggested_package(" rstantools" )
@@ -795,14 +798,6 @@ ppc_loo_ribbon <-
795798 # Generate boundary corrected values via a linear convolution using a
796799 # 1-D Gaussian window filter. This method uses the "reflection method"
797800 # to estimate these pvalues and helps speed up the code
798- if (any(is.infinite(x ))) {
799- warn(paste(
800- " Ignored" , sum(is.infinite(x )),
801- " Non-finite PIT values are invalid for KDE boundary correction method"
802- ))
803- x <- x [is.finite(x )]
804- }
805-
806801 if (grid_len < 100 ) {
807802 grid_len <- 100
808803 }
@@ -819,6 +814,10 @@ ppc_loo_ribbon <-
819814 # 1-D Convolution
820815 bc_pvals <- .linear_convolution(x , bw , grid_counts , grid_breaks , grid_len )
821816
817+ if (all(is.na(bc_pvals ))) {
818+ abort(" KDE boundary correction produced all NA values." )
819+ }
820+
822821 # Generate vector of x-axis values for plotting based on binned relative freqs
823822 n_breaks <- length(grid_breaks )
824823
0 commit comments