Solved – Anderson Darling Test on student-T distribution

anderson darling testt-distribution

I would like to do an Anderson Darling test in R using ad.test() from the package “goftest”.
My null hypothesis is H0: Data follows a student-t distribution with 2 degrees of freedom.

I receive the statistic “An” and the “p-value”.

To decide (on a 5% level) whether to reject H0 or not, I could:

a)Compare “An” with a critical value.
QUESTION: But how do I know what this critical value is?
R does not show a critical value. Is there a table where I can look it up or a formula from a paper.

Or

b)I could just look at the p-value. If I receive a p-value smaller than 0.05, I will reject H0.
QUESTION: But how is the p-value calculated in my case? Is there a literature that shows a formula?

Note: The anderson darling test can test any distribution. But I didn't find literature that shows me how to do it when testing if the data comes from a student-T.

In case a reproducible example is needed for discussion, I propose:

library(goftest) 

set.seed(403)
data<-rt(n = 300, df=2)

ad.test(x = data,null = "pt", df = 2)

Best Answer

For a fully specified distribution, the Anderson-Darling - as with the Kolmogorov-Smirnov, the Cramer-von Mises, the Kuiper test and many other ecdf-based tests - is distribution-free.

So you don't need tables for the 'standard t' such as that represented by the cdf function pt. All you need do is apply pt to your data (data$^\dagger$) and test that for uniformity ... which is effectively what these tests all do, and that's how goftest::ad.test works -- it uses fully specified distributions.

The asymptotic distribution of the Anderson-Darling test statistic for completely specified distributions was worked out by Anderson and Darling (1952, 1954) -- the 1952 paper gives the theory of computation of the asymptotic distribution (of a large class of tests of the Cramer-von Mises type, including specific discussion of what would become known as the Anderson-Darling test) and the 1954 paper gives asymptotic 10%, 5% and 1% critical values for the Anderson-Darling statistic.

In that paper they say that convergence to the asymptotic distribution is rapid and suggest it should be okay by $n=40$. Stephens (1974) suggests using it for $n\ge 5$.

Peter Lewis (1961) did tabulations of the distribution for $n\le 8$.

A little testing of goftest::ad.test suggests that the code isn't using the asymptotic distribution down at n=10, however (e.g. simulation at n=10 shows that the 5% CV there is around 2.512, which is larger than the asymptotic value). So if all else fails, let's read the help.

The help for ad.test refers to Marsaglia and Marsaglia (2004). They use simulation for $n=2^k$ for $k=3,4,5,6,7$ to identify a simple 3-piece transformation of the small-sample test statistic (scaled by 1/n) so that the asymptotic distribution can be used for small $n$. So it seems their code takes the statistic, scales it a little bit according to their piecewise transformation, and then compares that to the asymptotic distribution.

Anderson, T. W.; Darling, D. A. (1952).
"Asymptotic theory of certain "goodness-of-fit" criteria based on stochastic processes"
Annals of Mathematical Statistics 23: 193–212.

Anderson, T.W. and Darling, D.A. (1954).
"A Test of Goodness-of-Fit",
Journal of the American Statistical Association 49: 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

P.A. Lewis, (1961),
"Distribution of the Anderson-Darling Statistic,"
Ann. Math. Stat., 32 1118-1124.

Marsaglia, G. and Marsaglia, J. (2004)
"Evaluating the Anderson-Darling Distribution."
Journal of Statistical Software, 9 (2), 1-5. February.
http://www.jstatsoft.org/v09/i02

$\dagger$ About which:

install.packages("fortunes")
library(fortunes)
fortune(77)