From b0f6dbd825bd5810ab6a8c90df396c61b27ee414 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 7 Oct 2023 13:43:43 +0200 Subject: [PATCH 1/7] oass down verbose --- DESCRIPTION | 2 +- R/bayesfactor_parameters.R | 2 +- R/describe_posterior.R | 44 +++++++++++++++++++++++++++++++---- R/equivalence_test.R | 4 ++-- man/bayesfactor_parameters.Rd | 4 ++-- man/describe_posterior.Rd | 5 ++++ 6 files changed, 50 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 68da738c1..1fcd4bc1c 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.5 +Version: 0.13.1.6 Authors@R: c(person(given = "Dominique", family = "Makowski", diff --git a/R/bayesfactor_parameters.R b/R/bayesfactor_parameters.R index 8e71399b4..77d98db70 100644 --- a/R/bayesfactor_parameters.R +++ b/R/bayesfactor_parameters.R @@ -219,7 +219,7 @@ bayesfactor_pointnull <- function(posterior, bayesfactor_rope <- function(posterior, prior = NULL, direction = "two-sided", - null = rope_range(posterior), + null = rope_range(posterior, verbose = FALSE), verbose = TRUE, ...) { if (length(null) < 2 && verbose) { diff --git a/R/describe_posterior.R b/R/describe_posterior.R index 864fd753d..45ab6072a 100644 --- a/R/describe_posterior.R +++ b/R/describe_posterior.R @@ -35,6 +35,7 @@ #' @inheritParams point_estimate #' @inheritParams ci #' @inheritParams si +#' @inheritParams hdi #' #' @details #' One or more components of point estimates (like posterior mean or median), @@ -130,15 +131,18 @@ describe_posterior.default <- function(posterior, ...) { keep_iterations = FALSE, bf_prior = NULL, BF = 1, + verbose = TRUE, ...) { if (is.null(x)) { - insight::format_warning("Could not extract posterior samples.") + if (verbose) { + insight::format_warning("Could not extract posterior samples.") + } return(NULL) } # we need this information from the original object if (all(rope_range == "default")) { - rope_range <- rope_range(x, ...) + rope_range <- rope_range(x, verbose = verbose, ...) } if (!is.data.frame(x) && !is.numeric(x)) { @@ -227,9 +231,11 @@ describe_posterior.default <- function(posterior, ...) { # no ROPE for multi-response models if (insight::is_multivariate(x)) { test <- setdiff(test, c("rope", "p_rope")) - insight::format_warning( - "Multivariate response models are not yet supported for tests `rope` and `p_rope`." - ) + if (verbose) { + insight::format_warning( + "Multivariate response models are not yet supported for tests `rope` and `p_rope`." + ) + } } # MAP-based p-value @@ -534,6 +540,7 @@ describe_posterior.numeric <- function(posterior, keep_iterations = FALSE, bf_prior = NULL, BF = 1, + verbose = TRUE, ...) { out <- .describe_posterior( posterior, @@ -547,6 +554,7 @@ describe_posterior.numeric <- function(posterior, keep_iterations = keep_iterations, bf_prior = bf_prior, BF = BF, + verbose = verbose, ... ) @@ -582,6 +590,7 @@ describe_posterior.bayesQR <- function(posterior, rope_ci = 0.95, keep_iterations = FALSE, parameters = NULL, + verbose = TRUE, ...) { out <- .describe_posterior( insight::get_parameters(posterior), @@ -595,6 +604,7 @@ describe_posterior.bayesQR <- function(posterior, keep_iterations = keep_iterations, effects = "fixed", parameters = parameters, + verbose = verbose, ... ) @@ -633,6 +643,7 @@ describe_posterior.draws <- function(posterior, keep_iterations = FALSE, bf_prior = NULL, BF = 1, + verbose = TRUE, ...) { out <- .describe_posterior( .posterior_draws_to_df(posterior), @@ -646,6 +657,7 @@ describe_posterior.draws <- function(posterior, keep_iterations = keep_iterations, bf_prior = bf_prior, BF = BF, + verbose = verbose, ... ) @@ -673,6 +685,7 @@ describe_posterior.effectsize_std_params <- function(posterior, keep_iterations = FALSE, bf_prior = NULL, BF = 1, + verbose = TRUE, ...) { class(posterior) <- "data.frame" @@ -695,6 +708,7 @@ describe_posterior.effectsize_std_params <- function(posterior, keep_iterations = keep_iterations, bf_prior = bf_prior, BF = BF, + verbose = verbose, ... ) @@ -720,6 +734,7 @@ describe_posterior.effectsize_std_params <- function(posterior, keep_iterations = keep_iterations, bf_prior = bf_prior, BF = BF, + verbose = verbose, ... ) } @@ -732,6 +747,7 @@ describe_posterior.get_predicted <- function(posterior, ci = 0.95, ci_method = "eti", test = NULL, + verbose = TRUE, ...) { if ("iterations" %in% names(attributes(posterior))) { describe_posterior( @@ -741,6 +757,7 @@ describe_posterior.get_predicted <- function(posterior, ci = ci, ci_method = ci_method, test = test, + verbose = verbose, ... ) } else { @@ -766,6 +783,7 @@ describe_posterior.emmGrid <- function(posterior, keep_iterations = FALSE, bf_prior = NULL, BF = 1, + verbose = TRUE, ...) { if (any(c("all", "bf", "bayesfactor", "bayes_factor") %in% tolower(test)) || "si" %in% tolower(ci_method)) { @@ -789,6 +807,7 @@ describe_posterior.emmGrid <- function(posterior, keep_iterations = keep_iterations, bf_prior = bf_prior, BF = BF, + verbose = verbose, ... ) @@ -835,6 +854,7 @@ describe_posterior.stanreg <- function(posterior, ), parameters = NULL, BF = 1, + verbose = TRUE, ...) { if ((any(c("all", "bf", "bayesfactor", "bayes_factor") %in% tolower(test)) || "si" %in% tolower(ci_method)) && is.null(bf_prior)) { @@ -859,6 +879,7 @@ describe_posterior.stanreg <- function(posterior, effects = effects, component = component, parameters = parameters, + verbose = verbose, ... ) @@ -907,6 +928,7 @@ describe_posterior.stanmvreg <- function(posterior, "auxiliary" ), parameters = NULL, + verbose = TRUE, ...) { effects <- match.arg(effects) component <- match.arg(component) @@ -924,6 +946,7 @@ describe_posterior.stanmvreg <- function(posterior, bf_prior = bf_prior, effects = effects, parameters = parameters, + verbose = verbose, ... ) @@ -970,6 +993,7 @@ describe_posterior.stanfit <- function(posterior, effects = c("fixed", "random", "all"), parameters = NULL, priors = FALSE, + verbose = TRUE, ...) { effects <- match.arg(effects) out <- .describe_posterior( @@ -984,6 +1008,7 @@ describe_posterior.stanfit <- function(posterior, keep_iterations = keep_iterations, effects = effects, parameters = parameters, + verbose = verbose, ... ) @@ -1030,6 +1055,7 @@ describe_posterior.brmsfit <- function(posterior, parameters = NULL, BF = 1, priors = FALSE, + verbose = TRUE, ...) { effects <- match.arg(effects) component <- match.arg(component) @@ -1054,6 +1080,7 @@ describe_posterior.brmsfit <- function(posterior, effects = effects, component = component, parameters = parameters, + verbose = verbose, ... ) @@ -1104,6 +1131,7 @@ describe_posterior.MCMCglmm <- function(posterior, keep_iterations = FALSE, diagnostic = "ESS", parameters = NULL, + verbose = TRUE, ...) { out <- .describe_posterior( posterior, @@ -1117,6 +1145,7 @@ describe_posterior.MCMCglmm <- function(posterior, keep_iterations = keep_iterations, effects = "fixed", parameters = parameters, + verbose = verbose, ... ) @@ -1141,6 +1170,7 @@ describe_posterior.bcplm <- function(posterior, keep_iterations = FALSE, priors = TRUE, parameters = NULL, + verbose = TRUE, ...) { out <- .describe_posterior( insight::get_parameters(posterior), @@ -1154,6 +1184,7 @@ describe_posterior.bcplm <- function(posterior, keep_iterations = keep_iterations, effects = "fixed", parameters = parameters, + verbose = verbose, ... ) if (isTRUE(priors)) { @@ -1180,6 +1211,7 @@ describe_posterior.bamlss <- function(posterior, keep_iterations = FALSE, component = c("all", "conditional", "location"), parameters = NULL, + verbose = TRUE, ...) { component <- match.arg(component) out <- .describe_posterior( @@ -1194,6 +1226,7 @@ describe_posterior.bamlss <- function(posterior, keep_iterations = keep_iterations, component = component, parameters = parameters, + verbose = verbose, ... ) @@ -1255,6 +1288,7 @@ describe_posterior.BFBayesFactor <- function(posterior, rope_range = rope_range, rope_ci = rope_ci, keep_iterations = keep_iterations, + verbose = verbose, ... ) diff --git a/R/equivalence_test.R b/R/equivalence_test.R index 39c12d819..6f3b4a6eb 100644 --- a/R/equivalence_test.R +++ b/R/equivalence_test.R @@ -110,7 +110,7 @@ equivalence_test.default <- function(x, ...) { #' @export equivalence_test.numeric <- function(x, range = "default", ci = 0.95, verbose = TRUE, ...) { - rope_data <- rope(x, range = range, ci = ci) + rope_data <- rope(x, range = range, ci = ci, verbose = verbose) out <- as.data.frame(rope_data) if (all(ci < 1)) { @@ -208,7 +208,7 @@ equivalence_test.BFBayesFactor <- function(x, range = "default", ci = 0.95, verb parameters = NULL, verbose = TRUE) { if (all(range == "default")) { - range <- rope_range(x) + range <- rope_range(x, verbose = verbose) } else if (!all(is.numeric(range)) || length(range) != 2L) { insight::format_error("`range` should be 'default' or a vector of 2 numeric values (e.g., c(-0.1, 0.1)).") } diff --git a/man/bayesfactor_parameters.Rd b/man/bayesfactor_parameters.Rd index b9904d92b..644494131 100644 --- a/man/bayesfactor_parameters.Rd +++ b/man/bayesfactor_parameters.Rd @@ -36,7 +36,7 @@ bayesfactor_rope( posterior, prior = NULL, direction = "two-sided", - null = rope_range(posterior), + null = rope_range(posterior, verbose = FALSE), verbose = TRUE, ... ) @@ -63,7 +63,7 @@ bf_rope( posterior, prior = NULL, direction = "two-sided", - null = rope_range(posterior), + null = rope_range(posterior, verbose = FALSE), verbose = TRUE, ... ) diff --git a/man/describe_posterior.Rd b/man/describe_posterior.Rd index 04c4f9819..1cfa19d72 100644 --- a/man/describe_posterior.Rd +++ b/man/describe_posterior.Rd @@ -21,6 +21,7 @@ describe_posterior(posterior, ...) keep_iterations = FALSE, bf_prior = NULL, BF = 1, + verbose = TRUE, ... ) @@ -42,6 +43,7 @@ describe_posterior(posterior, ...) "distributional", "auxiliary"), parameters = NULL, BF = 1, + verbose = TRUE, ... ) @@ -63,6 +65,7 @@ describe_posterior(posterior, ...) parameters = NULL, BF = 1, priors = FALSE, + verbose = TRUE, ... ) } @@ -118,6 +121,8 @@ case of models) ignored.} \item{BF}{The amount of support required to be included in the support interval.} +\item{verbose}{Toggle off warnings.} + \item{diagnostic}{Diagnostic metrics to compute. Character (vector) or list with one or more of these options: \code{"ESS"}, \code{"Rhat"}, \code{"MCSE"} or \code{"all"}.} From 6ec8fd5f862ad85a0208a5d62a4d020a8b08c7cf Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 7 Oct 2023 13:55:56 +0200 Subject: [PATCH 2/7] linbtr --- R/describe_posterior.R | 98 +++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/R/describe_posterior.R b/R/describe_posterior.R index 45ab6072a..a2cfe6cfd 100644 --- a/R/describe_posterior.R +++ b/R/describe_posterior.R @@ -169,7 +169,9 @@ describe_posterior.default <- function(posterior, ...) { # Point-estimates - if (!is.null(centrality)) { + if (is.null(centrality)) { + estimates <- data.frame(Parameter = NA) + } else { estimates <- .prepare_output( point_estimate(x_df, centrality = centrality, dispersion = dispersion, ...), cleaned_parameters, @@ -181,14 +183,14 @@ describe_posterior.default <- function(posterior, ...) { estimates ) } - } else { - estimates <- data.frame(Parameter = NA) } # Uncertainty - if (!is.null(ci)) { + if (is.null(ci)) { + uncertainty <- data.frame(Parameter = NA) + } else { ci_method <- match.arg(tolower(ci_method), c("hdi", "spi", "quantile", "ci", "eti", "si", "bci", "bcai")) # not sure why "si" requires the model object if (ci_method == "si") { @@ -208,14 +210,54 @@ describe_posterior.default <- function(posterior, ...) { uncertainty ) } - } else { - uncertainty <- data.frame(Parameter = NA) } # Effect Existence - if (!is.null(test)) { + if (is.null(test)) { + test_pd <- data.frame( + Parameter = NA, + Effects = NA, + Component = NA, + Response = NA + ) + + test_rope <- data.frame( + Parameter = NA, + Effects = NA, + Component = NA, + Response = NA + ) + + test_prope <- data.frame( + Parameter = NA, + Effects = NA, + Component = NA, + Response = NA + ) + + test_psig <- data.frame( + Parameter = NA, + Effects = NA, + Component = NA, + Response = NA + ) + + test_bf <- data.frame( + Parameter = NA, + Effects = NA, + Component = NA, + Response = NA + ) + + test_pmap <- data.frame( + Parameter = NA, + Effects = NA, + Component = NA, + Response = NA + ) + } else { test <- .check_test_values(test) if ("all" %in% test) { test <- c("pd", "p_map", "p_rope", "p_significance", "rope", "equivalence", "bf") @@ -384,48 +426,6 @@ describe_posterior.default <- function(posterior, ...) { } else { test_bf <- data.frame("Parameter" = NA) } - } else { - test_pd <- data.frame( - Parameter = NA, - Effects = NA, - Component = NA, - Response = NA - ) - - test_rope <- data.frame( - Parameter = NA, - Effects = NA, - Component = NA, - Response = NA - ) - - test_prope <- data.frame( - Parameter = NA, - Effects = NA, - Component = NA, - Response = NA - ) - - test_psig <- data.frame( - Parameter = NA, - Effects = NA, - Component = NA, - Response = NA - ) - - test_bf <- data.frame( - Parameter = NA, - Effects = NA, - Component = NA, - Response = NA - ) - - test_pmap <- data.frame( - Parameter = NA, - Effects = NA, - Component = NA, - Response = NA - ) } From b2aa5a59ef5608042a6c53c700d8f15a355d869b Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 7 Oct 2023 13:57:02 +0200 Subject: [PATCH 3/7] lintr --- R/equivalence_test.R | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/R/equivalence_test.R b/R/equivalence_test.R index 6f3b4a6eb..5d4a9226b 100644 --- a/R/equivalence_test.R +++ b/R/equivalence_test.R @@ -249,7 +249,15 @@ equivalence_test.stanreg <- function(x, range = "default", ci = 0.95, effects = c("fixed", "random", "all"), - component = c("location", "all", "conditional", "smooth_terms", "sigma", "distributional", "auxiliary"), + component = c( + "location", + "all", + "conditional", + "smooth_terms", + "sigma", + "distributional", + "auxiliary" + ), parameters = NULL, verbose = TRUE, ...) { From c931d443ee1d4b9c7044a820bb429a463ed1d0f7 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 7 Oct 2023 14:10:39 +0200 Subject: [PATCH 4/7] lintr --- R/describe_posterior.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/describe_posterior.R b/R/describe_posterior.R index a2cfe6cfd..fe9d87976 100644 --- a/R/describe_posterior.R +++ b/R/describe_posterior.R @@ -415,7 +415,7 @@ describe_posterior.default <- function(posterior, ...) { cleaned_parameters, is_stanmvreg ), - error = function(e) data.frame("Parameter" = NA) + error = function(e) data.frame(Parameter = NA) ) if (!"Parameter" %in% names(test_bf)) { test_bf <- cbind( @@ -424,7 +424,7 @@ describe_posterior.default <- function(posterior, ...) { ) } } else { - test_bf <- data.frame("Parameter" = NA) + test_bf <- data.frame(Parameter = NA) } } @@ -515,9 +515,9 @@ describe_posterior.default <- function(posterior, ...) { #' @keywords internal .add_effects_component_column <- function(x) { - if (!"Effects" %in% names(x)) x <- cbind(x, data.frame("Effects" = NA)) - if (!"Component" %in% names(x)) x <- cbind(x, data.frame("Component" = NA)) - if (!"Response" %in% names(x)) x <- cbind(x, data.frame("Response" = NA)) + if (!"Effects" %in% names(x)) x <- cbind(x, data.frame(Effects = NA)) + if (!"Component" %in% names(x)) x <- cbind(x, data.frame(Component = NA)) + if (!"Response" %in% names(x)) x <- cbind(x, data.frame(Response = NA)) x } From cadb4d6ab44ea90f23ab0cad10b5d608b40b1866 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 7 Oct 2023 16:53:57 +0200 Subject: [PATCH 5/7] update test --- tests/testthat/_snaps/windows/print.md | 8 ++------ tests/testthat/test-print.R | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/testthat/_snaps/windows/print.md b/tests/testthat/_snaps/windows/print.md index b88e10940..0ce29a9a9 100644 --- a/tests/testthat/_snaps/windows/print.md +++ b/tests/testthat/_snaps/windows/print.md @@ -1,9 +1,7 @@ # print.describe_posterior Code - describe_posterior(m) - Warning - Could not estimate a good default ROPE range. Using 'c(-0.1, 0.1)'. + describe_posterior(m, verbose = FALSE) Output Summary of Posterior Distribution @@ -16,9 +14,7 @@ --- Code - describe_posterior(m, effects = "all", component = "all") - Warning - Could not estimate a good default ROPE range. Using 'c(-0.1, 0.1)'. + describe_posterior(m, effects = "all", component = "all", verbose = FALSE) Output Summary of Posterior Distribution diff --git a/tests/testthat/test-print.R b/tests/testthat/test-print.R index bb2e50c86..d353c6601 100644 --- a/tests/testthat/test-print.R +++ b/tests/testthat/test-print.R @@ -5,6 +5,6 @@ test_that("print.describe_posterior", { skip_if_not_or_load_if_installed("httr") m <- insight::download_model("brms_zi_3") - expect_snapshot(describe_posterior(m), variant = "windows") - expect_snapshot(describe_posterior(m, effects = "all", component = "all"), variant = "windows") + expect_snapshot(describe_posterior(m, verbose = FALSE), variant = "windows") + expect_snapshot(describe_posterior(m, effects = "all", component = "all", verbose = FALSE), variant = "windows") }) From 43a7e15f4cd7e86b81316b78c642cca5815b21d4 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 7 Oct 2023 16:56:07 +0200 Subject: [PATCH 6/7] fix test --- R/describe_posterior.R | 2 +- tests/testthat/test-describe_posterior.R | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/describe_posterior.R b/R/describe_posterior.R index fe9d87976..abbd8ce8d 100644 --- a/R/describe_posterior.R +++ b/R/describe_posterior.R @@ -411,7 +411,7 @@ describe_posterior.default <- function(posterior, ...) { if (any(c("bf", "bayesfactor", "bayes_factor") %in% test)) { test_bf <- tryCatch( .prepare_output( - bayesfactor_parameters(x, prior = bf_prior, ...), + bayesfactor_parameters(x, prior = bf_prior, verbose = verbose, ...), cleaned_parameters, is_stanmvreg ), diff --git a/tests/testthat/test-describe_posterior.R b/tests/testthat/test-describe_posterior.R index 0daf5599a..ec76f60cb 100644 --- a/tests/testthat/test-describe_posterior.R +++ b/tests/testthat/test-describe_posterior.R @@ -12,14 +12,14 @@ test_that("describe_posterior", { x <- distribution_normal(4000) - describe_posterior( + expect_silent(describe_posterior( x, centrality = "all", dispersion = TRUE, test = "all", ci = 0.89, verbose = FALSE - ) + )) rez <- as.data.frame(suppressWarnings(describe_posterior( x, From 92ae82597c8bc5fd541b8ab406460e29f1e8c7eb Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 7 Oct 2023 17:03:58 +0200 Subject: [PATCH 7/7] pass verbose --- R/describe_posterior.R | 6 +-- R/p_rope.R | 84 ++++++++++++++++++++++++++++++++++-------- man/p_rope.Rd | 6 ++- 3 files changed, 76 insertions(+), 20 deletions(-) diff --git a/R/describe_posterior.R b/R/describe_posterior.R index abbd8ce8d..83296e60f 100644 --- a/R/describe_posterior.R +++ b/R/describe_posterior.R @@ -194,9 +194,9 @@ describe_posterior.default <- function(posterior, ...) { ci_method <- match.arg(tolower(ci_method), c("hdi", "spi", "quantile", "ci", "eti", "si", "bci", "bcai")) # not sure why "si" requires the model object if (ci_method == "si") { - uncertainty <- ci(x, BF = BF, method = ci_method, prior = bf_prior, ...) + uncertainty <- ci(x, BF = BF, method = ci_method, prior = bf_prior, verbose = verbose, ...) } else { - uncertainty <- ci(x_df, ci = ci, method = ci_method, ...) + uncertainty <- ci(x_df, ci = ci, method = ci_method, verbose = verbose, ...) } uncertainty <- .prepare_output( uncertainty, @@ -323,7 +323,7 @@ describe_posterior.default <- function(posterior, ...) { if ("p_rope" %in% test) { test_prope <- .prepare_output( - p_rope(x_df, range = rope_range, ...), + p_rope(x_df, range = rope_range, verbose = verbose, ...), cleaned_parameters, is_stanmvreg ) diff --git a/R/p_rope.R b/R/p_rope.R index d7267caa7..e88f656b6 100644 --- a/R/p_rope.R +++ b/R/p_rope.R @@ -30,8 +30,8 @@ p_rope.default <- function(x, ...) { #' @rdname p_rope #' @export -p_rope.numeric <- function(x, range = "default", ...) { - out <- .p_rope(rope(x, range = range, ci = 1, ...)) +p_rope.numeric <- function(x, range = "default", verbose = TRUE, ...) { + out <- .p_rope(rope(x, range = range, ci = 1, verbose = verbose, ...)) attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(x)) out } @@ -42,8 +42,8 @@ p_rope.data.frame <- p_rope.numeric #' @export -p_rope.draws <- function(x, range = "default", ...) { - p_rope(.posterior_draws_to_df(x), range = range, ...) +p_rope.draws <- function(x, range = "default", verbose = TRUE, ...) { + p_rope(.posterior_draws_to_df(x), range = range, verbose = verbose, ...) } #' @export @@ -51,10 +51,10 @@ p_rope.rvar <- p_rope.draws #' @export -p_rope.emmGrid <- function(x, range = "default", ...) { +p_rope.emmGrid <- function(x, range = "default", verbose = TRUE, ...) { xdf <- insight::get_parameters(x) - out <- p_rope(xdf, range = range) + out <- p_rope(xdf, range = range, verbose = verbose) attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(x)) out } @@ -71,8 +71,31 @@ p_rope.MCMCglmm <- p_rope.numeric #' @rdname p_rope #' @export -p_rope.stanreg <- function(x, range = "default", effects = c("fixed", "random", "all"), component = c("location", "all", "conditional", "smooth_terms", "sigma", "distributional", "auxiliary"), parameters = NULL, ...) { - out <- .p_rope(rope(x, range = range, ci = 1, effects = effects, component = component, parameters = parameters, ...)) +p_rope.stanreg <- function(x, + range = "default", + effects = c("fixed", "random", "all"), + component = c( + "location", + "all", + "conditional", + "smooth_terms", + "sigma", + "distributional", + "auxiliary" + ), + parameters = NULL, + verbose = verbose, + ...) { + out <- .p_rope(rope( + x, + range = range, + ci = 1, + effects = effects, + component = component, + parameters = parameters, + verbose = verbose, + ... + )) out <- .add_clean_parameters_attribute(out, x) attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(x)) out @@ -87,8 +110,23 @@ p_rope.blavaan <- p_rope.stanreg #' @rdname p_rope #' @export -p_rope.brmsfit <- function(x, range = "default", effects = c("fixed", "random", "all"), component = c("conditional", "zi", "zero_inflated", "all"), parameters = NULL, ...) { - out <- .p_rope(rope(x, range = range, ci = 1, effects = effects, component = component, parameters = parameters, ...)) +p_rope.brmsfit <- function(x, + range = "default", + effects = c("fixed", "random", "all"), + component = c("conditional", "zi", "zero_inflated", "all"), + parameters = NULL, + verbose = verbose, + ...) { + out <- .p_rope(rope( + x, + range = range, + ci = 1, + effects = effects, + component = component, + parameters = parameters, + verbose = verbose, + ... + )) out <- .add_clean_parameters_attribute(out, x) attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(x)) out @@ -100,24 +138,38 @@ p_rope.sim.merMod <- p_rope.stanreg #' @export -p_rope.sim <- function(x, range = "default", parameters = NULL, ...) { - out <- .p_rope(rope(x, range = range, ci = 1, parameters = parameters, ...)) +p_rope.sim <- function(x, range = "default", parameters = NULL, verbose = TRUE, ...) { + out <- .p_rope(rope(x, range = range, ci = 1, parameters = parameters, verbose = verbose, ...)) attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(x)) out } #' @export -p_rope.bamlss <- function(x, range = "default", component = c("all", "conditional", "location"), parameters = NULL, ...) { +p_rope.bamlss <- function(x, + range = "default", + component = c("all", "conditional", "location"), + parameters = NULL, + verbose = TRUE, + ...) { component <- match.arg(component) - out <- .p_rope(rope(x, range = range, ci = 1, effects = "all", component = component, parameters = parameters, ...)) + out <- .p_rope(rope( + x, + range = range, + ci = 1, + effects = "all", + component = component, + parameters = parameters, + verbose = verbose, + ... + )) out <- .add_clean_parameters_attribute(out, x) attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(x)) out } #' @export -p_rope.mcmc <- function(x, range = "default", parameters = NULL, ...) { - out <- .p_rope(rope(x, range = range, ci = 1, parameters = parameters, ...)) +p_rope.mcmc <- function(x, range = "default", parameters = NULL, verbose = TRUE, ...) { + out <- .p_rope(rope(x, range = range, ci = 1, parameters = parameters, verbose = verbose, ...)) attr(out, "object_name") <- insight::safe_deparse_symbol(substitute(x)) out } diff --git a/man/p_rope.Rd b/man/p_rope.Rd index 99515923c..52845be6e 100644 --- a/man/p_rope.Rd +++ b/man/p_rope.Rd @@ -9,7 +9,7 @@ \usage{ p_rope(x, ...) -\method{p_rope}{numeric}(x, range = "default", ...) +\method{p_rope}{numeric}(x, range = "default", verbose = TRUE, ...) \method{p_rope}{stanreg}( x, @@ -18,6 +18,7 @@ p_rope(x, ...) component = c("location", "all", "conditional", "smooth_terms", "sigma", "distributional", "auxiliary"), parameters = NULL, + verbose = verbose, ... ) @@ -27,6 +28,7 @@ p_rope(x, ...) effects = c("fixed", "random", "all"), component = c("conditional", "zi", "zero_inflated", "all"), parameters = NULL, + verbose = verbose, ... ) } @@ -45,6 +47,8 @@ to the name of the response variables. If \code{"default"} and input is a vector the range is set to \code{c(-0.1, 0.1)}. If \code{"default"} and input is a Bayesian model, \code{\link[=rope_range]{rope_range()}} is used.} +\item{verbose}{Toggle off warnings.} + \item{effects}{Should results for fixed effects, random effects or both be returned? Only applies to mixed models. May be abbreviated.}