Skip to content

Commit

Permalink
Fix issue with pareto_khat output no longer being a list
Browse files Browse the repository at this point in the history
  • Loading branch information
n-kall committed May 20, 2024
1 parent 1a4cfce commit c3c6c00
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/E_loo.R
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,15 @@ E_loo_khat.matrix <- function(x, psis_object, log_ratios, ...) {
h_theta <- x_i
r_theta <- exp(log_ratios_i - max(log_ratios_i))
khat_r <- posterior::pareto_khat(r_theta, tail = "right", ndraws_tail = tail_len_i)
if (!is.na(khat_r)) { # https://github.com/stan-dev/loo/issues/263
if (is.list(khat_r)) { # retain compatiblity with older posterior that returned a list
khat_r <- khat_r$khat
}
if (is.null(x_i) || is_constant(x_i) || length(unique(x_i))==2 ||
anyNA(x_i) || any(is.infinite(x_i))) {
khat_r
} else {
khat_hr <- posterior::pareto_khat(h_theta * r_theta, tail = "both", ndraws_tail = tail_len_i)
if (!is.na(khat_hr)) { # https://github.com/stan-dev/loo/issues/263
if (is.list(khat_hr)) { # retain compatiblity with older posterior that returned a list
khat_hr <- khat_hr$khat
}
if (is.na(khat_hr) && is.na(khat_r)) {
Expand Down

0 comments on commit c3c6c00

Please sign in to comment.