test.kruskal: Kruskal-Wallis Test with Dunn Post-hoc

View source: R/Kruskal_test.R

test.kruskalR Documentation

Kruskal-Wallis Test with Dunn Post-hoc

Description

Performs the Kruskal-Wallis rank-sum test for comparing three or more independent groups, followed by Dunn's post-hoc test with multiple comparison adjustment.

Usage

test.kruskal(
  ...,
  title = "Kruskal-Wallis + Dunn",
  xlab = "Group",
  ylab = "Value",
  style = c("boxplot", "violin", "mono", "halfeye"),
  adjust = c("bonferroni", "holm", "BH"),
  help = FALSE,
  verbose = TRUE
)

Arguments

...

Numeric vectors representing groups, or a data frame with two or more columns (each column is treated as a group).

title

Character. Plot title.

xlab

Character. X-axis label.

ylab

Character. Y-axis label.

style

Character. Plot style. One of: "boxplot", "violin", "mono", or "halfeye".

adjust

Character. Method for p-value adjustment in Dunn's test. One of "bonferroni", "holm", or "BH".

help

Logical. If TRUE, displays a short help message and exits.

verbose

Logical. If TRUE, prints formatted statistical results to the console.

Details

This function is a non-parametric alternative to one-way ANOVA and is recommended when normality or homoscedasticity assumptions are violated.

Value

Invisibly returns a list with the following components:

type

Test type.

H

Kruskal-Wallis H statistic.

df

Degrees of freedom.

p

Global test p-value.

epsilon_sq

Epsilon-squared effect size.

epsilon_ci

Bootstrap confidence interval for effect size.

means_sd

Group means and standard deviations.

dunn

Dunn post-hoc results.

significant_pairs

Significant pairwise comparisons.

data

Long-format data used in the analysis.

Examples

set.seed(123)

n <- 25

df <- data.frame(
  control    = rexp(n, rate = 1),
  treatment1 = rexp(n, rate = 0.6),
  treatment2 = rgamma(n, shape = 2, scale = 1)
)

test.kruskal(df)


autotestR documentation built on April 29, 2026, 1:09 a.m.