Skip to content

Commit ce58981

Browse files
authored
Merge pull request #1057 from stan-dev/fix_loo_r_eff_overflow
fix translation of log liks before exponentiation
2 parents 79d3779 + 0436f37 commit ce58981

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

R/fit.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,8 @@ loo <- function(variables = "log_lik", r_eff = TRUE, moment_match = FALSE, ...)
15431543
if (is.logical(r_eff)) {
15441544
if (isTRUE(r_eff)) {
15451545
r_eff_cores <- list(...)[["cores"]] %||% getOption("mc.cores", 1)
1546-
r_eff <- loo::relative_eff(exp(LLarray + max(-LLarray)), cores = r_eff_cores)
1546+
r_eff <- loo::relative_eff(exp(sweep(LLarray, 3, apply(LLarray, 3, max), FUN = "-")),
1547+
cores = r_eff_cores)
15471548
} else {
15481549
r_eff <- NULL
15491550
}

0 commit comments

Comments
 (0)