Performs the Anderson-Darling test for normality to assess whether a given
sample comes from a normal distribution. This implementation follows the
methodology from the nortest R package.
Value
A list with class "htest" containing the following components:
statistic- The Anderson-Darling test statistic (A)p.value- The p-value for the testmethod- The name of the method ("Anderson-Darling normality test")data.name- The name of the data used in the test
Details
The Anderson-Darling test is a statistical test of whether a given sample of data is drawn from a normal distribution. The test is a modification of the Kolmogorov-Smirnov (K-S) test and gives more weight to the tails than the K-S test.
This implementation requires a minimum sample size of 8 observations. The test statistic is calculated as: $$A^2 = -n - \frac{1}{n}\sum_{i=1}^n(2i-1)[\ln(p_i) + \ln(1-p_{n+1-i})]$$ where \(p_i = \Phi((x_i - \mu)/\sigma)\) and \(\Phi\) is the cumulative distribution function of the standard normal distribution.
The p-value is calculated using different approximation formulas depending on the value of the adjusted test statistic:
For AA < 0.2: \(p = 1 - \exp(-13.436 + 101.14 \times AA - 223.73 \times AA^2)\)
For 0.2 ≤ AA < 0.34: \(p = 1 - \exp(-8.318 + 42.796 \times AA - 59.938 \times AA^2)\)
For 0.34 ≤ AA < 0.6: \(p = \exp(0.9177 - 4.279 \times AA - 1.38 \times AA^2)\)
For 0.6 ≤ AA < 10: \(p = \exp(1.2937 - 5.709 \times AA + 0.0186 \times AA^2)\)
For AA ≥ 10: \(p = 3.7 \times 10^{-24}\)
where \(AA = A^2 \times (1 + 0.75/n + 2.25/n^2)\).
References
This implementation is based on the nortest package:
Gross, J. and Ligges, U. (2015). nortest: Tests for Normality. R package version 1.0-4. https://CRAN.R-project.org/package=nortest
The original test is described in:
Anderson, T.W. and Darling, D.A. (1954). A Test of Goodness of Fit. Journal of the American Statistical Association, 49(268), 765-769.
Stephens, M.A. (1974). EDF Statistics for Goodness of Fit and Some Comparisons. Journal of the American Statistical Association, 69(347), 730-737.
See also
ad.test for the original implementation in the nortest package.
shapiro.test for the Shapiro-Wilk normality test.
ks.test for the Kolmogorov-Smirnov test.
Other normality_test:
cvm.test(),
dagostino.test(),
jb.test.modified(),
pearson.test(),
sf.test()
Examples
if (FALSE) { # \dontrun{
# Test a sample from normal distribution
set.seed(123)
normal_data <- rnorm(100)
ad.test(normal_data)
# Test a sample from non-normal distribution
exponential_data <- rexp(50)
ad.test(exponential_data)
# Test with real data
if (require("datasets")) {
ad.test(iris$Sepal.Length)
}
} # }