Take the 2-minute tour ×
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?

Thanks.

share|improve this question
2  
Is the example at stats.stackexchange.com/q/5206/919 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

2 Answers 2

up vote 5 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 
        42  

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 )$conf.int
[1] 30.26991 56.77180
attr(,"conf.level")
[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)

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

share|improve this answer
3  
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

Your Answer

 
discard

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.