Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
adapt to changed BF convention
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Oct 19, 2020
1 parent 7d3cc87 commit 59cee65
Show file tree
Hide file tree
Showing 39 changed files with 995 additions and 1,013 deletions.
7 changes: 5 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: pairwiseComparisons
Title: Multiple Pairwise Comparison Tests
Version: 3.0.0
Version: 3.0.0.9000
Authors@R:
person(given = "Indrajeet",
family = "Patil",
Expand All @@ -26,7 +26,8 @@ Depends:
Imports:
BayesFactor,
dplyr,
ipmisc (>= 4.0.0),
insight (>= 0.9.6.1),
ipmisc,
PMCMRplus,
parameters,
purrr,
Expand All @@ -38,6 +39,8 @@ Suggests:
rmarkdown,
spelling,
testthat
Remotes:
easystats/insight
Encoding: UTF-8
Language: en-US
LazyData: true
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ importFrom(dplyr,rowwise)
importFrom(dplyr,select)
importFrom(dplyr,starts_with)
importFrom(dplyr,ungroup)
importFrom(insight,standardize_names)
importFrom(ipmisc,"%$%")
importFrom(ipmisc,"%<-%")
importFrom(ipmisc,"%<>%")
importFrom(ipmisc,"%>%")
importFrom(ipmisc,as_tibble)
importFrom(ipmisc,easystats_to_tidy_names)
importFrom(ipmisc,enframe)
importFrom(ipmisc,long_to_wide_converter)
importFrom(ipmisc,signif_column)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# pairwiseComparisons 3.0.0.9000

- To be consistent with the rest of the `ggstatsverse`, the Bayes Factor
results are now always shown in favor of null over alternative (`BF01`).

# pairwiseComparisons 3.0.0

- The `label` column returned in `pairwise_comparisons` now displays the
Expand Down
210 changes: 2 additions & 208 deletions R/global_vars.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,214 +2,8 @@

utils::globalVariables(
names = c(
".",
"conf.level",
"nboot",
"U",
"V",
"Z",
"chi",
"counts",
"df",
"df.residual",
"df1",
"df2",
"desc",
"do",
"effsize",
"estimate",
"eta",
"omega",
"etasq",
"omegasq",
"perc",
"cramer",
"cramer_ci",
"pvalue",
"r",
"rho",
"xi",
"y",
"z_value",
"italic",
"rsubtitle",
"stats_subtitle",
"chi_subtitle",
"proptest_subtitle",
"LL",
"UL",
"outlier",
"outlier.label",
"proptest_subtitle",
"significance",
"..count..",
"..density..",
"dnorm",
"mean",
"median",
"sd",
"bf",
"bf_error",
"bf_prior",
"Df",
"F value",
"F.value",
"LL",
"Pr(>F)",
"UL",
"complete",
"data",
"df1",
"df2",
"effect",
"effsize",
"formula",
"hist",
"median",
"p0",
"p100",
"p50",
"p25",
"p75",
"sd",
"type",
"Chi-squared",
"df",
"p-value",
"chi_sq",
"significance",
"F-value",
"V2",
"V3",
"V4",
"V5",
"conf",
"AIC",
"BIC",
"R",
"adj.r.squared",
"p.value",
"psihat",
"term",
"label",
"loglik",
"Pr(>|t|)",
"coef",
"conf.high",
"conf.low",
"mean.high.conf",
"mean.low.conf",
"rowid",
"Cramer's V",
"df[chiSq]",
"p[chiSq]",
"value[chiSq]",
"condition_n_label",
"total_n",
"robust",
"partial.etasq",
"partial.omegasq",
"stratum",
"coefficient_type",
"mean.y",
"n.y",
"sd.y",
"se.y",
"std.error",
"pair",
"bold",
"x...internal",
"y...internal",
"or",
"atop",
"top.text",
"bottom.text",
"code",
"time",
"t-value",
"Group",
"Group1",
"group1",
"group2",
"Group..1",
"Group..2",
"Group...1",
"Group...2",
"ci.lower",
"ci.upper",
"comparison",
"p",
"p1",
"p2",
"high.conf",
"i1",
"i2",
"key",
"low.conf",
"mean.difference",
"p.crit",
"sep",
"value",
"var",
"label2",
"p.value.label",
"sampling.plan",
"displaystyle",
"textstyle",
"a",
"x",
"bf01",
"bf10",
"log_10_bf01",
"log_10_bf10",
"log_e_bf01",
"log_e_bf10",
"2.5 %",
"97.5 %",
"group",
"name",
"se",
"zvalue",
"isanoutlier",
"Cramer.V",
"t.value",
"ci.lb",
"ci.ub",
"pval",
"zval",
"statistic.z",
"variable",
"method",
"N",
"compare_list",
"I2",
"Q",
"tau",
"tau2",
"id",
"coef.type",
"Value",
"Statistic",
"statistic",
"d.pmean",
"d.pmean.LB",
"d.pmean.UB",
"Cramer V",
"lwr.ci",
"upr.ci",
"lower.ci",
"upper.ci",
"epsilon.squared",
"condition",
"main",
"pair1",
"W",
"stat",
"contrast",
"chi2",
"comparisons",
"z.value",
"altp"
".", "Group...1", "Group...2", "bf10", "ci.lower", "ci.upper",
"group1", "group2", "log_e_bf10", "p.crit", "p.value", "psihat"
),
package = "pairwiseComparisons",
add = FALSE
Expand Down
86 changes: 83 additions & 3 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ matrix_to_tidy <- function(m, col_name = "value", ...) {
#' @importFrom BayesFactor ttestBF
#' @importFrom dplyr mutate
#' @importFrom parameters model_parameters
#' @importFrom ipmisc easystats_to_tidy_names
#' @importFrom insight standardize_names
#'
#' @noRd
#' @keywords internal
Expand Down Expand Up @@ -87,7 +87,87 @@ bf_internal_ttest <- function(data,

# extracting Bayes Factors and other details
parameters::model_parameters(bf_object, ...) %>%
ipmisc::easystats_to_tidy_names(.) %>%
dplyr::rename(.data = ., bf10 = bf) %>%
insight::standardize_names(data = ., style = "broom") %>%
dplyr::rename(.data = ., "bf10" = "bayes.factor") %>%
dplyr::mutate(.data = ., log_e_bf10 = log(bf10))
}


#' @title Preparing text to describe which *p*-value adjustment method was used
#' @name p_adjust_text
#' @return Standardized text description for what method was used.
#'
#' @inheritParams pairwise_comparisons
#'
#' @examples
#' library(pairwiseComparisons)
#' p_adjust_text("none")
#' p_adjust_text("BY")
#' @export

p_adjust_text <- function(p.adjust.method) {
switch(
EXPR = p.adjust.method,
none = "None",
bonferroni = "Bonferroni",
holm = "Holm",
hochberg = "Hochberg",
hommel = "Hommel",
BH = "FDR",
fdr = "FDR",
BY = "BY",
"Holm"
)
}


#' @name pairwise_caption
#' @title Expression containing details about pairwise comparison test
#' @description This returns an expression containing details about the pairwise
#' comparison test and the *p*-value adjustment method. These details are
#' typically included in the `ggstatsplot` package plots as a caption.
#'
#' @param test.description Text describing the details of the test.
#' @param caption Additional text to be included in the plot.
#' @param pairwise.display Decides which pairwise comparisons to display.
#' Available options are `"significant"` (abbreviation accepted: `"s"`) or
#' `"non-significant"` (abbreviation accepted: `"ns"`) or
#' `"everything"`/`"all"`. The default is `"significant"`.
#' @param ... Ignored.
#'
#' @examples
#' library(pairwiseComparisons)
#' pairwise_caption("my caption", "Student's t-test")
#' @export

pairwise_caption <- function(caption,
test.description,
pairwise.display = "significant",
...) {
# which comparisons are shown? (standardize strings)
pairwise.display <-
switch(
EXPR = substr(x = pairwise.display, start = 1L, stop = 1L),
s = "only significant",
n = "only non-significant",
"all"
)

# create expression
substitute(
atop(
displaystyle(top.text),
expr = paste(
"Pairwise test: ",
bold(test.description),
"; Comparisons shown: ",
bold(pairwise.display)
)
),
env = list(
top.text = caption,
test.description = test.description,
pairwise.display = pairwise.display
)
)
}

0 comments on commit 59cee65

Please sign in to comment.