Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

describe_posterior() only conditionally calls rope_range() when needed #695

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion R/describe_posterior.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#' - Makowski, D., Ben-Shachar, M. S., Chen, S. H. A., and Lüdecke, D. (2019).
#' *Indices of Effect Existence and Significance in the Bayesian Framework*.
#' Frontiers in Psychology 2019;10:2767. \doi{10.3389/fpsyg.2019.02767}
#' - [Region of Practical Equivalence (ROPE)](https://easystats.github.io/bayestestR/articles/region_of_practical_equivalence.html)

Check warning on line 49 in R/describe_posterior.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/describe_posterior.R,line=49,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 131 characters.
#' - [Bayes factors](https://easystats.github.io/bayestestR/articles/bayes_factors.html)
#'
#' @examples
Expand Down Expand Up @@ -120,7 +120,7 @@


#' @keywords internal
.describe_posterior <- function(x,

Check warning on line 123 in R/describe_posterior.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/describe_posterior.R,line=123,col=1,[cyclocomp_linter] Reduce the cyclomatic complexity of this function from 68 to at most 40.
centrality = "median",
dispersion = FALSE,
ci = 0.95,
Expand All @@ -141,7 +141,7 @@
}

# 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 @@
"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)))

Check warning on line 1451 in R/describe_posterior.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/describe_posterior.R,line=1451,col=3,[return_linter] Use implicit return behavior; explicit return() is not needed.
}

Check warning on line 1452 in R/describe_posterior.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/describe_posterior.R,line=1452,col=2,[trailing_blank_lines_linter] Add a terminal newline.
Loading