From 0436f37cb5b51f7b72c0ff3e8ea49453e811211f Mon Sep 17 00:00:00 2001 From: Aki Vehtari Date: Tue, 14 Jan 2025 20:05:58 +0200 Subject: [PATCH] fix translation of log liks before exponentiation --- R/fit.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/fit.R b/R/fit.R index 7c4f554f..cb093d9b 100644 --- a/R/fit.R +++ b/R/fit.R @@ -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 }