Message Boards Message Boards

1
|
2088 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Kolmogorov-Smirnov goodness-of-fit test - computation of p-value

Posted 7 months ago

Dear all, does anybody know how Mathematica computes the p-value in the command KolmogorovSmirnovTest[data]. It is clear to me how the test statistic dn is computed but I tried to compute the p-value with the help of the so-called Kolmogorov distribution and also by using some modifications found in literature but I failed. What is also strange is the fact that the p-value given by Mathematica is far away from that computed with the Kolmogorov distribution also for large n.

Best,
Klaus

3 Replies
Posted 7 months ago

When using the command with symbolic parameters for a normal distribution

KolmogorovSmirnovTest[data, NormalDistribution[\[Mu], \[Sigma]], "TestData"]

you are testing whether the data comes from a normal distribution. That is the Lilliefors Test and it has a different P-value calculation. See https://en.wikipedia.org/wiki/Lilliefors_test.

When you want to test against a specific distribution with specified parameters such as

KolmogorovSmirnovTest[data, NormalDistribution[0, 1], "TestData"]

then the formula for the P-value works.

POSTED BY: Jim Baldwin

Dear Jim,

thanks a lot for the answer!

Concerning the Kolmogorov-Smirnov-Test against s specific distribution with specified parameters: In the literature, I found that instead of the Kolmogorov distribution FK(x) it is better to use the modification FK(x+1/(6*sqrt(n))+(x-1)/(4n)). With this modification I get approximately the same p-value as Mathematica but not exactly the same (see the attached notebook). Do you know, what Mathematica uses as CDF for computing the p-value?

Attachments:
Posted 7 months ago

I wasn't aware that RandomReal could work with a distribution but apparently it does. It would be more standard to use RandomVariate. In any event, preceding the generation of the random numbers with a call to SeedRandom (such as SeedRandom[12345]) will pretty much guarantee that everyone will get the same random numbers as you did.

POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract