Skip to contents

Native implementation for the two composite null hypotheses that have published percentage points: the normal distribution with unknown mean and variance, and the exponential distribution with unknown mean. The statistic is $$A^2 = -n - n^{-1}\sum (2i-1)[\ln F(z_i) + \ln(1 - F(z_{n+1-i}))]$$ and is then modified for the estimated parameters before being compared with the tabulated points (see .gof_lillie_crit for the table provenance).

Usage

anderson_darling(x, dist = c("norm", "expon"))

Arguments

x

Numeric vector.

dist

Either "norm" (default) or "expon".

Value

A morie_test_result (subclass of morie_rich_result) with the modified statistic \(A^*\) as test_statistic, the p-value, and sample size n. extra carries the unmodified a_squared and, when the statistic falls outside the tabulated range, p_bounded set to "upper" or "lower" – the p-value is then the nearest tabulated bound, not an exact value.

Details

Because the fitted parameters are estimated from the same sample, the unmodified \(A^2\) is not referred to its own null distribution; \(A^* = A^2(1 + 0.75/n + 2.25/n^2)\) in the normal case and \(A^* = A^2(1 + 0.3/n)\) in the exponential case.

References

Gibbons, J. D. & Chakraborti, S. (2010). Nonparametric Statistical Inference, 5th edn. CRC Press. Section 4.7 and Table 4.7.1.

Stephens, M. A. (1986). Tests based on EDF statistics. In R. B. D'Agostino & M. A. Stephens (eds), Goodness-of-Fit Techniques. Marcel Dekker.

Examples

set.seed(1)
res <- anderson_darling(rnorm(60))
res$test_statistic
#> [1] 0.2870253
anderson_darling(rexp(60), dist = "expon")$p_value
#> [1] 0.15