Learn R Programming

wmwAUC (version 0.2.0)

quadruplot: Four EDA Plots for Visual Assessment of Location-Shift Assumption

Description

Creates four diagnostic plots to visually assess whether the location-shift assumption \(F_1(x) = F_2(x - \delta)\) holds: (1) boxplot with swarmplot overlay, (2) density plot comparison, (3) wormplot of median-centered residuals, and (4) empirical CDF comparison with confidence band for median-centered data.

Usage

quadruplot(
  formula,
  data,
  ref_level = NULL,
  test = "ks",
  seed = 123L,
  ylab = NULL,
  color_palette = "lancet",
  combine_plots = TRUE,
  distribution = "norm",
  show_colors = TRUE,
  show_legend = TRUE
)

Value

If combine_plots = TRUE, returns a combined ggplot object created by patchwork. If FALSE, returns a list of four ggplot objects named 'boxplot', 'density', 'wormplot', and 'ecdf'.

Arguments

formula

Formula of the form response ~ group

data

Data frame containg response, group

ref_level

Character, reference level of the grouping factor. If NULL (default), uses first factor level

test

Character, statistical test for shift-equivalence assumption. Tests for distributional equality applied to median-centered data: "ks" (Kolmogorov-Smirnov) (default), "kuiper" (Kuiper), "cvm" (Cramér-von Mises), "ad" (Anderson-Darling), "wass" (Wasserstein), "dts" (DTS test).

seed

Numeric, for set.seed() used in test_shift_equivalence() for bootstrap.

ylab

Character, label for y-axis. If NULL (default), uses variable name

color_palette

Character, color palette to use. One of "viridis", "plasma", "inferno", "magma", or "cividis"

combine_plots

Logical, whether to return combined plot using patchwork (TRUE) or list of individual plots (FALSE)

distribution

Character, theoretical distribution for Q-Q plot comparison. Default is "norm" for normal distribution

show_colors

Logical, whether to use colors (TRUE) or grayscale (FALSE)

show_legend

Logical, whether to display legend in plots (default TRUE)

Details

The location-shift assumption is assessed by applying a test of H0: equality of distributions to median-centered data. One of the tests from the twosamples package can be used. The empirical CDF plot includes 95% confidence bands for the difference between distributions, computed using the sfsmisc::KSd function based on the Kolmogorov-Smirnov distribution. These bands help assess whether observed differences between median-centered distributions exceed what would be expected under the location-shift assumption.

References

O'Dowd, C. (2025). Statistical Code Examples. https://codowd.com/code (accessed November 28, 2025).

Maechler M (2024). sfsmisc: Utilities from 'Seminar fuer Statistik' ETH Zurich. R package version 1.1-20, https://CRAN.R-project.org/package=sfsmisc.

Examples

Run this code
library(wmwAUC)

data(Ex2)
da <- Ex2
qp = quadruplot(y ~ group, data = da, ref_level = 'control')
qp


Run the code above in your browser using DataLab