0

I am trying to run a KS test on a vector to check if its follows a Poisson distribution

require("MASS")

Data <- rpois(100000, 20)
distFit<-fitdistr(Data,"Poisson")
ks.test(Data,"ppois",lambda=distFit$estimate)

unfortunately I get the following message once I run ks.test in the next step

Warning message: In ks.test(Data, "ppois", lambda = distFit$estimate) : ties should not be present for the Kolmogorov-Smirnov test

Any idea how to fix this?

ulrich
  • 3,547
  • 5
  • 35
  • 49
  • Not an answer, but note that you can only use the K-S-test to test for a *fully specified* distribution. If you use it to test whether your sample belongs to a distribution *with parameters estimated from the sample*, the critical values will be off. The K-S-test will be too conservative. – Stephan Kolassa Apr 29 '15 at 11:01
  • Thanks for the heads up Stephan The error comes from the duplicated values in the vector (ie ks.test(unique(Data),"ppois",lambda=distFit$estimate) would work) – ulrich Apr 29 '15 at 11:09

1 Answers1

2

you could apply the jitter function to your data to break ties ... have a look at ?jitterto find out if it fits your needs

GWD
  • 1,387
  • 10
  • 22