# Is the Anderson-Darling test similar to the Kruskal-Wallis test to compare more than 2 groups?

I would like to compare more than 2 groups (their dependent variable is not distributed normally).

Can I use the Anderson-Darling test like I would use the Kruskal-Wallis test? I have no specific reason to choose the former, this is mainly a way to learn something new about nonparametric tests.

(I use R)

Non-technical response: The tests look at different things. The documentation for the kSamples package does an okay job suggesting how they are different. It's my understanding that Anderson-Darling is testing if the distributions are the same overall, whereas Kruskal-Wallis is looking for a stochastic difference, that is specifically if the values in one distribution is higher than in the other. Practically speaking, the question you are trying to answer with each of these is very different.

The following example will produce a vector X with normally-distributed values, a median of 0, and a range of about -25 to 25. Y will be a vector with simply twice the values of X.

The Anderson-Darling test will report that they are different distributions. The distributions are similar in shape and location, but the range of Y is twice that of X.

Kruskal-Wallis, however, will not find a stochastic difference between the two distributions, since they are similar in shape with the same medians. It's not the case that the values of one distribution are greater than those of the other.

set.seed(5)
X = rnorm(100)*10
X = X - median(X)
Y = X * 2

Value = c(X, Y)
Group = c(rep("X", length(X)), rep("Y", length(X)))
Data  = data.frame(Group, Value)

if(!require(lattice)){install.packages("lattice")}
library(lattice)
histogram(~ Value | Group,
data=Data,
layout=c(1,2)) if(!require(kSamples)){install.packages("kSamples")}
library(kSamples)

### Anderson-Darling k-sample test.

### version 1: 5.248 5.632         0.002071
### version 2: 5.290 5.692         0.001974

kruskal.test(Value ~ Group, data=Data)

### Kruskal-Wallis rank sum test

### Kruskal-Wallis chi-squared = 0.016143, df = 1, p-value = 0.8989

summary(X)
summary(Y)

###    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
### -20.900  -4.992   0.000   1.256   8.637  24.812

###    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
### -41.800  -9.984   0.000   2.512  17.274  49.624

• Very informative example, thank you. It will help my study – statisticianwannabe Dec 13 '17 at 17:36