CVM2gof | R Documentation |
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.
CVM2gof(
x,
y,
alternative = c("two.sided", "less", "greater"),
nboots = 2000,
keep.boots = FALSE
)
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 |
nboots |
Number of bootstrap replicates to approximate the null distribution (default: 2000). |
keep.boots |
Logical. If |
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.
An object of class "htest"
with elements:
Observed Cramér–von Mises test statistic.
Bootstrap-based p-value.
The alternative hypothesis used.
A description of the test.
(Optional) Vector of bootstrap test statistics if keep.boots = TRUE
.
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.