Skip to content

Commit

Permalink
Merge pull request #1057 from stan-dev/fix_loo_r_eff_overflow
Browse files Browse the repository at this point in the history
fix translation of log liks before exponentiation
  • Loading branch information
andrjohns authored Jan 15, 2025
2 parents 79d3779 + 0436f37 commit ce58981
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,8 @@ loo <- function(variables = "log_lik", r_eff = TRUE, moment_match = FALSE, ...)
if (is.logical(r_eff)) {
if (isTRUE(r_eff)) {
r_eff_cores <- list(...)[["cores"]] %||% getOption("mc.cores", 1)
r_eff <- loo::relative_eff(exp(LLarray + max(-LLarray)), cores = r_eff_cores)
r_eff <- loo::relative_eff(exp(sweep(LLarray, 3, apply(LLarray, 3, max), FUN = "-")),
cores = r_eff_cores)
} else {
r_eff <- NULL
}
Expand Down

0 comments on commit ce58981

Please sign in to comment.