# KS test - R, Minitab (and Systat)

I'm trying to figure out how Kolmogorov-Smirnov one-sample testing for normality is done in Minitab (or Systat, since the answers apparently match).

If this is my data vector:

abc <- c(0.0313, 0.0273, 0.0379, 0.0427, 0.0286, 0.0327, 0.0298, 0.0381, 0.0559, 0.0573,
0.0558, 0.113, 0.0464, 0.0442, 0.0579, 0.0495)


The boneheaded way of doing this in R would be:

ks.test(abc, pnorm, mean(abc), sd(abc))


Yes, I know that the ks.test help page says to not use the data to estimate the mean/sd of the comparison distribution. Hence, boneheaded. Sidenote - if I understand correctly, SAS is using this as a regular procedure? http://support.sas.com/documentation/cdl/en/procstat/63104/HTML/default/viewer.htm#procstat_univariate_sect037.htm

Anyway, the p-value R gives for this improper test is 0.3027, while apparently both Minitab and Systat provide a p-value of 0.029.

The project manager won't hear anything about using other means of testing for normality (or, heavens forbid, use plots of data distribution). At this point I'm just trying to figure out what it is that the other softwares are doing, so that I can explain to myself the differences...

Am I missing something?? If people suggest using simulations instead of the direct test, like here (http://r.789695.n4.nabble.com/Kolmogorov-Smirnov-Test-td3037232.html), would it be possible to include detailed code?

Thank you!

• It looks more like a management issue than a statistical question ;) I spotted an 'outlier' in your sample (0.113), is it possible that Minitab would do something about it without really saying anything? – Vincent Guillemot Jul 21 '14 at 17:30
• Ha, no kidding. Do they have forums for those too? :-) Just retested with that value gone, and nope, ain't that. It's not the only one either - this example is one of ~ 10 that were run in both programs... – user2602640 Jul 21 '14 at 17:34
• OK, what is the value of the D statistic computed with Minitab? – Vincent Guillemot Jul 21 '14 at 17:40
• Another question: do R and Minitab give similar outputs after a Shapiro test? – Vincent Guillemot Jul 21 '14 at 17:49
• The value of the KS statistic is the same with R (if abc_s <- scale(abc), then you can compute it yourself max(abs(ecdf(abc_s)(abc_s) - drop(pnorm(abc_s)))) ; it is not very useful to do that, since ks.test already returns D, but it's fun!). And indeed, when the mean and standard deviation are unknown, the corresponding variation of the Kolmogorov-Smirnov test (in the one sample case, when the reference is the Gaussian distribution) is the Lilliefors test... – Vincent Guillemot Jul 22 '14 at 11:24

out <- replicate(100000, {x <- rnorm( length(abc), mean(abc), sd(abc) );
ks.test(x, pnorm, mean(x), sd(x))$p.value } ) hist(out) mean(out <= ks.test(abc, pnorm, mean(abc), sd(abc))$p.value)

• Exactly the p-value lillie.test gives. Yeah, I was wondering about the adjustments... – user2602640 Jul 24 '14 at 11:17