For example, I have a estimate of p = 0 (95% CI: 0, 0.01), and I want to know the sample size for this sample.

For $p\not =0$, I can compute the s.e. by $\sqrt(p(1-p)/n)$ to get the $n$, but not sure how to compute $n$ in this case?

  • $\begingroup$ Does this post answer your question? stats.stackexchange.com/questions/82720/… $\endgroup$ May 14 at 12:56
  • $\begingroup$ yes I think answer the first part, I edit my question to be specific to the second part $\endgroup$ May 14 at 13:55
  • 3
    $\begingroup$ Do you know how the confidence interval was computed? If by the rule of three, as in the linked post, the upper limit is $\frac{1}{3n}$ and from there it s easy ... $\endgroup$ May 14 at 15:58

1 Answer 1


A Jeffreys 95% CI for the binomial proportion is based on the non-informative prior distribution $\mathsf{Beta}(.5,.5)$ and is said to give good frequentist results. Several other styles of Cis are in common use. You should pick one that does not rely directly on normal approximation.

For example, if $n = 50$ trials with $x = 10$ successes then a a 95% CI for success probability $p$ is, then the Agresti 95% CI $(0.919, 0.283)$ for $p$ is found as follows:

p.est = (12/64)
CI.agr = p.est + qnorm(c(.025,.975))*sqrt(p.est*(1-p.est)/64)
[1] 0.09187523 0.28312477

The test-inverted Clopper-Pearson interval $(0.083, 0.285$ is available in the R procedure binomon.test:

binom.test(10, 60)

        Exact binomial test

data:  10 and 60
number of successes = 10, number of trials = 60, p-value = 1.616e-07
alternative hypothesis: true probability of success is not equal to 0.5
95 percent confidence interval:
 0.08292881 0.28521925
sample estimates:
 probability of success 

And the Jeffreys' CI $(0.108, 0.326),$ based on a Bayesian argument with a non-informative prior, which is said to have good frequentist properties, is found as by taking quantile $.025$ and $.975$ of the distribution $\mathsf{Beta}(.5+x, .5 + n - x)$ as follows.

qbeta(c(.025,.975), .5+10, .5+40)
[1] 0.1077340 0.3258269

Among these, I prefer the latter because of its properties and ease of computation in R.

It provides one possible solution to your problem. For $n = 61, x = 0,$ it gives the CI $(0, 0.04),$ as follows:

round(qbeta(c(.025,.975), .5, 61.5), 5)
[1] 0.00001 0.04018

It is easy to find $n = 61$ as a suitable sample size by trial and error or by grid search with values of $n$ from $1$ through $100.$ (I was looking for an interval that gives $(0,0),$ when rounded to one decimal place.)

You might find @DavidLukeThiessen's suggested link useful; also, the Wikipedia page on confidence intervals for a binomial proportion.

With my answer from the Jeffreys interval, you may want to compare results for $n = 61$ from several other intervals.


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.