5  Longitudinal Data, Rates, and Counts

The mortality and force of mortality will readily be distinguished, by comparing cholera with consumption; the mortality of the latter is 90–100 per cent, but its mean duration is two years, and the force of mortality is consequently nearly 0.50; the mortality in cholera is not 50 per cent, while the force of mortality is 2415, for cholera destroys in a week as many as phthisis consumes in a year. Phthisis is more dangerous than cholera; but cholera, probably, excites the greatest terror. (Farr 1838)1

The meaning of a risk or cumulative incidence depends on the time interval over which it is observed. William Farr observed that a risk of death slightly less than 50% over one week for cholera patients was widely considered more alarming than a risk of death greater than 90% over two years for tuberculosis patients. In public health, it matters a great deal how quickly things happen. How rapidly an event occurs is measured using a rate, which has units of events per unit time (Elandt-Johnson 1975; Morgenstern, Kleinbaum, and Kupper 1980). To estimate a risk or a rate, we use longitudinal data where individuals are followed over time. The analysis of longitudinal data is complicated by the fact that individuals can come and go during the study period.

To estimate the risk of disease onset in a time interval \((t_a, t_b]\), we would follow individuals from time \(t_a\) to time \(t_b\) to ascertain disease onset. From Section 1.5.2, the risk of disease onset in the time interval \((t_a, t_b]\) is \[ \Pr\bigl(\{\omega \in \Omega: D(\omega) = 1\}\bigr) \] where \[ D(\omega) = \begin{cases} 1 & \text{if } \omega \text{ has } \tonset \in (t_a, t_b], \\ 0 & \text{otherwise}. \end{cases} \] and \(\tonset\) denotes the onset time of the disease. In practice, the population \(\Omega\) is often defined to consist only of individuals who are at risk of disease at time \(t_a\). If we have complete follow-up of the entire population \(\Omega\) over the entire interval \((t_a, t_b]\), then we know the cumulative incidence exactly.

More often, we follow a sample of individuals from the population. If selection into the sample is independent of disease onset during \((t_a, t_b]\) and we have complete follow-up over the entire interval, then we can get point and interval estimates of the true cumulative incidence using methods for a binomial proportion from Chapter 3 or Chapter 4. In practice, almost all longitudinal studies have individuals entering or leaving the study during the follow-up period. When this occurs, methods for binomial proportions can produce inefficient or biased estimates of risk.

The analysis of incomplete longitudinal data is called survival analysis, and it is the theoretical foundation for many epidemiologic methods. To analyze survival data, it is important to have clear definitions of the following that can be applied equally to all study participants:

In complex data, an individual can have multiple entry, exit, and failure times and even multiple time origins (e.g., time to heart attack after vigorous exercise or ingestion of cocaine). The time scale is usually defined so that \(t = 0\) at the origin time, and we will assume that the origin and population are defined so that all individuals in the population are at risk of the event at \(t = 0\).

Table 5.1: Time scales and time origins adapted from Clayton and Hills (1993).
Time scale Origin
Calendar time Fixed date
Time since exposure Exposure time
Time under treatment Start of treatment
Time since diagnosis Time of diagnosis
Age e.g., 65th birthday
Time in hospital Hospital admission

5.1 Incomplete follow-up

Let \(\tevent\) be the failure time of individual \(i\) and \(\tcens\) be the last time at which they would be under observation if they had no disease onset. We assume all times are defined so that \(t = 0\) at the time origin.

5.1.1 Right censoring

When \(\tcens_i < \tevent_i\), the outcome in person \(i\) is right censored at time \(\tcens_i\). We know that individual \(i\) does not have an event at or before \(\tcens_i\), but we do not know when or if the event will occur after that. In right-censored data, we see the exit time \[ t_i = \min\bigl(\tevent_i, \tcens_i\bigr) \] and the event indicator \[ \delta_i = \begin{cases} 0 & \text{if } \texit_i = \tcens_i,\\ 1 & \text{if } \texit_i = \tevent_i. \end{cases} \] Right censoring is often just called censoring. There are many reasons that person \(i\) might be censored: Perhaps we can no longer find person \(i\) (loss to follow-up), person \(i\) is no longer at risk of failure (e.g., a woman who has a hysterectomy is no longer at risk of uterine cancer), or observation ends. Different individuals in the same study can be censored for different reasons.

Independent right censoring occurs if those who remain under observation at any given time are a random sample of all of those who would be under observation if there were no right censoring. Censoring is not independent if those who remain under observation have systematically different failure times than those who are censored. There are three canonical types of independent censoring:

  • Type I censoring occurs when observation of each individual ends at a predetermined time under the control of the investigators.
  • Type II censoring occurs when observation ends after a predetermined number of events have been observed.
  • Random censoring occurs when each person \(i\) has a random censoring time \(\tcens_i\) that is independent of his or her failure time \(\tevent_i\) and not under the control of the investigators.

As long as all censoring is independent, different censoring mechanisms can occur within the same study. All of the methods we will discuss assume independent censoring, and they become biased under dependent or informative censoring.

5.1.2 Delayed entry (left truncation)

Whereas right censoring concerns the observation of failure times, truncation concerns the selection of study participants. Delayed entry or left truncation occurs when an individual \(i\) has an entry time \(\tentry_i > 0\) where \(t = 0\) denotes the origin. If person \(i\) had disease onset before \(\tentry_i\), he or she would have been excluded from the study. Person-time prior to entry cannot be included as time at risk; it is called immortal person-time. Delayed entry can be handled easily by all of the methods we will discuss. As with independent right censoring, we require that the set of individuals under observation are a random sample of the individuals who would be under observation if we had no right censoring or left truncation. You can think of this as independent left truncation

5.1.3 Left censoring and right truncation

Given that we have right censoring and left truncation (delayed entry), it is natural to wonder whether there is also left censoring and right truncation. Unfortunately, the answer is yes:

  • Left censoring means that we know an individual had an event before a left-censoring time but we do not know when.
  • Right truncation means that our sample contains only individuals who have already had the event.

Both of these must be handled using strong assumptions or specialized methods. Some areas of epidemiology must contend with left censoring (e.g., we know that a birth defect occurred prior to birth but not exactly when) or right truncation. Usually, they can be prevented or minimized by good study design.

5.2 Failure time distributions

Failure time distributions are descibed in terms of survival functions, cumulative hazard functions, and hazard functions. Any one of these is sufficient to specify the distribution of the time to an event, but each has a different and useful interpretation. We denote the failure time as a positive random variable \(T\). For simplicity, we will assume that \(T\) is continuous.

5.2.1 Survival function

The survival function for a failure time \(T\) is \[ S(t) = \Pr(T > t), \] which is the probability that the event does not occur up to and including time \(t\). Several properties follow from this definition:

  • Because it is a probability, \(S(t) \in [0, 1]\) for all \(t\).

  • Because \(T > 0\), \(S(0) = 1\).

  • \(S(t)\) is monotonically decreasing, which means that it cannot increase. If \(u > t\), you can survive to time \(u\) only if you survive to time \(t\), so \(S(t) \geq S(u)\).

The survival function \(S(t)\) tells us everything there is to know about the distribution of the time-to-event \(T\). The cumulative incidence function is \[ F(t) = 1 - S(t) = \Pr(T \leq t), \] which is also the cumulative distribution function (CDF) for \(T\). If \(T\) is a continuous random variable, then \[ -S'(t) = F'(t) = f(t), \tag{5.1}\] where \(f(t)\) is the probability density function (PDF) of \(T\). If \(T\) is a discrete or continuous failure time with survival function \(S(t)\), it turns out that \[ \E[T] = \int_0^\infty S(t) \,\dif t. \tag{5.2}\] This is often easier to calculate than the integral \(\E[T] = \int_0^t t f(t) \dif t\) that is normally used to define the mean of a positive random variable.3 The \(p\)th quantile of the failure time distribution is the solution to the equation \[ p = F(t_p) = 1 - S(t_p), \tag{5.3}\] so higher quantiles correspond to longer times to events.4 When \(p = 0.5\), we get the median time-to-event. Much of survival analysis is dedicated to calculating and comparing survival functions.

5.2.2 Hazard function

For any \(\Delta > 0\), the probability that you have an event in the time interval \((t, t + \Delta]\) is \[ \Pr\bigl(\text{event in } (t, t + \Delta]\bigr) = S(t) - S(t + \Delta) \] and the conditional probability that you have an event in the interval given that you survived until time \(t\) is \[ \Pr\bigl(\text{event in } (t, t + \Delta] \,\big|\, \text{survival until } t\bigr) = \frac{S(t) - S(t + \Delta)}{S(t)}. \tag{5.4}\] The numerator is the expected number of events in \((t, t + \Delta]\) given that you remain at risk at time \(t\). Dividing by \(\Delta\) gives us \[ \frac{S(t) - S(t + \Delta)}{S(t) \Delta}, \] which is the expected number of events per unit time in the interval \((t, t + \Delta]\). The hazard function is the limit of this expected number of events per unit time as \(\Delta \downarrow 0\) (i.e., as \(\Delta\) decreases to zero): \[ h(t) = \lim_{\Delta \downarrow 0} \frac{S(t) - S(t + \Delta)}{S(t) \Delta}. \tag{5.5}\] Because the numerator is nonnegative and the denominator is positive, \(h(t) \geq 0\). The hazard function \(h(t)\) measures the instantaneous expected number of events per unit time like a speedometer measures the instantaneous speed of a vehicle. When \(h(t)\) is high, you are likely to have an event soon after time \(t\) if you have survived event-free until \(t\). When \(h(t)\) is low, you are relatively unlikely to have an event soon after \(t\).

Unlike the survival function, the hazard function has units. Because we divide an expected number of events by a time interval \(\Delta\), the hazard has units of \(\text{events} / \text{time}\). Just like the same speed can be expressed in miles per hour or kilometers per hour, using different measures of time (e.g., month, week, day, hour, minute, or second) changes the numerical value of the hazard but not its meaning.

When \(\Delta\) is small, then Equation 5.4 and Equation 5.5 give us \[ h(t) \approx \frac{\Pr\bigl(\text{event in } (t, t + \Delta] \,\big|\, \text{survival until } t\bigr)}{\Delta}. \] Rearranging, we get \[ h(t) \Delta \approx \Pr\bigl(\text{event in } (t, t + \Delta] \,\big|\, \text{survival until } t\bigr). \] Notice how the units work: \[ h(t) \frac{\text{events}}{\text{time unit}} \Delta \text{ time units} = h(t) \Delta \text{ events}. \tag{5.6}\] Multiplying the hazard by a time interval gives the expected number of events that would occur in that interval if the hazard remained constant.

When times to failure are continuous, the survival function is differentiable. By definition of the derivative of \(S(t)\), \[ \lim_{\Delta \downarrow 0} \frac{S(t) - S(t + \Delta)}{\Delta} = -S'(t). \] Putting this back into Equation 5.5, we get \[ h(t) = \frac{1}{S(t)} \lim_{\Delta \downarrow 0} \frac{S(t) - S(t + \Delta)}{\Delta} = \frac{-S'(t)}{S(t)}. \tag{5.7}\] Because \(-S'(t) = f(t)\) from Equation 5.1, we can multiply both sides by \(S(t)\) to get \[ f(t) = h(t) S(t). \tag{5.8}\] Thus, the PDF is the product of the hazard and survival functions. This is used to write likelihoods for right-censored and left-truncated data.

5.2.3 Cumulative hazard function

The cumulative hazard function for a positive random variable \(T\) is \[ H(t) = -\ln S(t). \tag{5.9}\] Several properties follow from this definition:

  • \(H(0) = 0\) because \(S(0) = 1\).

  • \(H(t)\) is monotonically increasing, which means that it cannot decrease. If \(u > t\), then \(H(u) \geq H(t)\).

  • When \(S(t) > 0\), \(H(t) \in [0, \infty)\).

  • \(S(t) = e^{-H(t)}\).

Taking the derivative with respect to \(t\) on both sides of Equation 5.9 (using the chain rule on the right-hand side), we get \[ H'(t) = \frac{-S'(t)}{S(t)} = h(t) \] where the final equality follows from Equation 5.7. By the fundamental theorem of calculus and the fact that \(H(0) = 0\), \[ H(t) = \int_0^t h(u) \dif u \tag{5.10}\] so the cumulative hazard \(H(t)\) is the area under the graph of \(h\) over \((0, t)\).

Equation 5.10 gives us an interesting way to interpret the cumulative hazard function. If the event is something that can be repeated (e.g., clicks on a Geiger counter), the expected number of events in \((0, t]\) is the sum of the expected numbers of events in a series of intervals \((u_0, u_1], (u_1, u_2], \ldots, (u_{n - 1}, u_n]\) where \(u_0 = 0\) and \(u_n = t\). Taking a limit as the number of subintervals grows larger and each subinterval becomes smaller, \[ \E\bigl[\text{number of events in} (0, t]\bigr] = \int_0^t h(u) \,\dif u = H(t). \] The units in the integral work in the same way as in Equation 5.6. For an event that cannot be repeated (e.g., death), \(H(t)\) can be interpreted as the expected number of events that would occur if the event were made repeatable. After an event at time \(t\), you would be brought back to being at risk at time \(t\) to wait for the next event to occur.

5.2.4 Likelihoods for right-censored and left-truncated data

Suppose our survival time distribution has hazard function \(h(t, \theta_\true)\) and survival function \(S(t, \theta_\true)\), where \(\theta_\true\) is an unknown parameter (or parameter vector). If individual \(i\) has entry time \(\tentry_i\), exit time \(t_i\), and event indicator \(\delta_i\), then their likelihood contribution is \[ L_i(\theta) = \frac{h(t_i, \theta)^{\delta_i} S(t_i, \theta)}{S\bigl(\tentry_i, \theta\bigr)}. \tag{5.11}\] In the numerator, every observation contributes a survival term, but only the observed failure times (\(\delta_i = 1\)) contribute a hazard term. The survival term in the denominator accounts for the fact that they survived until time \(\tentry_i\). When \(\tentry_i = 0\), then the denominator equals one. Table 5.2 shows the likelihood contributions for all four possible combinations of right censoring and delayed entry (left truncation).

Table 5.2: Possible likelihood contributions for \((\tentry_i, t_i, \delta_i)\).
Right censoring (\(\delta_i = 0\)) No right censoring (\(\delta_i = 1\))
Delayed entry (\(\tentry > 0\)) \(\frac{S(t_i, \theta)}{S(\tentry_i, \theta)}\) \(\frac{h(t_i, \theta) S(t_i, \theta)}{S(\tentry_i, \theta)}\)
No delayed entry (\(\tentry = 0\)) \(S(t_i, \theta)\) \(h(t_i, \theta) S(t_i, \theta)\)

Taking logarithms on both sides of Equation 5.11 gives us the log likelihood contribution \[ \ell_i(\theta) = \delta_i \ln h(t_i, \theta) - [H(t_i, \theta) - H(\tentry_i, \theta)]. \] All observations contribute a cumulative hazard term, but only observed event times contribute a hazard term. When \(\tentry_i = 0\), then \(H(0, \theta) = 0\) for all \(\theta\). When we have \(n\) independent observations, the log likelihood is the sum of the individual log likelihood contributions: \[ \ell(\theta) = \sum_{i = 1}^n \ell_i(\theta). \] The maximum likelihood estimate \(\hat{\theta}\) can be found using the score function \(U(\theta) = \ell'(\theta)\), and its approximate variance is \(I(\hat{\theta})^{-1} = [-\ell''(\hat{\theta})]^{-1}\). The log likelihood can be used to do Wald, score, and likelihood ratio hypothesis tests and obtain the corresponding confidence intervals. For example, the Wald 95% confidence interval in large samples is \[ \hat{\theta} \pm 1.96 \sqrt{I(\hat{\theta})^{-1}}. \] If necessary, the delta method can be used to get confidence intervals that keep \(\hat{\theta}\) within an appropriate range of values. Bayesian estimation can be done using the corresponding likelihood \(L(\theta) = \exp\bigl(\ell(\theta)\bigr)\)

5.3 Exponential distribution

The exponential distribution is the simplest and most important failure time distribution. It has a constant hazard function \[ h(t) = \lambda \] where \(\lambda\) is called the rate parameter and has units of \(\text{events} / \text{time}\). Its cumulative hazard function is \[ H(t) = \int_0^t h(u) \,\dif u = \int_0^t \lambda \dif u = \lambda t, \] its the survival function is \[ S(t) = e^{-H(t)} = e^{-\lambda t}. \] A higher rate parameter \(\lambda\) implies shorter survival times. The scale parameter is \(\sigma = \lambda^{-1}\). A smaller scale parameter corresponds to shorter survival times.

5.3.1 Mean and variance

The mean of an exponential random variable \(T\) is found most easily by integrating the survival function: \[ \E(T) = \int_0^\infty e^{-\lambda t} \,\dif t = \frac{1}{\lambda} \int_0^\infty \lambda e^{-\lambda t} \,\dif t = \frac{1}{\lambda}, \tag{5.12}\] In that integral, we ``creatively multiplied by one’’ to turn the integrand into a exponential PDF and then used the fact that the total area under the PDF is one. Integration by parts can be used to show that \[ \E(T^2) = \int_0^\infty t^2 \lambda e^{-\lambda t} \,\dif t = \frac{2}{\lambda^2}, \] so \[ \Var(T) = \E(T^2) - \E(T)^2 = \frac{2}{\lambda^2} - \frac{1}{\lambda^2} = \frac{1}{\lambda^2}. \] by Equation 1.10. Thus, the standard deviation \(\sqrt{\Var(T)} = 1 / \lambda\) is equal to the mean.

5.3.2 Incidence rates

Now imagine that we want to estimate an unknown rate parameter \(\lambda_\true\) for an exponential distribution. Let \((\tentry_1, t_1, \delta_1), \ldots (\tentry_n, t_n, \delta_n)\) denote a set of entry times, exit times, and event indicators in a sample of size \(n\). The likelihood is \[ L(\lambda) = \prod_{i = 1}^n \lambda^{\delta_i} e^{-\lambda (t_i - \tentry_i)}, \] and the log likelihood is \[ \ell(\lambda) = \sum_{i = 1}^n \big(\delta_i \ln \lambda - \lambda (t_i - \tentry_i)\big) = m \ln \lambda - \lambda T, \tag{5.13}\] where \[ m = \sum_{i = 1}^n \delta_i \] is the total number of observed events and \[ T = \sum_{i = 1}^n \big(t_i - \tentry_i\big) \] is the total person-time. This is the total time under observation added up over all participants in the study. The likelihood assumes that the same rate \(\lambda_\true\) of events per unit time occurs in all of this person-time.

Maximum likelihood estimation of the rate \(\lambda_\true\) proceeds in the same way as it did for a probability. The only difference is that we are working with an exponential likelihood for times to events rather than a binomial likelihood for a binary outcome. Differentiating with \(\ell(\lambda)\) with respect to \(\lambda\), we get the score function \[ U(\lambda) = \frac{m}{\lambda} - T. \tag{5.14}\] Solving the score equation \(U(\hat{\lambda}) = 0\) gives us the point estimate \[ \hat{\lambda} = \frac{m}{T}. \tag{5.15}\] This is called the incidence rate in epidemiology. The incidence rate is the maximum likelihood estimate of an exponential rate parameter.

Differentiating \(U(\lambda)\) with respect to \(\lambda\), we get the observed information function \(I(\lambda) = m / \lambda^2\). The estimated variance is \[ I\big(\hat{\lambda}\big)^{-1} = \Bigg(\frac{m}{\big(\frac{m}{T}\big)^2}\Bigg)^{-1} = \frac{m}{T^2}, \tag{5.16}\] so the Wald 95% confidence interval for \(\lambda_\true\) is \[ \hat{\lambda} \pm 1.96 \sqrt{\frac{m}{T^2}}. \tag{5.17}\] It has relatively poor performance in terms of width and coverage probability. The performance of the Wald confidence interval can be improved using a log transformation, which ensures that the lower bound is greater than zero. Using the delta method, the variance of \(\ln \hat{\lambda}\) is approximately \[ \bigg(\frac{1}{\hat{\lambda}}\bigg)^2 \frac{m}{T^2} = \frac{1}{m}, \] which depends only on the number of events observed. An approximate 95% confidence interval for \(\ln(\lambda_0)\) is \[ \ln\Big(\frac{m}{T}\Big) \pm 1.96 \sqrt{\frac{1}{m}}. \] Exponentiating, we get the log-transformed Wald 95% confidence interval \[ \frac{m}{T} e^{\pm 1.96 \sqrt{\frac{1}{m}}}. \] Better interval estimates can be obtained by inverting the score or likelihood ratio test or from Bayesian credible intervals. Among the frequentist large-sample confidence intervals, the likelihood ratio interval has the best performance (Brown, Cai, and DasGupta 2003).

exponential.R
## Exponential rate parameter estimation

# generate right-censored exponential distribution
tevent <- rexp(1000, rate = 2)
tcens <- rexp(1000)             # default rate = 1
sdat <- data.frame(texit = pmin(tcens, tevent),
                   event = ifelse(tcens < tevent, 0, 1))

# calculating incidence rate and log-transformed confidence interval
m <- sum(sdat$event)
T <- sum(sdat$texit)
m / T
m / T * exp(c(-1, 1) * qnorm(.975) * sqrt(1 / m))

# fitting intercept-only exponential regression model
# This uses the survreg() function from the survival package.
library(survival)
expfit <- survreg(Surv(texit, event) ~ 1, data = sdat,
                  dist = "exponential")
summary(expfit)
coef(expfit)
confint(expfit)

# log-transformed Wald CI for the exponential rate
# The intercept is ln(scale), which is -ln(rate).
# The rate is exp(-intercept).
exp(-coef(expfit))
exp(-confint(expfit))

# add delayed entry (left truncation) to sdat
sdat2 <- sdat
sdat2$tentry <- rexp(1000, rate = 5)
sdat2 <- subset(sdat2, tentry < texit)

# incidence rate and log-transformed confidence interval
m2 <- sum(sdat2$event)
T2 <- sum(sdat2$texit - sdat2$tentry)
m2 / T2
m2 / T2 * exp(c(-1, 1) * qnorm(.975) * sqrt(1 / m2))

# survreg() does not handle delayed entry, so use flexsurv::flexsurvreg()
library(flexsurv)
expfit2 <- flexsurvreg(Surv(tentry, texit, event) ~ 1, data = sdat2,
                       dist = "exp")
# The summary() function does not work with flexsurvreg objects.
# Type "expfit2" or "expfit2$res" to get point and interval estimates.
# The "se" in expfit2$res is the delta method standard error.
expfit2
expfit2$res       # rate parameter scale
expfit2$res.t     # log rate parameter scale

5.3.3 Memoryless property

Given that you have reached age \(a\), your life expectancy at age \(a\) is how many years you are expected to live past age \(a\). According to the Social Security Administration’s 2019 life table, life expectancy at birth in the United States in 2019 was 76.22 years for males and 81.28 years for females. Life expectancy at age 40 was 38.74 years for males and 42.76 years for females, which means that the average age at death for those who survive to age 40 was 78.74 years and 82.76 years, respectively. Life expectancy at age 80 was 8.43 years for males and 9.83 years for females, so the average ages at death were 88.43 and 89.83 years, respectively. For humans, remaining life expectancy decreases with age.

Humans do not have exponential lifetimes. If your lifetime has an exponential distribution with rate \(\lambda\) and you survive to age \(t\), the probability that you survive to age \(t + u\) is \[ \Pr(\text{lifetime} > t + u \given{} \text{lifetime} > t) = \frac{e^{-\lambda (t + u)}}{e^{-\lambda t}} = e^{-u}. \] This does not depend on \(t\), so your life expectancy would be constant with age. This is called the memoryless property.

In a population with exponential lifetimes, the old and the young would have equal hazards of death at any given time and equal risks of death over any time interval. This seems to be true of decaying radioactive isotopes and other processes from physics and chemistry, but humans are more complex. The hazard of death is typically high right after birth, drops rapidly to a minimum between the ages of roughly 5 and 30, and then slowly increases. This is called the bathtub-shaped hazard or the Gompertz-Makeham law of mortality (Gompertz 1825; Makeham 1860). Figure 5.1 shows The bathtub-shaped hazard of death for the United States population in 2019.

Code
bathtub.R
# life table for male and female mortality in the United State, 2019
lifetab <- read.csv(file = "R/lifetable-2019.csv")
hdat <- subset(lifetab, age <= 80)
hdat$surv_male <- 1 - hdat$mortality_male
hdat$surv_female <- 1 - hdat$mortality_female

# plot hazard (events per year) for ages 0-80
plot(hdat$age, -log(hdat$surv_male), type = "l",
     xlab = "Age (years)", ylab = "Mortality hazard (deaths per year)")
lines(hdat$age, -log(hdat$surv_female), lty = "dashed")
grid()
legend("topleft", bg = "white", lty = c("solid", "dashed"),
       legend = c("Male", "Female"))
Figure 5.1: Mortality hazard (deaths per year) by age in the United States based on the Social Security Administration 2019 life table.

5.3.4 Prevalence, incidence, and duration of disease*

Suppose the time to disease onset in healthy individuals has an exponential(\(\lambda\)) distribution and the time to recovery in diseased individuals has an exponential(\(\gamma\)) distribution. Then the incidence rate of disease is \(\lambda\) and the mean duration of disease is \(1 / \gamma\). For simplicity, imagine a closed population where individuals move between the healthy and diseased states.

If the prevalence of disease at time \(t\) is \(p\) and the population has total size \(n\), then the expected number of disease onsets in any time interval \((t, t + \dif t]\) is \(n (1 - p) \lambda \,\dif t\). The expected number of recoveries in the same interval is \(n p \gamma \dif t\). For the prevalence to remain roughly constant over time (i.e., to randomly fluctuate around an equilibrium), we need the expected number of onsets and recoveries in each time interval to be the same: Thus, we need \[ n (1 - p) \lambda = n p \gamma \] The left-hand side is the expected number of disease onsets per time unit, and the right-hand side is the expected number of recoveries per time unit. It is critical to use the same time units (e.g., day, week, month, year) for the incidence rate and the duration of disease. This equation can be rearranged to get \[ \frac{\lambda}{\gamma} = \frac{p}{1 - p}, \] so \[ \text{incidence rate} \times \text{mean duration} = \text{prevalence odds} \] When the prevalence \(p\) is low, the prevalence and prevalence odds are roughly equal and we get \[ \text{incidence rate} \times \text{mean duration} \approx \text{prevalence}. \] Under more realistic conditions, the relationship between prevalence, incidence, and the duration of disease is more complex (Freeman and Hutchison 1980; Preston 1987; Keiding 1991; Alho 1992).

5.4 Poisson distribution

The Poisson distribution5 is one of the most important distributions in probability and statistics, and it has many applications in epidemiology. Section 5.2.3 showed that the cumulative hazard \(H(t)\) is the expected number of events that occur in \((0, t]\) when the event is repeatable. The number of events has a Poisson distribution with mean \(H(t)\).

If events occur at a constant rate \(\lambda\), then the times between events have an exponential(\(\lambda\)) distribution. The number \(X\) of events that occur in a time interval of length \(T\) will have a Poisson distribution with mean \(\lambda T\). The probability mass function (PMF) of a Poisson(\(\lambda T\)) distribution is \[ \Pr(X = x) = \frac{(\lambda T)^k}{k!} e^{-\lambda T} \text{ for } x = 0, 1, 2, \ldots. \tag{5.18}\] and \(\supp(X) = \{0, 1, 2, \ldots\}\). This is a PMF because, by definition, \[ e^{\lambda T} = \sum_{k = 0}^\infty \frac{(\lambda T)^k}{k!}. \] Multiplying \((\lambda T)^k / k!\) by \(e^{-\lambda T}\) ensures that the PMF over all possible values of \(X\) equals one. The relationship between the exponential and Poisson distributions can be seen easily for \(X = 0\): \[ \Pr(X = 0) = \frac{(\lambda T)^0}{0!} e^{-\lambda T} = e^{-\lambda T}, \] which is the probability that no event occurs in \((0, T]\) when the time-to-event has an exponential(\(\lambda\)) distribution.

5.4.1 Mean and variance

The mean of the Poisson(\(\lambda T\)) distribution is \[ \E[X] = \sum_{k = 0}^\infty k \frac{(\lambda T)^k}{k!} e^{-\lambda T} = \lambda T e^{\lambda T} e^{-\lambda T} = \lambda T. \] A similar calculation yields \[ \E[X^2] = \sum_{k = 0}^\infty k^2 \frac{(\lambda T)^k}{k!} e^{-\lambda T} = \lambda T + (\lambda T)^2. \] Using Equation 1.10, we get \[ \Var(X) = [\lambda T + (\lambda T)^2] - (\lambda T)^2 = \lambda T. \] Thus, both the mean and the variance are \(\lambda T\). Because it equals the mean, the parameter \(\lambda T\) is often written \(\mu\). Both \(\lambda\) and \(\mu\) can be estimated using maximum likelihood or Bayesian methods.

5.4.2 Incidence rates via count data

Suppose we observe \(n\) individuals in whom the time to disease onset is exponential(\(\lambda_\true\)), observing a total person-time of \(T\) during which \(m\) disease onsets occur. If we string together all of the observations, the memoryless property of the exponential distribution guarantees that we get an interval with total length \(T\) in which \(m\) events occurred and the times between events were exponential(\(\lambda_\true\)). Therefore, the total number of events that we see has a Poisson distribution with mean \(\lambda_\true T\). Using the Poisson PMF in Equation 5.18, we get the likelihood \[ L(\lambda) = \frac{(\lambda T)^m}{m!} e^{-\lambda T}. \] The corresponding log likelihood is \[ \ell(\lambda) = \ln L(\lambda) = m (\ln\lambda + \ln T) - \ln(m!) - \lambda T. \] Taking the derivative with respect to \(\lambda\), we get the score function \[ U(\lambda) = \frac{m}{\lambda} - T, \] which is exactly the same as the score function for \(\lambda\) that we got using an exponential likelihood in Equation 5.14. Taking another derivative with respect to \(\lambda\), we also get the same estimated variance \[ I(\hat{\lambda})^{-1} = \frac{m}{T^2} \] that we got in Equation 5.16. Under the Poisson model for the number of events, the Wald and log-transformed Wald confidence intervals for the unknown incidence rate \(\lambda_\true\) are exactly the same as those from the exponential model for the times to events. The score and likelihood ratio tests can be inverted to get confidence intervals that perform better in terms of coverage probability and width than the Wald interval (Brown, Cai, and DasGupta 2003).

Poisson-rate.R
## Poisson regression for incidence rates

# generate right-censored exponential distribution
tevent <- rexp(1000, rate = 2)
tcens <- rexp(1000)             # default rate = 1
sdat <- data.frame(texit = pmin(tcens, tevent),
                   event = ifelse(tcens < tevent, 0, 1))

# Poisson regression model
# Use log(time) offset to get incidence rate from Poisson(time * incidence rate)
poisreg <- glm(event ~ offset(log(texit)), data = sdat, family = poisson())
exp(coef(poisreg))
# GLMs use likelihood ratio confidence intervals in R.
exp(confint(poisreg))

# exponential regression for comparison (log-transformed Wald CI)
library(survival)
expreg <- survreg(Surv(texit, event) ~ 1, data = sdat, dist = "exponential")
exp(-coef(expreg))
exp(-confint(expreg))

# add delayed entry to sdat
sdat2 <- sdat
sdat2$tentry <- rexp(1000, rate = 5)
sdat2 <- subset(sdat2, tentry < texit)

# Poisson regression with delayed entry
poisreg2 <- glm(event ~ offset(log(texit - tentry)), data = sdat2,
                family = poisson())
exp(coef(poisreg2))
exp(confint(poisreg2))

# exponential regression with delayed entry for comparison
library(flexsurv)
expreg2 <- flexsurvreg(Surv(tentry, texit, event) ~ 1, data = sdat2,
                       dist = "exp")
expreg2$res

5.4.3 Small-sample estimation of incidence rates

The Poisson distribution can be used to calculate confidence limits for the incidence rate \(\lambda_\true\) that do not rely on the approximate normality in large samples that is guaranteed by the central limit theorem (CLT). Exact confidence limits can be calculated in a manner similar to the Clopper-Pearson confidence limits for a binomial probability in Section 3.5.2. Bayesian estimation, which does not require asymptotic normality, can also be used for small samples.

If we observe \(m\) events in a total person-time \(T\), the median unbiased estimate of \(\lambda_\true\) is the value of \(\lambda\) that makes \[ \Pr\nolimits_\lambda(X \leq m) = \Pr\nolimits_\lambda(X \geq m) \] where we use the subscript \(\lambda\) to indicate that the probabilities are calculated assuming \(\lambda_\true = \lambda\). If \(\lambda_\text{med}\) is the median unbiased estimate, then \[ \sum_{k = 0}^{m - 1} \frac{\big(\lambda_\text{med} T\big)^k}{k!} e^{-\lambda_\text{med} T} + \frac{1}{2} \frac{\big(\lambda_\text{med} T\big)^m}{m!} e^{-\lambda_\text{med} T} = \frac{1}{2}. \] It is the value of \(\lambda\) that makes the tail probabilities equal. The median of the distribution of \(\lambda_\text{med}\) is always \(\lambda_\true\) (Birnbaum 1964).

The lower exact \(1 - \alpha\) confidence limit for \(\lambda_\true\) gives the upper tail of the Poisson distribution a probability of \(\alpha / 2\) (Garwood 1936). It solves the equation \[ \sum_{k = m}^\infty \frac{\big(\lambda_\text{lower} T\big)^k}{k!} e^{-\lambda_\text{lower} T} = 1 - \Bigg[\sum_{k = 0}^{m - 1} \frac{\big(\lambda_\text{lower} T\big)^k}{k!} e^{-\lambda_\text{lower} T}\Bigg] = \frac{\alpha}{2}. \] The upper exact \(1 - \alpha\) confidence limit for \(\lambda_\true\) gives the lower tail of the Poisson distribution a probability of \(\alpha / 2\). It solves the equation \[ \sum_{k = 0}^m \frac{\big(\lambda_\text{upper} T\big)^k}{k!} e^{-\lambda_\text{upper} T} = \frac{\alpha}{2}. \] As with the Clopper-Pearson confidence limits for a binomial probability, the exact Poisson confidence limits guarantee a coverage probability (i.e., probability that the confidence interval contains \(\lambda_\true\)) of at least \(1 - \alpha\). However, these confidence intervals can be wide and have a coverage probability much higher than \(1 - \alpha\) (Cohen and Yang 1994; Swift 2009).

Mid-p confidence limits can produce confidence intervals that are narrower and have a coverage probability closer to \(1 - \alpha\) (Lancaster 1961). The lower \(1 - \alpha\) mid-p exact confidence limit for the incidence rate \(\lambda_\true\) solves the equation \[ 1 - \Bigg[\sum_{k = 0}^{m - 1} \frac{\big(\lambda_\text{lower} T\big)^k}{k!} e^{-\lambda_\text{lower} T} + \frac{1}{2} \frac{\big(\lambda_\text{lower} T\big)^m}{m!} e^{-\lambda_\text{lower} T}\Bigg] = \frac{\alpha}{2}. \] The upper \(1 - \alpha\) mid-p exact confidence limit solves the equation \[ \sum_{k = 0}^{m - 1} \frac{\big(\lambda_\text{upper} T\big)^k}{k!} e^{-\lambda_\text{upper} T} \\ + \frac{1}{2} \frac{\big(\lambda_\text{upper} T\big)^m}{m!} e^{-\lambda_\text{upper} T} = \frac{\alpha}{2}. \] The coverage probability of the mid-p confidence interval is usually very close to \(1 - \alpha\) (Cohen and Yang 1994; Swift 2009).

Poisson-small.R
## Small-sample Poisson point and interval estimation

# median unbiased estimate
medrate_pois <- function(m, T) {
  # m = number of events, T = total person-time

  # Poisson lower tail probability
  lower_tail <- function(rate) {
    mu = rate * T
    ppois(m, mu) - dpois(m, mu) / 2
  }

  # median unbiased estimate
  med <- uniroot(function(rate) lower_tail(rate) - 1 / 2, interval = c(0, 1))
  med$root
}
medrate_pois(7, 22)

# exact confidence limits
# The point estimate is the incidence rate m / T, not the median unbiased rate.
library(DescTools)
PoissonCI(7, 22, method = "exact")
PoissonCI(7, 22, method = "exact", conf.level = 0.8)

# mid-p confidence limits
midp_pois <- function(m, T, level=0.95) {
  # m = number of events, T = total person-time
  # The default confidence level (1 - type I error probability) is 0.95.
  
  # Poisson mid-p lower tail probability
  lower_tail <- function(rate) {
    mu = rate * T
    ppois(m, mu) - dpois(m, mu) / 2
  }

  # lower confidence limit
  alpha <- 1 - level
  lower <- uniroot(function(rate) lower_tail(rate) - (1 - alpha / 2),
                   interval = c(0, 100), extendInt = "yes")
  # upper confidence limit
  upper <- uniroot(function(rate) lower_tail(rate) - alpha / 2,
                   interval = c(0, 100), extendInt = "yes")

  # names for confidence limits
  lower_perc <- paste(round(alpha / 2 * 100, 3), "%", sep = "")
  upper_perc <- paste(round((1 - alpha / 2) * 100, 3), "%", sep = "")
  
  # return named vector of confidence limits
  conflimits <- c(lower$root, upper$root)
  names(conflimits) <- c(lower_perc, upper_perc)
  conflimits
}
midp_pois(7, 22)
midp_pois(7, 22, level = 0.8)

5.4.4 Poisson approximation to the binomial for rare events*

Most applications of the Poisson distribution in epidemiology come from its relationship with the exponential distribution, but the Poisson distribution also has a useful relationship with the binomial distribution. When \(n\) is large and \(p\) is small, the binomial(\(n, p\)) distribution can be approximated by a Poisson(\(n p\)) distribution. More specifically, imagine that \(n\) increases and \(p\) decreases such that \(n p = \mu\) stays constant. The binomial(\(n, p\)) probability mass function is \[ \Pr(X = k) = \binom{n}{k} p^k (1 - p)^{n - k} = \frac{n!}{(n - k)! k!} p^k (1 - p)^{n - k}. \] When \(n\) is much larger than \(k\), we have \[ \frac{n!}{(n - k)! k!} \approx \frac{n^k}{k!}. \] Because \(p = \mu / n\), we also have \[ p^k = \frac{\mu^k}{n^k} \] for each \(n\) and \[ (1 - p)^{n - k} = \Big(1 - \frac{\mu}{n}\Big)^{n - k} \longrightarrow e^{-\mu} \] as \(n \rightarrow \infty\). Putting all of this together, we get the following approximation to the binomial PMF \[ \Pr(X = k) \approx \frac{n^k \mu^k}{k! n^k} e^{-\mu} = \frac{\mu^k}{k!} e^{-\mu}, \] which is the Poisson(\(\mu\)) PMF.

As an approximation to the binomial distribution, the Poisson distribution can be used for rare events in many different contexts. The number of events such as automobile accidents or number of onsets of a rare disease in a given time period or area (or both) will often have a Poisson distribution. Clarke (1946) describes an astonishing application of the Poisson distribution that occurred in London in World War II. The V1 flying bomb was a German cruise missile with an 850 kg warhead that was fired at London (and later at Belgium) in 1944 and 1945. Soon after the attacks began, many people felt that the bomb impacts were clustered in particular areas of London. British investigators used the Poisson distribution to determine whether the V1s were being aimed or fell randomly within the city.

They divided 144 square kilometers of central London into 576 squares of \(0.25\) square kilometers each. By then, the total number of bombs that had fallen on the entire area was 537. If the bombs were falling randomly, the number of bombs in each square should have a Poisson distribution with mean \(537 / 576 \approx 0.932\). Grouping the squares by the number of bombs that had fallen on them yielded Table 5.3. The close fit to the Poisson distribution suggested that the bombs were falling randomly over the entire 144 square kilometers, not being aimed at particular targets within the city. Near the end of the war, analysis of captured V1s revealed that the guidance system was only accurate to a radius of about 6 kilometers, a circle large enough to encompass almost all of London at the time.

Table 5.3: Distribution of V1 bomb impacts in London (Clarke 1946).}
Number of Expected (Poisson) Actual number
impacts number of squares of squares
0 226.74 229
1 211.39 211
2 98.54 93
3 30.62 35
4 7.14 7
5+ 1.57 1
Total squares 576.00 576

5.5 Bayesian estimation of incidence rates

As with a binomial probability, Bayesian methods can be used to estimate an incidence rate without making any large-sample assumptions. They also allow a prior distribution to be used to incorporate background knowledge about the possible values of \(\lambda_\true\).

5.5.1 Gamma conjugate distribution

The conjugate distribution for the exponential(\(\lambda\)) and Poisson(\(\lambda T\)) distributions is the gamma distribution, which has the PDF \[ f(x, \alpha, \beta) = \frac{\beta^\alpha}{\Gamma(\alpha)} x^{\alpha - 1} e^{-\beta x} \tag{5.19}\] where \(\alpha > 0\) is the shape parameter, \(\beta > 0\) is the rate parameter, and \(\Gamma(\alpha) = \int_0^\infty x^{\alpha - 1} \dif x\) is the gamma function. If \(X\) has a gamma(\(\alpha, \beta\)) distribution, then \[ \E[X] = \frac{\alpha}{\beta} \] and variance \[ \Var(X) = \frac{\alpha}{\beta^2} \] The exponential(\(\beta\)) distribution is a special case of the gamma distribution with shape \(\alpha = 1\).

If the prior PDF of an unknown exponential rate \(\lambda_\true\) has a gamma(\(\alpha, \beta\)) distribution, then \[ p(\lambda \given \data) \propto \big(\lambda^m e^{-\lambda T}\big) \big(\lambda^{\alpha - 1} e^{-\beta \lambda}\big) = \lambda^{m + \alpha - 1} e^{-\lambda (T + \beta)}. \] After normalizing, this is a gamma(\(m + \alpha, T + \beta\)) distribution. The posterior mean is \[ \bar{\lambda} = \frac{m + \alpha}{T + \beta} \] and the posterior variance is \[ \frac{m + \alpha}{(T + \beta)^2} = \frac{\bar{\lambda}}{T + \beta} \] The equal-tailed \(1 - \alpha\) credible interval has its limits at the \(\alpha / 2\) and \(1 - \alpha / 2\) quantiles of this distribution. Figure 5.2 shows an example of an uninformative Bayesian prior and a posterior distribution for the incidence rate.

Code
incrate-Bayes-plot.R
## Bayesian estimation of incidence rates

x <- seq(0, 1, by = 0.002)
m <- 4
T <- 25

# plot of prior and posterior distributions
plot(x, dgamma(x, shape = 0.5 + m, rate = 0.1 + T), type = "n",
     xlab = expression(paste("Incidence rate (", lambda, ")")),
     ylab = "Probability density")
grid()
lines(x, dgamma(x, shape = 0.5, rate = 0.1), lty = "dashed")
lines(x, dgamma(x, shape = 0.5 + m, rate = 0.1 + T))
legend("topright", lty = c("dashed", "solid"),
       legend = c("gamma(0.5, 0.1) prior", "gamma (4.5, 25.1) posterior"))
Figure 5.2: The PDFs of a gamma(0.5, 0.1) prior distribution and the gamma(4.5, 25.1) posterior distribution that results from seeing 4 events in 25 person-years of observation. The units of the incidence rate events per year.

5.5.2 Jeffreys confidence interval

If we fix the total person-time \(T\) and model the number of events as a Poisson(\(\lambda T\)) random variable, the Jeffreys prior has \(\alpha = 1 / 2\) and \(\beta = 0\) (Jeffreys 1946). This is an improper prior because the PDF has a total area of \(\infty\) under the curve, but we get a proper posterior distribution (i.e., a posterior PDF with a total area of \(1\)) as long as \(T > 0\). The Jeffreys confidence interval for \(\lambda_\true\) is the equal-tailed credible interval from the gamma(\(m + 1 / 2, T\)) posterior distribution. If \(m = 0\), the lower limit can be set to zero. This confidence interval has good coverage probabilities and narrow widths similar to the likelihood ratio confidence interval (Brown, Cai, and DasGupta 2003; Swift 2009).

incrate-Bayes.R
## Bayesian estimation of incidence rates with gamma conjugate distribution

# incidence rate posterior mean, median, and equal-tailed credible limits
incrate_bayes <- function(m, T, level=0.95, priora=0.5, priorb=0) {
  # default arguments are for the Jeffreys confidence interval
  alpha <- 1 - level
  posta  <- priora + m
  postb <- priorb + T
  if (m == 0) {
    lower <- 0
  } else {
    lower <- qgamma(alpha / 2, shape = posta, rate = postb)
  }
  upper <- qgamma(1 - alpha / 2, shape = posta, rate = postb)
  postmean <- posta / postb
  postmedian <- qgamma(0.5, shape = posta, rate = postb)
  return(c(postmean = postmean, postmedian = postmedian,
           lower = lower, upper = upper,
           priora = priora, priorb = priorb, level = level))
}

# 7 events in 22 units of person-time
incrate_bayes(7, 22)                          # Jeffreys 95% confidence interval
incrate_bayes(7, 22, level = 0.8)             # Jeffreys 80% confidence interval
incrate_bayes(7, 22, priora = 1, priorb = 1)  # uniform prior

  1. William Farr (1807–1883) was a British pioneer of epidemiology. As the first statistician in the General Register Office, he was responsible for the collection of medical statistics in England and Wales He set up a system for recording causes of death that allowed comparison of mortality rates. In the quote, “consumption” and “phthisis” both refer to tuberculosis.↩︎

  2. To be predictable, it is sufficient for a process to be left-continuous. The disease onset process is assumed to be right-continuous with left-hand limits (cadlag) and hence unpredictable.↩︎

  3. Using integration by parts, we get that \[ \int_0^\infty t f(t) \,\dif t = -t S(t) \Big|_0^\infty + \int_0^\infty S(t) \,\dif t = \int_0^\infty S(t) \,\dif t \] when \(t S(t) \rightarrow 0\) as \(t \rightarrow \infty\).↩︎

  4. When \(T\) is discrete (or a mixture of continuous and discrete components), \[ t_p = \inf\{t: F(t) \geq p\} = \inf\{t: S(t) \leq 1 - p\}. \] When \(T\) is continuous, this reduces to Equation 5.3.↩︎

  5. Named after Sim'{e}on Denis Poisson (1781-1840), a French mathematician, physicist, and astronomer. He introduced the distribution in an 1837 paper in which he estimated the number of wrongful convictions that would occur over a given time period. His is one of the 72 names inscribed on the Eiffel Tower.↩︎