From 960ae8b200fdeb06bba7ac4b10b47f82d3b75359 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 31 Jan 2024 20:49:33 +0100 Subject: [PATCH] lintr --- DESCRIPTION | 2 +- R/rope_range.R | 78 ++++++++++++++++++++++++-------------------------- 2 files changed, 39 insertions(+), 41 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index ae192a25e..000d6a44c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: bayestestR Title: Understand and Describe Bayesian Models and Posterior Distributions -Version: 0.13.1.7 +Version: 0.13.1.8 Authors@R: c(person(given = "Dominique", family = "Makowski", diff --git a/R/rope_range.R b/R/rope_range.R index 182c6d0bf..08c9c8dcb 100644 --- a/R/rope_range.R +++ b/R/rope_range.R @@ -83,10 +83,10 @@ rope_range.default <- function(x, verbose = TRUE, ...) { ret <- Map( function(i, j, ...) .rope_range(x, i, j), information, response, response_transform, verbose ) - return(ret) } else { - .rope_range(x, information, response, response_transform, verbose) + ret <- .rope_range(x, information, response, response_transform, verbose) } + ret } @@ -114,44 +114,42 @@ rope_range.mlm <- function(x, verbose = TRUE, ...) { .rope_range <- function(x, information = NULL, response = NULL, response_transform = NULL, verbose = TRUE) { negligible_value <- tryCatch( - { - if (!is.null(response_transform) && grepl("log", response_transform, fixed = TRUE)) { - # for log-transform, we assume that a 1% change represents the ROPE adequately - # see https://github.com/easystats/bayestestR/issues/487 - 0.01 - } else if (information$is_linear && information$link_function == "log") { - # for log-transform, we assume that a 1% change represents the ROPE adequately - # see https://github.com/easystats/bayestestR/issues/487 - 0.01 - } else if (information$family == "lognormal") { - # for log-transform, we assume that a 1% change represents the ROPE adequately - # see https://github.com/easystats/bayestestR/issues/487 - 0.01 - } else if (!is.null(response) && information$link_function == "identity") { - # Linear Models - 0.1 * stats::sd(response, na.rm = TRUE) - # 0.1 * stats::sigma(x) # https://github.com/easystats/bayestestR/issues/364 - } else if (information$is_logit) { - # Logistic Models (any) - # Sigma==pi / sqrt(3) - 0.1 * pi / sqrt(3) - } else if (information$is_probit) { - # Probit models - # Sigma==1 - 0.1 * 1 - } else if (information$is_correlation) { - # Correlations - # https://github.com/easystats/bayestestR/issues/121 - 0.05 - } else if (information$is_count) { - # Not sure about this - sig <- stats::sigma(x) - if (is.null(sig) || length(sig) == 0 || is.na(sig)) stop() - 0.1 * sig - } else { - # Default - stop() - } + if (!is.null(response_transform) && grepl("log", response_transform, fixed = TRUE)) { + # for log-transform, we assume that a 1% change represents the ROPE adequately + # see https://github.com/easystats/bayestestR/issues/487 + 0.01 + } else if (information$is_linear && information$link_function == "log") { + # for log-transform, we assume that a 1% change represents the ROPE adequately + # see https://github.com/easystats/bayestestR/issues/487 + 0.01 + } else if (information$family == "lognormal") { + # for log-transform, we assume that a 1% change represents the ROPE adequately + # see https://github.com/easystats/bayestestR/issues/487 + 0.01 + } else if (!is.null(response) && information$link_function == "identity") { + # Linear Models + 0.1 * stats::sd(response, na.rm = TRUE) + # 0.1 * stats::sigma(x) # https://github.com/easystats/bayestestR/issues/364 + } else if (information$is_logit) { + # Logistic Models (any) + # Sigma==pi / sqrt(3) + 0.1 * pi / sqrt(3) + } else if (information$is_probit) { + # Probit models + # Sigma==1 + 0.1 * 1 + } else if (information$is_correlation) { + # Correlations + # https://github.com/easystats/bayestestR/issues/121 + 0.05 + } else if (information$is_count) { + # Not sure about this + sig <- stats::sigma(x) + if (is.null(sig) || length(sig) == 0 || is.na(sig)) stop(call. = FALSE) + 0.1 * sig + } else { + # Default + stop(call. = FALSE) }, error = function(e) { if (isTRUE(verbose)) {