Skip to content

Commit 6f690c1

Browse files
authored
Merge pull request #269 from n-kall/pareto_k_fix
Fix issue with pareto_khat output no longer being a list
2 parents 1a4cfce + c3c6c00 commit 6f690c1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

R/E_loo.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,15 @@ E_loo_khat.matrix <- function(x, psis_object, log_ratios, ...) {
291291
h_theta <- x_i
292292
r_theta <- exp(log_ratios_i - max(log_ratios_i))
293293
khat_r <- posterior::pareto_khat(r_theta, tail = "right", ndraws_tail = tail_len_i)
294-
if (!is.na(khat_r)) { # https://github.com/stan-dev/loo/issues/263
294+
if (is.list(khat_r)) { # retain compatiblity with older posterior that returned a list
295295
khat_r <- khat_r$khat
296296
}
297297
if (is.null(x_i) || is_constant(x_i) || length(unique(x_i))==2 ||
298298
anyNA(x_i) || any(is.infinite(x_i))) {
299299
khat_r
300300
} else {
301301
khat_hr <- posterior::pareto_khat(h_theta * r_theta, tail = "both", ndraws_tail = tail_len_i)
302-
if (!is.na(khat_hr)) { # https://github.com/stan-dev/loo/issues/263
302+
if (is.list(khat_hr)) { # retain compatiblity with older posterior that returned a list
303303
khat_hr <- khat_hr$khat
304304
}
305305
if (is.na(khat_hr) && is.na(khat_r)) {

0 commit comments

Comments
 (0)