Skip to content

Commit 7410b81

Browse files
committed
skip pareto-k check for low number of unique values
1 parent b0ebac7 commit 7410b81

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

R/loo_compare.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ loo_compare.default <- function(x, ...) {
139139
# possible outliers in differences (Sivula et al., 2025;
140140
# Vehtari et al., 2024)
141141
khat_diff <- rep(NA, length(elpd_diff))
142-
khat_diff[elpd_diff!=0] <- apply(diffs[,elpd_diff!=0, drop = FALSE], 2, \(x) posterior::pareto_khat(x, tail="both"))
142+
khat_diff[elpd_diff!=0] <- apply(diffs[,elpd_diff!=0, drop = FALSE], 2, \(x) ifelse(length(unique(x))<=20, NA, posterior::pareto_khat(x, tail="both")))
143143
diag_pnorm[khat_diff > 0.5] <- paste0("khat_diff > 0.5")
144144
}
145145
rownames(comp) <- rnms

0 commit comments

Comments
 (0)