# Computing confidence intervals for count data

I have a representative sample token on area of 60 mq (squared meter) of a territory of 54077 mq. This sample contains the number of little plants that there are for each mq. The sample is defined in R as:

s=c(13,7,10,4,28,0,10,0,0,0,0,0,0,0,0,0,6,
0,0,0,0,0,0,0,4,0,0,0,4,0,0,0,1,2,2,0,
2,3,3,3,1,3,12,33,1,31,0,1,21,0,3,1,8,
0,1,1,6,0,2,0)


The sum of s is 227.

To compute the CI of s I used a t.test (also it is not a normal distribution: it is not that my problem).

t.test(s)
t = 3.9606, df = 59, p-value = 0.0002039
mean of s =  3.783333 - 95 % confidence interval:  1.871905 - 5.694762


My question is:

Can I assume that the CI of number of plant in the entire territory is between $1.871905\times 227\times (54077/60) - 5.694762\times 227\times (54077/60)$?

I think NO because the count is very simplified but I hope YES.

• I changed your title to reflect what I think you are interested in. I believe you mean the "sum of s is 227", not its length. Also, if this is homework, please consider tagging it as such. – chl Oct 29 '11 at 8:53
• What do you mean by "the count is very simplified"? – Peter Flom Oct 29 '11 at 12:55
• @chl I agree about "sum" so I changed that. I also think the title should be "CI of the sum of a count variable". – Peter Flom Oct 29 '11 at 12:56
• You have some "zero inflation" here (nearly half of your counts are 0). Also, if the data have been entered in the order in which they were observed, there is some systematic effect (a long stretch of 0s, and three of the four high observations all occurred close to each other). That said, you might try a bootstrap computation for the confidence interval for the mean. The relevant R packages are "boot" or "bootstrap". I think the t.test CI is definitely not right. – Hans Engler Oct 29 '11 at 16:02
• Highly discrete (e.g. small median count), highly skew, count data. No, your calculation is not appropriate. It also seems to have serial dependence. – Glen_b Sep 3 '14 at 6:28

As Hans Engler suggested, a bootstrap should work well for these data. You can use the boot or bootstrap packages directly, but it’s much easier to use the simpleboot package:

s = c(13,7,10,4,28,0,10,0,0,0,0,0,0,0,0,0,6,
0,0,0,0,0,0,0,4,0,0,0,4,0,0,0,1,2,2,0,
2,3,3,3,1,3,12,33,1,31,0,1,21,0,3,1,8,
0,1,1,6,0,2,0)

library(simpleboot)
b = one.boot(s, mean, R=10^4)
boot.ci(b, type="perc")


The output is:

BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 10000 bootstrap replicates

CALL :
boot.ci(boot.out = b, type = "perc")

Intervals :
Level     Percentile
95%   ( 2.10,  5.85 )
Calculations and Intervals on Original Scale


As you can see (and as one might have expected), the confidence interval is not very different from the confidence interval from the t-test (1.87–5.69).