# How to calculate 95% CI for cumulative incidence rate using R?

for example, 30 events during 10000 person-years, the cumulative incidence rate is 3 per 1000 person-years, how to calculate its 95% CI?

## migrated from stackoverflow.comMar 24 '17 at 15:35

This question came from our site for professional and enthusiast programmers.

Use a Poisson GLM to do maximum likelihood under the assumption of independent interarrival times:

n <- 30
d <- 10000
fit <- glm(n ~ offset(log(d)), family=poisson)

exp(confint(fit))


gives

> exp(confint(fit))
Waiting for profiling to be done...
2.5 %      97.5 %
0.002050488 0.004205138


The assumption would be violated when there are discrepant intervals between incidence and recurrence in the cohort, such as cases of herpes sores. Here infected persons have a shorter interval between outbreaks, than would be expected in a time-to-event analysis inspecting incidence in a cohort of persons uninfected with the disease.

This is more precise than normal approximations to the crude rate since it is not the natural parameterization for rates. This method is the same as @JamesKirkbride's answer below. The GLM is nice to familiarize yourself with because it extends to many other methods like aggregating ecological data and stratifying.

• Don't you need each individual measure in order to do a glm regression? – skan Mar 16 '18 at 23:14
• What's the difference with the method (qchisq(α/2, 2*x)/2d, qchisq(1-α/2, 2*(x+1))/2d) ? statsdirect.com/help/rates/poisson_rate_ci.htm – skan Mar 16 '18 at 23:19

This sounds like an incidence rate not cumulative incidence, which is a risk (number of cases divided by original disease-free population). Presumably the 95% CI for cumulative incidence is the same as that for any proportion. If you are after the 95% confidence interval for a rate it is given by:

ln(95%CI) = ln(rate)+/-1.96SE [1]

where SE is defined by

1/sqrt(d) [2]

where d is the numerator size.

Exponentiate [1] to give you the lower and upper bounds.