CVM2gof {Dogoftest}R Documentation

Two-Sample Cramér–von Mises Test (Bootstrap Version)

Description

Performs a nonparametric two-sample Cramér–von Mises test using a permutation-based bootstrap method to assess whether two samples come from the same distribution.

Usage

CVM2gof(
  x,
  y,
  alternative = c("two.sided", "less", "greater"),
  nboots = 2000,
  keep.boots = FALSE
)

Arguments

x

Numeric vector of observations from the first sample.

y

Numeric vector of observations from the second sample.

alternative

Character string specifying the alternative hypothesis. Must be one of "two.sided" (default), "less", or "greater".

nboots

Number of bootstrap replicates to approximate the null distribution (default: 2000).

keep.boots

Logical. If TRUE, the bootstrap statistics will be returned (default: FALSE).

Details

The test compares two empirical cumulative distribution functions (ECDFs). The bootstrap procedure permutes group labels to generate the null distribution. Tailored one-sided tests use one-sided squared differences of ECDFs.

Value

An object of class "htest" with elements:

statistic

Observed Cramér–von Mises test statistic.

p.value

Bootstrap-based p-value.

alternative

The alternative hypothesis used.

method

A description of the test.

bootstraps

(Optional) Vector of bootstrap test statistics if keep.boots = TRUE.

Examples

set.seed(123)
x <- rnorm(100, mean = 0, sd = 4)
y <- rnorm(100, mean = 2, sd = 4)
CVM2gof(x, y)

# One-sided test
CVM2gof(x, y, alternative = "greater")

# Store bootstrap replicates
res <- CVM2gof(x, y, keep.boots = TRUE)
hist(res$bootstraps, main = "Bootstrap Distribution", xlab = "Test Statistic")


[Package Dogoftest version 0.2 Index]