I'm doing a hypothesis test to determine if the data follows binomial distribution with p=0.31, and I'm getting a warning when running this:

chisq.test(x = c(36,48,38,23,10,3),p = dbinom(0:5,5,0.31))

    Chi-squared test for given probabilities

data:  c(36, 48, 38, 23, 10, 3)
X-squared = 28.265, df = 5, p-value = 3.23e-05

And the warning message I'm getting:

Warning message:
In chisq.test(x = c(36, 48, 38, 23, 10, 3), p = dbinom(0:5, 5, 0.31)) :
  Chi-squared approximation may be incorrect

1 Answer 1


I believe what you were trying to do was to check if given the size of 100 observation from a binomial distribution with the probability of 0.31, you would get the same result. In this case R's chisq.test() is not a good choice, first because you have stated the probability wrong. You're giving the probabilities of each observation one-by-one, element-wise and that's not what you have meant. Here's an example:

x <- c(36,48,38,23,10,3)

binom(0:5, 5, 0.31)
[1] 0.156403135 0.351340375 0.315697149 0.141834951 0.031861475 0.002862915

36 is not equal to 0.15 anyway, the same goes with the the other elements. You could have divided x by 100 but still you're not applying the right statistical test here.

One option is to use Kolmogorov–Smirnov test which is used to test whether or not a sample comes from a certain distribution. To perform a one-sample or two-sample Kolmogorov-Smirnov test in R we can use the ks.test() function. Here we assume that:

$H_0:$ the two dataset values are from the same distribution - Binomial in this case

ks.test(c(36,48,38,23,10,3), pbinom(5, 100, 0.31))
    Two-sample Kolmogorov-Smirnov test

data:  c(36, 48, 38, 23, 10, 3) and pbinom(5, 100, 0.31)
D = 1, p-value = 0.2857
alternative hypothesis: two-sided

Voila! Turns our your observations may come from a Binomial distribution with p=0.31. Still be aware that with these few observations, the test result couldn't be much reliable after all.

  • $\begingroup$ Thank you very very much for taking the time to answer this! Sincerely appreciate it $\endgroup$ Commented Oct 10, 2022 at 22:15
  • $\begingroup$ @AlePouroullis You're very welcome. I hope this answered what you were exactly looking for. If it did, please mark the question as answered. $\endgroup$
    – Miss.Alpha
    Commented Oct 10, 2022 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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