Skip to content

Commit

Permalink
Infinite loop in icc() for some brms models
Browse files Browse the repository at this point in the history
Fixes #905
  • Loading branch information
strengejacke committed Jul 17, 2024
1 parent 17b7d10 commit 73451c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/compute_variances.R
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@
model_component = NULL,
verbose = TRUE) {
# get overdispersion parameter / sigma
sig <- .safe(get_sigma(model))
sig <- .safe(.get_sigma(model, no_recursion = TRUE))

if (is.null(sig)) {
sig <- 1
Expand Down
8 changes: 6 additions & 2 deletions R/get_sigma.R
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ get_sigma <- function(x, ci = NULL, verbose = TRUE) {
}
)


# compute sigma manually ---------------
if (is_empty_object(s)) {
# default sigma ---------------
Expand All @@ -242,7 +241,12 @@ get_sigma <- function(x, ci = NULL, verbose = TRUE) {
if (is_empty_object(s)) {
info <- model_info(x, verbose = FALSE)
if (!is.null(info) && info$is_mixed) {
s <- .safe(sqrt(get_variance_residual(x, verbose = FALSE)))
dots <- list(...)
# in "get_variance()", we call "get_sigma()" - make sure we avoid
# recursion and infinite loops
if (!isTRUE(dots$no_recursion)) {
s <- .safe(sqrt(get_variance_residual(x, verbose = FALSE)))
}
}
}

Expand Down

0 comments on commit 73451c1

Please sign in to comment.