Kolmogorov-Smirnov Test
Study guide: Exam MAS-I
A Kolmogorov-Smirnov Test is a hypothesis test of whether individual observations come from a hypothesized continuous distribution with cdf F^*(x). Its test statistic, the largest vertical distance between F^* and the empirical distribution function F_n of the sample, is
D = \max_{x} \left| F_n(x) - F^*(x) \right|
F_n(x)is the proportion of thenobservations that are at mostx.
The empirical distribution function is a step function that jumps by 1/n at each observation, so the largest distance is found by comparing F^* with the step just before and just at each observation. Computed this way, the test statistic is
D = \max_{1 \le i \le n} \left\{ F^*(x_{(i)}) - \frac{i - 1}{n},\ \ \frac{i}{n} - F^*(x_{(i)}) \right\}
x_{(1)} \le \cdots \le x_{(n)}are the order statistics of the sample.
The test rejects H_0 when D exceeds the critical value. For a fully specified F^*, the large-sample critical values are 1.22/\sqrt{n}, 1.36/\sqrt{n}, 1.48/\sqrt{n} and 1.63/\sqrt{n} at significance levels 0.10, 0.05, 0.025 and 0.01, the same for every continuous F^*.
Eight claims are observed: 45, 110, 180, 260, 390, 520, 800 and 1,350. Does a Kolmogorov-Smirnov test at significance level 0.05 reject an exponential distribution with mean 400? The hypothesized cdf is
F^*(x) = 1 - e^{-x/400}, compared with the empirical step just before and at each claim:
x_{(i)}F^*(x_{(i)})\frac{i-1}{8}\frac{i}{8}Larger distance 45 0.1064 0.000 0.125 0.1064 110 0.2404 0.125 0.250 0.1154 180 0.3624 0.250 0.375 0.1124 260 0.4780 0.375 0.500 0.1030 390 0.6228 0.500 0.625 0.1228 520 0.7275 0.625 0.750 0.1025 800 0.8647 0.750 0.875 0.1147 1,350 0.9658 0.875 1.000 0.0908
- The largest distance is
D = 0.1228, atx = 390.- The critical value at 0.05 is
1.36/\sqrt{8} = 0.481.- Because
0.1228 < 0.481, the test does not reject the exponential distribution with mean 400.
Estimated parameters
The tabled critical values assume that F^* is fully specified without reference to the data. When its parameters are estimated from the same sample, F^* is fitted closer to F_n, so D tends to be smaller, the tabled critical values are too large and the test rejects less often than its stated significance level. Unlike the chi-square goodness-of-fit test, whose degrees of freedom are reduced by one for each estimated parameter, the Kolmogorov-Smirnov test has no simple adjustment, and its critical values must then be found by simulation.
Anderson-Darling test
The Anderson-Darling test weights the squared distance between F_n and F^* more heavily in the tails of the distribution. With u_i = F^*(x_{(i)}), its test statistic is
A^2 = -n - \frac{1}{n} \sum_{i=1}^{n} (2i - 1)\left[\ln u_i + \ln(1 - u_{n+1-i})\right]
Unlike those of D, the critical values of A^2 depend on the hypothesized distribution.
Four losses, 20, 70, 130 and 260, are tested against an exponential distribution with mean 100. What is the Anderson-Darling statistic?
- The values
u_i = 1 - e^{-x_{(i)}/100}are 0.1813, 0.5034, 0.7275 and 0.9257.- For an exponential distribution,
\ln(1 - u_{5-i}) = -x_{(5-i)}/100, which gives-2.6,-1.3,-0.7and-0.2.- The terms
(2i - 1)\left[\ln u_i + \ln(1 - u_{5-i})\right]are-4.3078,-5.9590,-5.0909and-1.9402, which sum to-17.2979.- The statistic is
A^2 = -4 + \frac{17.2979}{4} = 0.3245.