test_tmulti: Multiple pairwise comparisons with diagnostics

View source: R/Multi_T_test.R

test_tmultiR Documentation

Multiple pairwise comparisons with diagnostics

Description

Performs multiple pairwise comparisons using Student's t-test or the Mann-Whitney U test, with automatic diagnostic checks, effect size estimation, confidence intervals, multiple testing correction, and visualization.

Usage

test_tmulti(
  ...,
  comparisons = NULL,
  title = "Multiple comparisons (t / MW)",
  xlab = "",
  ylab = "Value",
  style = c("boxplot", "violin", "mono", "halfeye"),
  p_adjust = c("none", "holm", "BH", "bonferroni"),
  colors = NULL,
  help = FALSE,
  verbose = TRUE
)

Arguments

...

Numeric vectors or a data frame containing groups in columns.

comparisons

Optional list of character vectors specifying pairwise comparisons between groups. Each element should contain two group names, such as c("A", "B"). If NULL, all pairwise combinations are used.

title

Plot title.

xlab

Character string specifying the x-axis label.

ylab

Character string specifying the y-axis label.

style

Character string specifying the plot style generated by the function. One of boxplot, violin, mono, or halfeye. Default: boxplot.

p_adjust

Character string specifying the method used for multiple testing correction. Supported methods include none, holm, BH, and bonferroni.

colors

Optional character vector specifying the box colors.

help

Logical. If TRUE, displays usage examples.

verbose

Logical. If TRUE, prints results and plots.

Details

Normality is assessed using the Shapiro-Wilk test, and homogeneity of variances is assessed using Levene's test. When the assumptions are met, a pooled-variance Student's t-test is used. Otherwise, the Mann-Whitney U test is applied with bootstrap confidence intervals.

Effect sizes are calculated as follows:

  • Cohen's d for t-tests.

  • Rank-biserial correlation for Mann-Whitney U tests.

Value

A list containing the following components:

results

A tibble containing the pairwise test results.

plot

A plot object generated using ggplot2.

data_long

Long-format data used for plotting.

Examples

set.seed(123)
df <- data.frame(
  control = rnorm(30, mean = 10),
  treatment = rnorm(30, mean = 12),
  test1 = rnorm(30, mean = 11),
  test2 = rnorm(30, mean = 15)
)

test_tmulti(
  df,
  comparisons = list(
    c("control", "treatment"),
    c("treatment", "test1")
  )
)


autotestR documentation built on Oct. 27, 2026, 1:07 a.m.