Worked example I
We base our first example on some data on sole horn moisture content from a study by Higuchi & Nagahata (2001) on cows with and without laminitis. We will assume for now that we wish to test this observed distribution against a reference normal distribution of mean 35.0 and standard deviation 2.0.
The observed cumulative relative frequencies (S(Y)) are obtained by dividing rank (r) by the number of observations (n). Expected cumulative relative frequencies (Fo(Y)) for these quantiles from a normal distribution are given by the area under the normal curve; they are readily obtained from R. Differences are obtained between observed and expected values (S(Y)i - F(Y)i), and between observed of the previous variate and expected values (S(Y)i-1 - F(Y)i). The largest absolute difference of these two sets of differences is d.
|Moisture content of sole horn
|Obs #||% moisture|
|S(Y)i - F(Y)i||S(Y)i-1 - F(Y)i
The process may be easier to follow on the first graph below. The red curve shows the expected cumulative relative frequencies from a normal distribution. Blue points show the observed cumulative relative frequencies. Red points show points on the cumulative normal curve equivalent to observed cumulative relative frequencies. Green points lie immediately before each step-up.
A more efficient approach is shown in the second figure above. A correction factor (0.5/n) is subtracted from each observed cumulative relative frequency. Only one difference then has to be calculated for each observed cumulative relative frequency. Once the largest absolute difference is identified, the correction factor is added back on again to give d.
We said at the start of this worked example that we were testing the observed distribution against a fully defined normal distribution (μ=35,σ=2). Usually, however, one is more interested in an omnibus test of normality - using the sample mean and standard deviation as estimates of the population parameters.
The Kolmogorov-Smirnov test should not be used to test such a hypothesis - but we will do it here in R in order to see why it is inappropriate. In this example the mean is 34.754 and the standard deviation is 1.92472.
The P-value we obtain is 0.7026 - which gives no indication of a significant deviation from normality. Let us now use three of specialized tests of normality which allow for the fact that one is estimating parameters from the sample.
- Lilliefors test of normality
The maximum difference (D) is estimated in exactly the same way as previously.
The test statistic is the same (D = 0.191), but the P-value is much lower at 0.2628.
- Cramér-von Mises's test of normality
This test uses a different test statistic from Kolmogorov-Smirnov and Lilliefors.
The test statistic (W) is 0.0591, with a P-value of 0.3606.
- Anderson-Darling test of normality
This test uses another different test statistic which gives more weight to the tails of the distribution. It is reputedly the most powerful of this family of tests.
The test statistic (A) is 0.3891, with a P-value of 0.3263.
Whilst the P-value from the Kolmogorov-Smirnov test (0.7026) is not valid for the reasons stated, any of the other three tests could justifiably be used depending on which aspect of the distribution one is most interested in. None of them indicates a significant deviation from normality - although with such a small sample the deviation would have to be very marked to be detected.
Postscript: When there are several (appropriate) tests to choose from, it is very important to select the test a priori, and not just choose the one that gives the desired result. If you want to give more weight to the tails of the distribution, then select the Anderson-Darling test. If you want to give more weight to the centre of the distribution, then select the Lilliefors test.