Skip to content

Commit

Permalink
Merge pull request #695 from easystats/selective-rope_range
Browse files Browse the repository at this point in the history
`describe_posterior()` only conditionally calls `rope_range()` when needed
  • Loading branch information
mattansb authored Jan 28, 2025
2 parents fb746e3 + 600a493 commit 00183b2
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion R/describe_posterior.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe_posterior.default <- function(posterior, ...) {
}

# we need this information from the original object
if (all(rope_range == "default")) {
if (.check_if_need_to_compute_rope_range(rope_range, test)) {
rope_range <- rope_range(x, verbose = verbose, ...)
}

Expand Down Expand Up @@ -1433,3 +1433,20 @@ describe_posterior.BFBayesFactor <- function(posterior,
"bf", "bayesfactor", "bayes_factor", "p_map", "all"
), several.ok = TRUE)
}

#' @keywords internal
.check_if_need_to_compute_rope_range <- function(rope_range, test) {
if (is.numeric(rope_range) || is.list(rope_range)) {
return(FALSE)
}

need_rope <- c(
"all",
"p_rope",
"ps", "p_sig", "p_significance",
"rope",
"equivalence", "equivalence_test", "equitest"
)

return(is.character(test) && length(test) > 0L && any(need_rope %in% tolower(test)))
}

0 comments on commit 00183b2

Please sign in to comment.