**June 2011**

You have a set of data. You would like to know if it fits a certain distribution - for example, the normal distribution. Maybe there are a number of statistical tests you want to apply to the data but those tests assume your data are normally distributed? How can you determine if the data are normally distributed. You can construct a histogram and see if it looks like a normal distribution. You could also make a normal probability plot and see if the data falls in a straight line. We have past newsletters on histograms and making a normal probability plot. There is an additional test you can apply. It is called the Anderson-Darling test and is the subject of this month's newsletter.

We have included an Excel workbook that you can download to perform the Anderson-Darling test for up to 200 data points. It includes a normal probability plot. We have also included a link to VBA function macro that you can use to calculate the Anderson-Darling statistic and associated p-value.

In this issue:

- The Anderson-Darling Test Hypotheses
- Two Data Sets
- The Anderson-Darling Test
- The p Value for the Adjusted Anderson-Darling Statistic
- Applying the Anderson-Darling Test
- Summary
- Quick Links

You can download the workbook containing the data at this link.

### The Anderson-Darling Test Hypotheses

The Anderson-Darling Test was developed in 1952 by Theodore Anderson and Donald Darling. It is a statistical test of whether or not a dataset comes from a certain probability distribution, e.g., the normal distribution. The test involves calculating the Anderson-Darling statistic. You can use the Anderson-Darling statistic to compare how well a data set fits different distributions.

The two hypotheses for the Anderson-Darling test for the normal distribution are given below:

H

_{0}: The data follows the normal distributionH

_{1}: The data do not follow the normal distribution

The null hypothesis is that the data are normally distributed; the alternative hypothesis is that the data are non-normal.

In many cases (but not all), you can determine a p value for the Anderson-Darling statistic and use that value to help you determine if the test is significant are not. Remember the p ("probability") value is the probability of getting a result that is more extreme if the null hypothesis is true. If the p value is low (e.g., <=0.05), you conclude that the data do not follow the normal distribution. Remember that you chose the significance level even though many people just use 0.05 the vast majority of the time. We will look at two different data sets and apply the Anderson-Darling test to both sets.

### Two Data Sets

The two data sets come from another website that has statistical data you can use for examples. Click here for the link. The first data comes from Mater Mother's Hospital in Brisbane, Australia. The data set contains the birth weight, gender, and time of birth of 44 babies born in the 24-hour period of 18 December 1997. The data were explained using four different distributions. We will focus on using the normal distribution, which was applied to the birth weights. The data are shown in the table below.

**Table of Birth Weights (Grams)**

3837 | 3480 |

3334 | 3116 |

3554 | 3428 |

3838 | 3783 |

3625 | 3345 |

2208 | 3034 |

1745 | 2184 |

2846 | 3300 |

3166 | 2383 |

3520 | 3428 |

3380 | 4162 |

3294 | 3630 |

2576 | 3406 |

3208 | 3402 |

3521 | 3500 |

3746 | 3736 |

3523 | 3370 |

2902 | 2121 |

2635 | 3150 |

3920 | 3866 |

3690 | 3542 |

3430 | 3278 |

The second set of data involves measuring the lengths of forearms in adult males. The 140 data values are in inches. The data is given in the table below.

**Table of Forearm Lengths**

17.3 | 20.9 | 18.7 | 17.9 | 18.3 |

19 | 18.1 | 18.8 | 19.1 | 17.9 |

18.2 | 19.4 | 19.4 | 17.3 | 18.3 |

19 | 20.5 | 18.5 | 19.4 | 19.6 |

19 | 20.4 | 18.6 | 18.3 | 19.6 |

20.4 | 16.1 | 19.6 | 19.3 | 21 |

18.3 | 18.7 | 18.5 | 17.2 | 18 |

19.9 | 18.8 | 20 | 17.5 | 17.9 |

18.7 | 17.3 | 17.8 | 19.6 | 18.1 |

20.9 | 18.1 | 19.8 | 17.6 | 19.5 |

17.7 | 19.9 | 16.6 | 20 | 17.1 |

19.1 | 19.6 | 19.4 | 19.9 | 18.9 |

19.7 | 18.4 | 19.3 | 16.9 | 18.5 |

18.1 | 19.5 | 20.1 | 19.5 | 19.2 |

18.4 | 16.8 | 20.5 | 20.4 | 20.5 |

17.5 | 17.1 | 20 | 19.1 | 18.3 |

18.9 | 18.9 | 20.8 | 18.5 | 19.4 |

19 | 19.7 | 17.7 | 18.3 | 21.4 |

20.5 | 19.7 | 19.9 | 19.8 | 19 |

17.3 | 19.2 | 18.8 | 19.1 | 18.6 |

18.3 | 20.6 | 16.4 | 17.5 | 19.5 |

18.4 | 20.1 | 18.5 | 18.5 | 17.4 |

18.6 | 18.8 | 19 | 19.3 | 18.5 |

19.8 | 17.1 | 20.6 | 19.1 | 18.4 |

20.2 | 18.6 | 19.2 | 17.4 | 18.3 |

18.5 | 18 | 17.1 | 16.3 | 20.7 |

18.5 | 18.7 | 16.3 | 18.2 | 19.3 |

18 | 20.3 | 17.2 | 18.8 | 17.7 |

### The Anderson-Darling Test

The Anderson-Darling Test will determine if a data set comes from a specified distribution, in our case, the normal distribution. The test makes use of the cumulative distribution function. The Anderson-Darling statistic is given by the following formula:

where n = sample size, F(X) = cumulative distribution function for the specified distribution and i = the i^{th} sample when the data is sorted in ascending order. You will often see this statistic called A^{2}.

To demonstrate the calculation using Microsoft Excel and to introduce the workbook, we will use the first five results from the baby weight data. Those five weights are 3837, 3334, 3554, 3838, and 3625 grams. You definitely want to have more data points than this to determine if your data are normally distributed. We will walk through the steps here. You can download the Excel workbook which will do this for you automatically here: download workbook. Of course, the Anderson-Darling test is included in the SPC for Excel software.

The data are placed in column E in the workbook. After entering the data, the workbook determines the average, standard deviation and number of data points present The workbook can handle up to 200 data points.

The next step is to number the data from 1 to n as shown below.

The formula in Cell F2 is "=IF(ISBLANK(E2),"",1)". The formula in cell F3 is "=IF(ISBLANK(E3),"",F2+1)". The formula in cell F3 is copied down the column.

To calculate the Anderson-Darling statistic, you need to sort the data in ascending order. This is done in column G using the Excel function SMALL(array, k). This function returns the k^{th} smallest number in the array. The sorted data are placed in column G.

The formula in cell G2 is "=IF(ISBLANK(E2), NA(),SMALL(E$2:E$201,F2))". This formula is copied down the column. The NA() is used so that Excel will not plot points with no data.

Now we are ready to calculate F(X_{i}). Remember, this is the cumulative distribution function. In Excel, you can determine this using either the NORMDIST or NORMSDIST functions. They both will give the same result. We will use the NORMDIST function. The workbook places these results in column H.

The formula in cell H2 is "=IF(ISBLANK(E2),"",NORMDIST(G2, $B$3, $B$4, TRUE))". This formula is copied down column H. The average is in cell B3; the standard deviation in cell B4. Using "TRUE" returns the cumulative distribution function.

Take a look again at the Anderson-Darling statistic equation:

We have F(X_{i}). The equation shows we need 1-F(_{Xn-i+1}). It takes two steps to get this in the workbook. First the value of 1- F(X_{i}) is calculated in column I and then the results are sorted in column J. The results are shown below.

The formula in cells I2 is "=IF(ISBLANK(E2), "", 1-H2)" and the formula in cell J2 is "=IF(ISBLANK(E2),"",SMALL(I$2:I$201,F2))." These are copied down those two columns.

We are now ready to calculate the summation portion of the equation. So, define the following for the summation term in the Anderson-Darling equation:

This result is placed in column K in the workbook.

The formula in cell K2 is "=IF(ISBLANK(E2),"",(2*F2-1)*(LN(H2)+LN(J2)))". This formula is copied down the column.

We are now ready to calculate the Anderson-Darling statistic. This is given by:

The value of AD needs to be adjusted for small sample sizes. The adjusted AD value is given by:

For these 5 data points, AD* = .357. The workbook has the following output in columns A and B:

The last entry is the p value. That depends on the value of AD*.

### The p Value for the Adjusted Anderson-Darling Statistic

The calculation of the p value is not straightforward. The reference most people use is R.B. D'Augostino and M.A. Stephens, Eds., 1986, Goodness-of-Fit Techniques, Marcel Dekker. There are different equations depending on the value of AD*. These are given by:

- If AD*=>0.6, then p = exp(1.2937 - 5.709(AD*)+ 0.0186(AD*)
^{2} - If 0.34 < AD* < .6, then p = exp(0.9177 - 4.279(AD*) - 1.38(AD*)
^{2} - If 0.2 < AD* < 0.34, then p = 1 - exp(-8.318 + 42.796(AD*)- 59.938(AD*)
^{2}) - If AD* <= 0.2, then p = 1 - exp(-13.436 + 101.14(AD*)- 223.73(AD*)
^{2})

The workbook (and the SPC for Excel software) uses these equations to determine the p value for the Anderson-Darling statistic.

### Applying the Anderson-Darling Test

Now let's apply the test to the two sets of data, starting with the baby weight. The question we are asking is - are the baby weight data normally distributed?" The results for that set of data are given below.

AD = 1.717

AD* = 1.748

p Value = 0.000179

The p value is less than 0.05. Since the p value is low, we reject the null hypotheses that the data are from a normal distribution. You can construct a normal probability plot of the data. How to do this is explained in our June 2009 newsletter. The normal probability plot is included in the workbook. If the data comes from a normal distribution, the points should fall in a fairly straight line. You can see that this is not the case for these data and confirms that the data does not come from a normal distribution.

Now consider the forearm length data. Again, we are asking the question - are the data normally distributed? The results for the elbow lengths

AD = 0.237

AD* = 0.238

p Value = 0.782045

Since the p value is large, we accept the null hypotheses that the data are from a normal distribution. The normal probability plot shown below confirms this.

The workbook contains all you need to do the Anderson-Darling test and to see the normal probability plot. If you prefer to use VBA code, this link gives you the VBA code for an Anderson-Darling function. You can copy this code into a workbook and use it to calculate AD, AD* and the p value for the data.

### Summary

The Anderson-Darling test is used to determine if a data set follows a specified distribution. In this newsletter, we applied this test to the normal distribution. The test involves calculating the Anderson-Darling statistic and then determining the p value for the statistic. It is often used with the normal probability plot.

### Quick Links

Thanks so much for reading our publication. We hope you find it informative and useful. Happy charting and may the data always support your position.

Sincerely,

Dr. Bill McNeese

BPI Consulting, LLC

## Comments (16)

Anonymousawesome article !

AnonymousVery Illustrative, Easy to adopt and enables any to tackle similar issues irrespective of age, education & position

AnonymousThanks for the info.

You will never know how much you helped!

AnonymousWell explained topic, thanks

AnonymousVery well explained in places, slightly ambiguous in others. Shame about the grammar used throughout the piece!

billAnd what is wrong with the grammar? Ready fine to me!

RamasubramanianHow Anderson-Darling test is different from Shapiro Wilk test for normality?

billI have seen varying data on which approach is better - have seen where Shapiro-Wilk has more power. But, I have not looked too much into the Shapiro-Wilk test.

LukeSHi. This is really usefull thank you. However is there any way to increase the amount of data that can be analysed in this workbook? I've got 750 samples. I did change the maximum values in the formulas to include a bigger data sample but wasn’t sure if the formulas would be compromised.e.g E$701 =IF(ISBLANK(E2), NA(),SMALL(E$2:

E$1000,F2))billYou can use the workbook with larger sample sizes. You just need to be sure that it is changed in all formulas, including Avg, stdev, n, S and the ones containing SMALL.

JamesHi, Thanks for the info. I'm reproducing the steps in Excel but I don't want to compare with a Normal distribution, I have my own set of data and I want to check it with my own distribution. In this case how do generate F(Xi) using 10,000 data points I have for the distribution?

billI am not sure I understand what you want to do. Maybe this:

In Column B, put the numbers from 1 to 10,000

In cell C1, enter = B1/10000

Copy that from C2 to C10000

Plot A vs C to generate the CDF

StefanIs it possible to explain the correction in the calculation of the Z-value (see column L of sheet 2 in the embedded excel-sheet). The P value is not calculated as i/n. But corrected and is now calculated as (i-0,3)/(n+0.4) Is it possible to give some substantiation of the used 0.3 and 0.4.

billThe method used is median rank method for uncensored data. This gives p = (i-0.3)/(n+.4). There are other methods that could be used. For example, you could use (i-0.5)/n; or i/(n+1) or simply i/n.

StefanThanks

JiniThis is really very informative article.I come to know about this useful test.thanks

## Leave a comment