diff --git a/API b/API index 2a7e722..cf9a11f 100644 --- a/API +++ b/API @@ -2,13 +2,13 @@ ## Exported functions -bf_contingency_tab(data, x, y = NULL, counts = NULL, ratio = NULL, sampling.plan = "indepMulti", fixed.margin = "rows", prior.concentration = 1, caption = NULL, output = "results", k = 2L, ...) -bf_corr_test(data, x, y, bf.prior = 0.707, caption = NULL, output = "results", k = 2L, ...) +bf_contingency_tab(data, x, y = NULL, counts = NULL, ratio = NULL, sampling.plan = "indepMulti", fixed.margin = "rows", prior.concentration = 1, caption = NULL, output = "dataframe", k = 2L, ...) +bf_corr_test(data, x, y, bf.prior = 0.707, caption = NULL, output = "dataframe", k = 2L, ...) bf_expr(bf.object, k = 2L, conf.level = 0.95, conf.method = "hdi", centrality = "median", output = "null", caption = NULL, anova.design = FALSE, ...) bf_extractor(bf.object, ...) -bf_meta(data, d = prior("norm", c(mean = 0, sd = 0.3)), tau = prior("invgamma", c(shape = 1, scale = 0.15)), k = 2L, output = "results", caption = NULL, messages = TRUE, ...) -bf_oneway_anova(data, x, y, bf.prior = 0.707, caption = NULL, output = "results", paired = FALSE, k = 2L, ...) -bf_ttest(data, x, y = NULL, test.value = 0, paired = FALSE, bf.prior = 0.707, caption = NULL, output = "results", k = 2L, ...) +bf_meta(data, d = prior("norm", c(mean = 0, sd = 0.3)), tau = prior("invgamma", c(shape = 1, scale = 0.15)), k = 2L, output = "dataframe", caption = NULL, ...) +bf_oneway_anova(data, x, y, bf.prior = 0.707, caption = NULL, output = "dataframe", paired = FALSE, k = 2L, ...) +bf_ttest(data, x, y = NULL, test.value = 0, paired = FALSE, bf.prior = 0.707, caption = NULL, output = "dataframe", k = 2L, ...) meta_data_check(data) ## Reexported objects diff --git a/NEWS.md b/NEWS.md index a20c095..1821f4a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -9,6 +9,9 @@ BREAKING CHANGES hypothesis (`BF10`) and its `log` value to avoid cluttered dataframe since all the other columns were essentially mathematical transformations of it and not really relevant. + + - The `output` argument's default value has been changed from too generic + `"results"` to `"dataframe"`. MAJOR CHANGES diff --git a/R/bf_contingency_tab.R b/R/bf_contingency_tab.R index 9907d0e..94b6295 100644 --- a/R/bf_contingency_tab.R +++ b/R/bf_contingency_tab.R @@ -82,7 +82,7 @@ bf_contingency_tab <- function(data, fixed.margin = "rows", prior.concentration = 1, caption = NULL, - output = "results", + output = "dataframe", k = 2L, ...) { @@ -230,7 +230,7 @@ bf_contingency_tab <- function(data, # return the text results or the dataframe with results return(switch( EXPR = output, - "results" = dplyr::select(df, -dplyr::matches("error|time|code")), + "dataframe" = dplyr::select(df, -dplyr::matches("error|time|code")), bf_message )) } diff --git a/R/bf_corr_test.R b/R/bf_corr_test.R index 59cd126..7537a9f 100644 --- a/R/bf_corr_test.R +++ b/R/bf_corr_test.R @@ -47,7 +47,7 @@ bf_corr_test <- function(data, y, bf.prior = 0.707, caption = NULL, - output = "results", + output = "dataframe", k = 2L, ...) { @@ -62,7 +62,7 @@ bf_corr_test <- function(data, # return the text results or the dataframe with results switch( EXPR = output, - "results" = bf_extractor(bf_object), + "dataframe" = bf_extractor(bf_object), bf_expr(bf_object, k = k, output = output, caption = caption, ...) ) } diff --git a/R/bf_meta.R b/R/bf_meta.R index a368274..6660e40 100644 --- a/R/bf_meta.R +++ b/R/bf_meta.R @@ -7,7 +7,6 @@ #' sizes or outcomes) and `std.error` (corresponding standard errors). These #' two columns will be used for `yi` and `sei` arguments in `metafor::rma` #' (for parametric analysis) or `metaplus::metaplus` (for robust analysis). -#' @param messages Deprecated. Retained only for backward compatibility. #' @inheritParams bf_expr #' @inheritParams metaBMA::meta_random #' @inheritDotParams metaBMA::meta_random -y -SE @@ -48,7 +47,6 @@ #' data = df, #' k = 3, #' iter = 1500, -#' messages = TRUE, #' # customizing analysis with additional arguments #' control = list(max_treedepth = 15) #' ) @@ -61,9 +59,8 @@ bf_meta <- function(data, d = prior("norm", c(mean = 0, sd = 0.3)), tau = prior("invgamma", c(shape = 1, scale = 0.15)), k = 2L, - output = "results", + output = "dataframe", caption = NULL, - messages = TRUE, ...) { # check the data contains needed column @@ -72,7 +69,7 @@ bf_meta <- function(data, #----------------------- meta-analysis ------------------------------- # extracting results from random-effects meta-analysis - meta_res <- + mod <- metaBMA::meta_random( y = data$estimate, SE = data$std.error, @@ -84,12 +81,9 @@ bf_meta <- function(data, #----------------------- preparing caption ------------------------------- # creating a dataframe with posterior estimates - df_estimates <- - as_tibble(meta_res$estimates, rownames = "term") %>% - dplyr::filter(.data = ., term == "d") - - # dataframe with bayes factors - df <- tibble(bf10 = meta_res$BF["random_H1", "random_H0"]) + df <- + as_tibble(mod$estimates, rownames = "term") %>% + dplyr::mutate(.data = ., bf10 = mod$BF["random_H1", "random_H0"]) # changing aspects of the caption based on what output is needed if (output %in% c("null", "caption", "H0", "h0")) { @@ -127,16 +121,16 @@ bf_meta <- function(data, top.text = caption, bf.sub = bf.sub, bf = specify_decimal_p(x = bf.value, k = k), - d.pmean = specify_decimal_p(x = df_estimates$mean[[1]], k = k), - d.pmean.LB = specify_decimal_p(x = df_estimates$hpd95_lower[[1]], k = k), - d.pmean.UB = specify_decimal_p(x = df_estimates$hpd95_upper[[1]], k = k) + d.pmean = specify_decimal_p(x = df$mean[[1]], k = k), + d.pmean.LB = specify_decimal_p(x = df$hpd95_lower[[1]], k = k), + d.pmean.UB = specify_decimal_p(x = df$hpd95_upper[[1]], k = k) ) ) # return the text results or the dataframe with results return(switch( EXPR = output, - "results" = df, + "dataframe" = df, bf_message )) } diff --git a/R/bf_oneway_anova.R b/R/bf_oneway_anova.R index 356a7bf..e12becf 100644 --- a/R/bf_oneway_anova.R +++ b/R/bf_oneway_anova.R @@ -55,7 +55,7 @@ bf_oneway_anova <- function(data, y, bf.prior = 0.707, caption = NULL, - output = "results", + output = "dataframe", paired = FALSE, k = 2L, ...) { @@ -112,7 +112,7 @@ bf_oneway_anova <- function(data, # return the text results or the dataframe with results switch( EXPR = output, - "results" = bf_extractor(bf_object), + "dataframe" = bf_extractor(bf_object), bf_expr(bf_object, k = k, output = output, caption = caption, anova.design = TRUE, ...) ) } diff --git a/R/bf_ttest.R b/R/bf_ttest.R index 1a19ce5..5e07e7d 100644 --- a/R/bf_ttest.R +++ b/R/bf_ttest.R @@ -54,7 +54,7 @@ bf_ttest <- function(data, paired = FALSE, bf.prior = 0.707, caption = NULL, - output = "results", + output = "dataframe", k = 2L, ...) { @@ -118,7 +118,7 @@ bf_ttest <- function(data, # return the text results or the dataframe with results switch( EXPR = output, - "results" = bf_extractor(bf_object), + "dataframe" = bf_extractor(bf_object), bf_expr(bf_object, k = k, output = output, caption = caption, ...) ) } diff --git a/R/helpers_bf_tests.R b/R/helpers_bf_tests.R index 9f6cc1c..6d41e87 100644 --- a/R/helpers_bf_tests.R +++ b/R/helpers_bf_tests.R @@ -66,7 +66,7 @@ bf_extractor <- function(bf.object, ...) { #' which will return expression with evidence in favor of the null hypothesis, #' or `"alternative"` (or `"title"` or `"H1"` or `"h1"`), which will return #' expression with evidence in favor of the alternative hypothesis, or -#' `"results"`, which will return a dataframe with results all the details). +#' `"dataframe"`, which will return a dataframe with results all the details). #' @param anova.design Whether the object is from `BayesFactor::anovaBF` #' (default: `FALSE`). The expression is different for anova designs because #' not all details are available. diff --git a/codemeta.json b/codemeta.json index c9ae578..3d7af16 100644 --- a/codemeta.json +++ b/codemeta.json @@ -229,5 +229,5 @@ "name": "Comprehensive R Archive Network (CRAN)", "url": "https://cran.r-project.org" }, - "fileSize": "1655.411KB" + "fileSize": "1659.995KB" } diff --git a/docs/news/index.html b/docs/news/index.html index 1ae1ca4..39f97a6 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -132,6 +132,7 @@

MAJOR CHANGES