AD2gof {Dogoftest}R Documentation

Two-Sample Anderson-Darling Test (Bootstrap Version)

Description

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.

Usage

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

Arguments

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').

Details

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.

Value

A list of class '"htest"' containing:

statistic

The observed Anderson-Darling test statistic.

p.value

The estimated bootstrap p-value.

alternative

The alternative hypothesis used.

method

A character string describing the test.

bootstraps

(Optional) A numeric vector of bootstrap statistics if 'keep.boots = TRUE'.

Examples

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


[Package Dogoftest version 0.2 Index]