10
$\begingroup$

I am going to use the Kolmogorov-Smirnov test to test normality of MYDATA in R. This is an example of what I do

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

Here is the result R gives me:

 data:  MYDATA
 D = 0.13527, p-value = 0.1721
 alternative hypothesis: two-sided

 Warning message:
 In ks.test(MYDATA, "pnorm", mean(MYDATA), sd(MYDATA)) :
    ties should not be present for the Kolmogorov-Smirnov test

I think there is a problem, what does "ties" mean in this warning?

$\endgroup$
  • 2
    $\begingroup$ Why do you wish to perform this normality test? In most cases, testing normality of a variable is pretty useless, although testing normality of residuals following a regression can be important. $\endgroup$ – EdM Aug 27 '16 at 21:48
  • 2
    $\begingroup$ Even without ties, the KS test is not a test for general normality but of a fully specified distribution (you're estimating the mean and sd from data). Your p-values will be nonsense. Search our site for references to Lilliefors test $\endgroup$ – Glen_b -Reinstate Monica Nov 27 '16 at 2:54
10
$\begingroup$

You have two problems here:

The K-S test is for a continuous distribution and so MYDATA should not contain any ties (repeated values).

The theory underlying the K-S test does not let you estimate the parameters of the distribution from the data as you have done. The help for ks.test explains this.

$\endgroup$
  • $\begingroup$ why does the ks.test in a two-sample case want the ties to be removed from both x and y? I mean, I have no ties in x and y (unique(x) and unique(y)), but the two vectors have a value in common. Shouldn't the ties be considered only among the values in x and in y? $\endgroup$ – Nemesi Jan 25 at 16:15
  • $\begingroup$ @Nemesi if you have a new question please ask it as such using the Ask Question button. $\endgroup$ – mdewey Jan 25 at 16:24
  • $\begingroup$ I though this was not enough to be a different question, but here it is: stats.stackexchange.com/questions/389151/… $\endgroup$ – Nemesi Jan 25 at 16:50
3
$\begingroup$

As explained by @mdewey, The K-S test is not suitable when estimating the parameters from the data. You can use the following code, which relies on the Anderson-Darling test for normality, and does not require you to supply the mean and the stddev. This test is stronger in accuracy than the Lilliefors test.

install.packages("nortest")
library(nortest)
ad.test(MYDATA)
$\endgroup$
  • $\begingroup$ "Accuracy" may be for a narrow but misguided search. In both cases, most applications of either of these tests is at worst useless and in most cases misleading. People are often taught to use them by persons with faulty understanding of the assumptions about regression methods. I susppose the relative weakness of the KS-test would make it actually "better" to use that the more powerful alternatives since its results would be less likely to be misleading to the naive user. $\endgroup$ – DWin Jun 16 '17 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.