# R vs. SPSS Kolmogorov-Smirnov test

I was recently given the following data.

7 1 6 6 2 8 3 7 4 6 3 3 1 8 4 5 9 3 2 4 1 4 4 3 6 3 4 2 3 2 7 2 7 4 2 4 4 4 3 2 2 4 5 8 6 4 3 1 5 5


I then ran a KS test as follows in R:

ks.test(mydata,"pnorm",mean(mydata),sd(mydata))


and got the following:

One-sample Kolmogorov-Smirnov test

data:  mydata
D = 0.1832, p-value = 0.06985
alternative hypothesis: two-sided


Trouble is when I do the same test in SPSS, as shown here: https://statistics.laerd.com/spss-tutorials/testing-for-normality-using-spss-statistics.php

I get a p-value of 0.000 but exactly the same test statistic. Does anyone have an idea why this is? I'm not an expert in SPSS at all (don't even have it installed) but the fact that the D-statistic matches makes me think I ran it correctly and am somehow misreading it.

RioRaider's hint was the right way to go. After manually applying Lilliefors Significance Correction as described here: http://home.ubalt.edu/ntsbarsh/stat-data/SPSSSAS.htm

Formula:

Exp[ -7.01256D2(n + 2.78019) + 2.99587D(n+2.78019)1/2 - 0.122119 + 0.97498/n1/2 + 1.67997/n ]


I get exactly the p-values as described. Is there a way I can flag his comment as a +1?

• Do you have confirmation from SPSS that it read the data exactly as intended and that it is identical to the data you fed into R? although not a confirmation i guess getting the same value is a clue that the data was probably read correctly and for the same value of the test statistic and the same sample size the p-values would have to be the same. Sep 14 '12 at 22:06
• The R manual page for the KS test explicitly mentions that using the mean and sd of the data for the parameters is invalid. You can verify this with a simulation.
– whuber
Sep 14 '12 at 22:11
• I noticed that the SPSS output linked by @user1357015 notes that Lilliefors Significance Correction is used. Maybe that is the difference? Sep 14 '12 at 22:23
• @whuber: I tried it with using rnorm and so forth, the effect is minor. Sep 14 '12 at 23:58
• @user1357015 Yes, it is the effect of Lilliefors correction aplied in Explore procedure. If you use K-S prodecure that is under Nonparametric tests menu, you'll get the same sig. as in R. Sep 15 '12 at 6:11