Skip to contents

epichains provides methods to analyse and simulate the size and length of branching processes with an arbitrary offspring distribution. In this vignette we lay out the mathematical concepts behind the functionality available in the package.

Branching processes

Branching processes are a class of models that are used to model the growth of populations. They assume that each member of the population produces a number of offspring, ZZ, that is a random variable with probability mass function p(Z=z|θ)p(Z = z | \theta), called the offspring distribution. Their use has a long history in epidemiology, where the population is interpreted as a pathogen, and the offspring as new hosts that it infects (Farrington, Kanaan, and Gay 2003). Below we will call these infected individuals cases but the methods could be applied in other contexts where branching processes are to be used.

Simulation

To simulate from a branching process, we start with a single case and proceed in discrete steps or generations, drawing from the offspring distribution p(Z=z|θ)p(Z=z | \theta) to generate new cases from each case.

Given an infector ii and infectee jj, we can additionally assign them a distribution of times TT that approximates when the infection event occurred. If we define TT as a random variable with distribution f(T=t;θ)f(T = t; \theta) we can assign each case jj a time tjt_{j} which, if case jj has been affected by case ii is given by f(tjti|θ)f(t_{j} - t_{i} | \theta). If we identify the timing of cases by the time of their symptom onset this is the serial interval, but depending on case definitions this could be another interval.

Summary statistics

Branching process simulations end when they have gone extinct, that is, no more offspring are being produced, or because of some stopping criterion. To summarise the simulations, we either study the size or length of the resulting chain of cases. The size SS of a chain is the number of cases that have occurred over the course of the simulation including the initial case so that S1S \geq 1. The length LL of a chain is the number of generations that have been simulated including the initial case so that L1L \geq 1.

Inference

By characterising a chains of cases by their size of length we can conduct inference to learn about the underlying parameters θ\theta from observation of chain sizes or chain lengths (Blumberg and Lloyd-Smith 2013). In general this is only possible for subcritical branching processes, i.e. ones where the mean number of offspring is less than 1, as otherwise the branching process could grow forever. However, we can expand the theory to supercritical branching processes, i.e. ones where the mean number of offspring is greater than 1, by defining a cut off of chain size or length beyond which we treat the chain as if it had infinite size or length, respectively.

Size and length distributions for some offspring distributions

We show the equations for the size and length distributions for some offspring distributions where they can be derived analytically: Poisson, negative binomial, geometric, and a gamma-Borel mixture.

Negative binomial and special cases

If the offspring distribution is a Poisson distribution, we can interpret its rate parameter λ\lambda as the basic reproduction number R0R_{0} of the pathogen. In the more general case where the offspring definition can be overdispersed leading to superspreading we can use a negative binomial offspring distribution with mean μ\mu and overdispersion kkBlumberg and Lloyd-Smith (2013). In that case, the mean parameter μ\mu is interpreted as the basic reproduction number R0R_0 of the pathogen. The negative binomial distribution arises from a Poisson-gamma mixture and thus a branching process with negative binomial distributed offspring can be interpreted as one with Poisson distributed offspring where the basic reproduction number R0R_0 itself varies according to a gamma distribution. The amount of variation in R0R_0 is then interpreted as individual-level variation in transmission representing overdispersion or superspreading, and the degree to which this happens is given by the overdispersion parameter kk.

Size distributions

The probability pp of a chain of size SS given R0R_0 and kk in a branching process with negative binomial offspring distribution is given in Eq. 9 of Blumberg and Lloyd-Smith (2013)

p(S|R0,k)=Γ(kS+S1)Γ(kS)Γ(S+1)(R0k)S1(1+R0k)kS+S1 p(S|R_0, k) = \frac{\Gamma(kS + S - 1)}{\Gamma(kS)\Gamma(S + 1)} \frac{\left(\frac{R_0}{k}\right)^{S - 1}}{\left( 1 + \frac{R_0}{k} \right)^{kS + S - 1}}

where Γ\Gamma is the gamma function. In order to estimate SS from a given R0R_0 and kk we can define a likelihood function L(S)=p(S|R0,k)L(S) = p(S|R_0, k). The corresponding log-likelihood is

LL(S)=logΓ(kS+S1)(logΓ(kS)+logΓ(S1))+(S1)logR0k(SR0+(S1))log(1+R0k)\begin{align} \mathrm{LL}(S) = &\log\Gamma(kS + S - 1) - \left(\log\Gamma(kS) + \log\Gamma(S - 1) \right) \\ & + (S-1) \log \frac{R_0}{k} - (SR_0 + (S - 1)) \log \left(1 + \frac{R_0}{k}\right) \end{align}

The log-likelihood for Poisson distributed offspring follows from this where kk tends to infinity (corresponding to Eq. 2.2 in Farrington, Kanaan, and Gay (2003))

LL(S)=(S1)logR0SR0+(S2)logSlogΓ(S) \mathrm{LL}(S) = (S - 1) \log R_0 - S R_0 + (S - 2) \log S - \log\Gamma(S)

In all cases the point estimate for the basic reproduction number R0̂\hat{R_0} is related to the mean chain size S\bar{S} by

R0̂=11S \hat{R_0} = 1 - \frac{1}{\bar{S}}

Length distributions

The cumulative mass function F(L)F(L) of observing a chain of length LL when offspring is Poisson distributed is given by Eq. (2.5) in Farrington, Kanaan, and Gay (2003) (there called “outbreak duration”):

F(L)=eR0EL(eR0eR0) F(L) = e^{-R_0} E_L \left( e^{R_0 e^{-R_0} } \right)

where EL(x)E_L(x) is the iterated exponential function, E0(x)=1E_0(x) = 1, EL+1(x)=xEL(x)E_{L + 1}(x) = x^{E_L(x)}.

For geometric distributed offspring (corresponding to a negative Binomial with k=1k=1) this function is given by

F(L)=1R0L+11R0L2 F(L) = \frac{ 1- R_0^{L + 1} } {1 - R_0^{L - 2}}

In both cases f(L)f(L) denotes cumulative mass functions and therefore the probability of observing a chain of length LL is therefore f(L)f(L1)f(L) - f(L - 1).

Gamma-Borel mixture

The probability distribution of outbreak sizes from a branching process with a Poisson offspring distribution (Eq. 2.2 in Farrington, Kanaan, and Gay (2003)) is a special case of the Borel-Tanner distribution starting with 1 individual. An alternative to the negative binomial offspring distribution which represents a Poisson-gamma mixture is a Borel-gamma mixture. This could represent situations where the variation is not at the individual level but at the chain level, i.e. transmission chains is homogeneous but there is heterogeneity between chains. In that case, it can be shown that the resulting log-likelihood of chain sizes is

LL(S)=logΓ(k+S1)(logΓ(k)+logΓ(S+1))+(S1)logSklog(S+R0k)\begin{align} \mathrm{LL}(S) = &\log\Gamma(k + S - 1) - \left(\log\Gamma(k) + \log\Gamma(S + 1) \right) \\ & + (S-1) \log S - k \log \left(S + \frac{R_0}{k}\right) \end{align}

Numerical approximations of chain size and length distributions

When analytic likelihoods are not available a numerical approximation is used to derive the distributions. In order to do this, the simulation functionality is be used to generate nn simulated chains and the value of the cumulative mass function P(S|θ)P(S|\theta) at the observed SS approximated by the empirical cumulative distribution function: P(S|θ)i𝟏(xi<=S) P(S|\theta) \approx \sum_i \mathbf{1}(x_i <= S) where 𝟏\mathbf{1} is the indicator function and xix_i the i-th observed chain size (or length, if the interest is in LL). In order to improve this approximation a linear approximation is applied to the values of the empirical distribution function (at the expense of normalisation to 1).

The (unnormalised) probability of observing SS is then given by p(S|θ)=P(S|θ)P(S1|θ) p(S|\theta) = P(S|\theta) - P(S - 1|\theta) and a an equivalent relationship is used for LL.

Blumberg, S., and J. O. Lloyd-Smith. 2013. “Comparing Methods for Estimating R0 from the Size Distribution of Subcritical Transmission Chains.” Epidemics 5 (3): 131–45. https://doi.org/10.1016/j.epidem.2013.05.002.
Farrington, C. P., M. N. Kanaan, and N. J. Gay. 2003. “Branching Process Models for Surveillance of Infectious Diseases Controlled by Mass Vaccination.” Biostatistics (Oxford, England) 4 (2): 279–95. https://doi.org/10.1093/biostatistics/4.2.279.
Lloyd-Smith, J. O., S. J. Schreiber, P. E. Kopp, and W. M. Getz. 2005. “Superspreading and the Effect of Individual Variation on Disease Emergence.” Nature 438 (7066): 355–59. https://doi.org/10.1038/nature04153.