AD2gof | R Documentation |
Performs a two-sample Anderson-Darling (AD) goodness-of-fit test using bootstrap resampling to compare whether two samples come from the same distribution. This test is sensitive to differences in both location and shape between the two distributions.
AD2gof(
x,
y,
alternative = c("two.sided", "less", "greater"),
nboots = 2000,
keep.boots = FALSE
)
x |
A numeric vector of data values from the first sample. |
y |
A numeric vector of data values from the second sample. |
alternative |
Character string specifying the alternative hypothesis. One of '"two.sided"' (default), '"less"', or '"greater"'. |
nboots |
Integer. Number of bootstrap replicates to compute the null distribution (default: 2000). |
keep.boots |
Logical. If 'TRUE', returns the full vector of bootstrap statistics (default: 'FALSE'). |
The test computes the Anderson-Darling statistic using the pooled empirical distribution functions (ECDFs) of the two samples. A bootstrap procedure resamples the group labels to approximate the null distribution and compute a p-value. If 'p.value = 0', it is adjusted to '1 / (2 * nboots)' for stability.
A list of class '"htest"' containing:
The observed Anderson-Darling test statistic.
The estimated bootstrap p-value.
The alternative hypothesis used.
A character string describing the test.
(Optional) A numeric vector of bootstrap statistics if 'keep.boots = TRUE'.
set.seed(123)
x <- rnorm(100, mean = 0, sd = 4)
y <- rnorm(100, mean = 2, sd = 4)
AD2gof(x, y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.