Sign up ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

As question, I have found something similar here, but how to do it in R?


share|improve this question
Is the example at helpful? – whuber May 18 '11 at 5:06
poisson.test gives identical answers to the page that you pointed to for count data. – deinst Dec 23 '11 at 13:44

3 Answers 3

up vote 9 down vote accepted

You are looking for a confidence interval around the count from a Poisson process. If you put for example 42 into your linked example you get

You observed 42 objects in a certain volume or 42 events in a certain time period.

Exact Poisson confidence interval:

  • The 90% confidence interval extends from 31.94 to 54.32
  • The 95% confidence interval extends from 30.27 to 56.77
  • The 99% confidence interval extends from 27.18 to 61.76

You can get this in R using poisson.test. For example

> poisson.test(42, conf.level = 0.9 )

        Exact Poisson test

data:  42 time base: 1 
number of events = 42, time base = 1, p-value < 2.2e-16
alternative hypothesis: true event rate is not equal to 1 
90 percent confidence interval:
 31.93813 54.32395 
sample estimates:
event rate 

and similarly the other values by changing conf.level. If you do not want all the background information, try something like

> poisson.test(42, conf.level = 0.95 )$
[1] 30.26991 56.77180
[1] 0.95
share|improve this answer

If the number of event is too small, it would be better to use the exact method.

exactPoiCI <- function (X, conf.level=0.95) {
  alpha = 1 - conf.level
  upper <- 0.5 * qchisq((1-(alpha/2)), (2*X))
  lower <- 0.5 * qchisq(alpha/2, (2*X +2))
  return(c(lower, upper))
exactPoiCI(42, 0.9)
exactPoiCI(42, 0.99)

Reference: Liddell FD. Simple exact analysis of the standardised mortality ratio. J Epidemiol Community Health. 1984;38:85-8 (link)

share|improve this answer
Welcome to the site. Do you mind expanding upon this. What exactly does "count data is too small" mean (sample size small or intensity of events is too small?) A reference would be appreciated as well. – Andy W Dec 23 '11 at 13:09

The first answer using poisson.test does give the exact confidence interval. However, this calculation is so simple that I prefer to calculate it directly instead of using a library function. In the second answer, there is a minor error. The +2 should be in the degree of freedom for the upper CI calculation, not for the lower one. So the correct code should be:

exactPoiCI <- function (X, conf.level=0.95) {
  alpha = 1 - conf.level
  upper <- 0.5 * qchisq(1-alpha/2, 2*X+2)
  lower <- 0.5 * qchisq(alpha/2, 2*X)
  return(c(lower, upper))

exactPoiCI(42, 0.9)
exactPoiCI(42, 0.99)
share|improve this answer
But this is already present in the other answer. Why did you put this here? – David Arenburg Nov 19 at 11:34
The other answer had an error, this is a correction. Note the +2 is in the upper CI calculation. – Jianmei Wang Nov 19 at 11:36
Welcome to the site and thank you for correcting the error. – Andy W Nov 19 at 11:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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