Skip to content

Commit b6caca5

Browse files
committed
fix ebfmi calc
1 parent c39aeb4 commit b6caca5

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

R/utils.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,17 @@ ebfmi <- function(post_warmup_sampler_diagnostics) {
308308

309309
check_ebfmi <- function(post_warmup_sampler_diagnostics, threshold = 0.2) {
310310
efbmi_per_chain <- ebfmi(post_warmup_sampler_diagnostics)
311-
if (any(efbmi_per_chain < threshold)) {
311+
nan_efbmi_count <- sum(is.nan(efbmi_per_chain))
312+
efbmi_below_threshold <- sum(efbmi_per_chain < threshold)
313+
if (nan_efbmi_count > 0) {
312314
message(
313-
"Warning: ", sum(efbmi_per_chain < threshold), " of ", length(efbmi_per_chain),
315+
"Warning: ", nan_efbmi_count, " of ", length(efbmi_per_chain),
316+
" chains have a NaN E-BFMI.\n",
317+
"See https://mc-stan.org/misc/warnings for details.\n"
318+
)
319+
} else if (efbmi_below_threshold > 0) {
320+
message(
321+
"Warning: ", efbmi_below_threshold, " of ", length(efbmi_per_chain),
314322
" chains had an E-BFMI less than ", threshold, ".\n",
315323
"See https://mc-stan.org/misc/warnings for details.\n"
316324
)

0 commit comments

Comments
 (0)