# Calculating the 1 Sample Kolmogorov Smirnov Test Statistic for Normality

Can anyone give me some insight into where this calculation for the KS test statistic is going wrong (see figure 1)? I ran the test in SPSS and SAS as a check. I have used the same process for other data and gotten the correct KS statistic (see figure 2).

I suspect that the presence of duplicate values in the figure 1 data is operative. If this is the case, does anyone know how SPSS and SAS adjusts the KS test stat for dups?

Any assistance is appreciated.

Figure 1

Figure 2

• I failed to mention that I suspect that the presence of duplicate values in the figure 1 data is operative. If this is the case, does anyone know how SPSS and SAS adjusts the KS test stat for dups?
– Dan
Aug 18 '18 at 23:18
• Please merge your accounts so you can edit your original post. Aug 18 '18 at 23:31
• (1) It's not about making an adjustment, but calculating the empirical distribution function correctly. What proportion of observations in the Figure 1 data are less than or equal to 76? (2) What does the presence of duplicates in itself tell you about the null hypothesis of normality? Aug 19 '18 at 8:04
• Not the question but this test is a poor test for normality: necessarily it's most sensitive to differences n the middle of the distribution, the opposite of what is usually helpful. Indeed all tests are poor tests of normality: using a normal quantile plot (normal probability plot, probit plot, yet other names) is typically a better idea. Oct 4 '21 at 11:24

I was originally using this formula for the column entitled "Abs Diff" in my spreadsheet above:

However, after further research I found this formula which indeed matches the KS test statistic values produced by SPSS and SAS in all cases.

Thanks to everyone who viewed this post.

It appears that the SPSS K-S Algorithm uses the sample mean and sample standard deviation in its determination of its F(x) value. I am looking at a simple example of a K-S test in Canavos (1984) - Applied probability and statistics, pp. 343-344, they show a sample of n = 16 observations where they calculate the KS test statistic.

They use a hypothetical population mean and sigma of mu = 985 and sigma = 50. The sample mean = 980.50 and a sample standard deviation of 61.29.

In the Canavos example, when they calculate their KS statistic using the m = 985 and sigma = 50 values, their hand calculated KS value is 0.1207. When I ran it in both SPSS and MINITAB, I got a value of 0.1750. So, I did an EXCEL hand calculation using the sample mean and sample standard deviation values of 980.50 and 61.29, respectively. Then I got the same value of 0.17488 ~ 0.175. So that is what is going on with software packages like SPSS and MINITAB.

v/r Kenneth Lewis Virginia State University Department of Psychology

• Oh, SPSS and MINITAB also use S(x) = (i - 1)/N instead of i/N for their S(x) values. I hope what I wrote makes sense. Oct 4 '21 at 4:16