Mathematical descriptions of infectious disease outbreaks are fundamental to forecasting and simulating the dynamics of epidemics, as well as to understanding the mechanics of how transmission occurs. One popular approach to modelling infectious disease outbreaks is founded on renewal processes and the renewal equation. A renewal process generalises a Poisson process to allow for arbitrary (instead of exponential) holding or event waiting times. From an infectious disease perspective, these holding times model how new infections are generated across an epidemic. The expected number of newly infections at some time is then given by the renewal equation [9] . While this formulation seems sensible, its application to infectious disease can be difficult to justify from first principles since it does not propose a formal mechanism for the generation of infectious events.
In the seminal work of [16] , Kermack and McKendrick studied the number and distribution of cases of an infectious disease as it is progressed through a population over time. They constructed classes, called compartments, and modelled the propagation of infectious disease via interactions among these compartments. The result is the popular susceptible-infected-recovered (SIR) model, variants of which are widely used in epidemiology. SIR models provide an intuitive mechanism for understanding disease transmission, and in the original derivation of [16] , they were found to be similar to the Volterra equation [23] . The Volterra equation is equal to the renewal equation when a convolution operator is applied. This link has been used to justify the role of renewal equations in modelling epidemic processes [11, 8, 21, 6] . However, the connection between the renewal equation and compartmental models is neither intuitive nor simple and the consequences of the differing assumptions behind both mathematical descriptions can be difficult to assess, especially when the number of compartments or renewal parameters becomes large [7, 22] .
The renewal equation may also be derived by treating every new infection event as a birth in the infected population. The Euler-Lotka equation from ecology [19] , which tracks the numbers of females in an age-structured population, can then be shown to yield the standard renewal equation of epidemiology [11] . While this derivation is simple and intuitive, it is somewhat limited.
Specifically, it remains unclear how to properly incorporate repeated, imported infections, which can significantly impact the time-course of an epidemic. A stronger and more transparent link between the physical process underlying an infectious outbreak and the formulation of the renewal model is therefore warranted.
Bellman and Harris elegantly captured this underlying infection mechanism by formulating an age-dependent branching process [2] . Branching processes describe how individuals stochastically propagate their numbers over time. In epidemiology, age-insensitive branching processes, such as the fundamental Galton-Watson process, which discretise the propagation process into generations, have provided tractable yet intuitive ways of modelling the spread of an infectious disease [1, 12] . However, these approaches, while useful, lack the flexibility and realism of the more general Bellman-Harris processes [2, 3] . Age-dependence allows for the variable time between exposure to a pathogen and the onset of symptoms to be properly modelled and provides a framework for encode useful information on the biology of the infecting pathogen, such as incubation periods and nonmonotonic infectiousness. Given these advantages, it is surprising that only a few epidemiological studies have considered Bellman-Harris approaches [4] .
To understand the Bellman-Harris process we consider a homogeneous or well-mixed population, in which members can randomly infect one another. Let t ∈ R + , be a positive real number representing time. We introduce a positive random variable τ ∈ R + with probability distribution g(τ ) and cumulative distribution G(τ ) = τ t=0 g(t)dt. After some random period τ, an infected individual can infect n ∈ I + (positive integers) other individuals with probability q n . We are interested in characterising the number of newly infected individuals at time t, which we denote Z(t). However, as each time trajectory of Z(t) is one possible reality (or sample-path) from the epidemic process, we more broadly aim to calculate and subsequently model, the average number of new infection events at time t, E[Z(t)].
Direct calculation of E[Z(t)] requires the manipulation of a generally intractable integral. Consequently, we adopt a generating function based approach, which allows the expectation to be obtained through derivatives. Generating functions are extremely useful but often hard to understand. They are perhaps best described by Pólya: A generating function is a device somewhat similar to a bag. Instead of carrying many little objects detachedly, which could be embarrassing, we put them all in a bag, and then we have only one object to carry, the bag. By using generating functions, we can use a single mathematical object to represent the complexity of the Bellman-Harris process.
In this paper we explore and exploit the relationship between the Bellman-Harris process and the renewal model approach to infectious disease with the aim of clarifying and understanding the dynamical assumptions underpinning the renewal process. Particularly, we re-derive the generating function of the Bellman-Harris process describing Z(t) with offspring distribution q n . This leads to an integral equation, the expectation of which recovers the renewal formulation of epidemiology [11] . While this result in itself is not completely new (e.g. it was solved for binary offspring distributions in [2, 3] ), we introduce two key generalisations. The first extends the Bellman-Harris process to allow for time-varying reproduction numbers, while the second provides a rigorous means of accounting for exogenous events, such as importations or zoonoses.
Further, we show how our approach provides a flexible framework for extending both the observation models (i.e. the count noise around E[Z(t)] and the effective reproduction number parametrisations, commonly employed in epidemic renewal model studies [8, 21, 22] . Specifically, we provide functionality for modelling negative binomial and Laplace distributed noise and for fitting autoregressive, polynomial and spline-based descriptions of the reproduction number. All source code is provided at https://github.com/mrc-ide/bhrp
Part of the difficulty in understanding the Bellman-Harris equation is the list of objects needed to derive it and their assumptions. We start by listing them here for reference:
• Z(t) is a stochastic counting process for the number of infected individuals, n ∈ I + , existing at time t ∈ R + . We are trying to estimate the expectation E[Z(t)].
• τ ∈ R + is a real random variable for the time taken to infect another individual. In infectious disease epidemiology, τ is generally called the serial interval distribution or offspring distribution [13] . τ has a probability measure, distributed by τ ∼ g(τ ), with cumulative distribution function G(τ ). A crucial assumption is that for each infected individual the distribution of • q n is the probability that an individual infects n other individuals. It is clear here that q n corresponds to the stochastic basic reproductive number and q n (t) to the stochastic timevarying reproductive number. The expected value of q n is the expected reproductive number that is ubiquitously used.
• For an arbitrary variable |s| ≤ 1, the generating function for the infection probabilities • We also introduce probabilities p r (t) of having r infected individuals at time t : p r (t) = P (Z(t) = r). We can therefore write the generating function for an arbitrary variable |s| ≤ 1 and the number of infected individuals Z(t) as:
Given the above expressions and the generating functions h(s, t) and F (s, t), we first need an expression for p r (t) = P [Z(t) = r], the probability that there are r infected individuals at time t. Deriving an expression for p r (t) is challenging because there are many facets to evaluating this probability. To aid understanding we will explain how to arrive at an expression for p r (t) and give a simple example for the binary case, where each individual infects two others. The first consideration is that any infected individual could infect n others (in time), and therefore we need to first sum over all possible infection probabilities ∞ n=0 q n (t). The next consideration is that there are many ways to arrive at p r (t) and so we need to account for all the combinations of n integers {i 1 , i 2 , . . . , i n } such that we can have r infections i.e. i 1 + i 2 + . . . + i n = r. Therefore, we want to sum over all the ways to get r and multiply these probabilities:
. τ appears in this equation because the r infections have occurred at some time τ before t. Finally, we need to integrate (average over) all the possible times τ at which the infections occurred, that is t τ =0 ·dG(τ ). In the binary case, much simplifies and the first sum disappears because each individual always infects 2 others and the summation is not necessary i.e. n = 2, q n = 0, and q 2 = 1. The second sum is also simply i1+i2=r because two individuals are always infected. Therefore, if we wanted to know the probability of seeing say 4 infections at time t in the binary case, we would need to
to the cumulative distribution function. In this binary case it is useful to notice that after the first infected individual infects two others, the process is self similar; a useful intuition therefore is to count taxa on a binary tree. Note that the Bellman Harris formulation is general and that if G is a step function we have the Galton-Watson family tree model and if G is exponentially distributed we have a Markov branching model. Putting all these constituents together, we can arrive at an expression for p r (t) that integrates (or averages) over incorporates the full uncertainty of when previous infections occurred and how many there were at that time. In what follows we will consider an extension of the original Bellman Harris formulation with q n (t), that is the probability of an individual infecting n others varies with time such that
Another intuition that may help the reader is that in the above equation, the terms in the braces are the coefficients of the generating function h(s, t), which therefore have the standard interpretation of the probability of seeing r infections while factoring all the ways r can appear i.e. p r . Now that we have an expression for p r (t), we can arrive at the generating function F (s, t) through multiplication with s r , over all possible values for r. Since we start with one infected individual, r ≥ 2. Also we note that s r can be decomposed into its constituents s r = s i1 s i2 . . . s in :
The interchange of sums and integrals is a consequence of Fubini/Tonelli conditions (i.e all the above functions are positive and the integral with respect to τ converges absolutely).
To simplify the above equation, we can now refactor the individual constituents of r -the indices
In this simplified notation, the fact that r is made up of a multitude of infection branches is hidden to simplify subsequent derivation. However the reader should remember that r is comprised of many possible branches and combinations.
To see how equation 5 is arises, note that:
so that the generating function F (s, t) can be written more compactly as
To simplify equation 9, we need to remember several choices we have made and defined. First if we define the generating function of Z(t) as F (s, t) = ∞ r=2 p r (t)s r , then clearly for some other time t − τ , the generating function is:
Finally, remembering that the generating function for infection probabilities is h(s, t) = ∞ n=0 q n (t)s n , we can rewrite:
Notice in this equation that the under brace can be simplified using the generating function h, h(s, t) = +∞ n=0 q n (t)s n . While this step can seem confusing, it is simply using the two generating functions and noticing recursive relationships. To finally arrive at the generating function F (s, t) = 
Normally the Bellman-Harris equation is derived with q n not q n (t) resulting in the more familiar
We have derived both expressions to show how the expected basic reproductive number and timevarying reproductive numbers (a fundamental metric in infectious disease modelling) can arise.
This will be shown when taking expectations below.
At first glance the generating function in equations 12 and 13 seems impenetrable and unsolvable.
However, by exploiting the favorable properties of generating functions, we can easily calculate the moments of Z(t) by calculating the derivatives of the generating function at s = 1.
Remember, the generating function of the number of infected individuals at time t, Z(t), is ∞ r=1 p r (t)s r . We denote the first moment (mean) of the generating function as the first derivative evaluated at s = 1:
Here f (t) is the average or expected number of infected individuals at time t. To get f (t) we take the first derivative of the Bellman-Harris integral equation (12) , and get:
Now, by using the properties of generating functions and evaluating at s = 1
From the definition of the generating function F (1, t−τ ) = 
This quantity is a the time-varying reproductive number. If we did this derivation using a fixed, time invariant q n , then the expected value would have been
These two equations show clearly how the basic and time-varying reproductive number arises from a carefully designed stochastic counting process. There is a clear intuition how reproductive numbers arise: first we design a time dependent branching process where there is a stochastic number, n, individuals that can be infected in time. Taking the expected value of q n from the first derivative of its generating function evaluated at s = 1 gives us the expected reproductive numbers -or the average number of infections a given individual infects. In this paper we show that this can be made time varying by changing q n to q n (t).
Incorporating R t we get a renewal equation for the first moment of Z(t):
where the term 1 − G(t) is the survival probability of the first infection or index infection. This term arises from p 1 (t), or the probability of seeing the first infection at time t.
In the renewal equation, there are two major components. The first term arises from p 1 (t), or the probability of seeing the first infection at time t. By assuming this first infection occurs straight away, this term disappears and we derive the renewal equation widely used in epidemic modelling [8, 21] . Even when not making this assumption, the survival function tends to zero with time and therefore does not not contribute to the epidemic, but simply starts it. And once started, the general and observed in multiple disciplines [25] .
In this section we will derive a renewal equation that accounts of exogenous sources at arbitrary times. It is useful to visualise the terms in the renewal equation (Figure 1 ) to see how it can easily be extended to include an exogenous component. Let us first consider a hypothetical scenario, or a new disease occurring in a homogeneously mixed immunologically naive population. We say this new disease has a serial interval distribution that is Rayleigh (g(τ ) = στ e − 1 2 στ 2 ) with σ = 1. The renewal equation is where * is a condensed convolution notation. We can solve the renewal equation using quadrature and see how the expected number of infected individuals evolves through time. Figure 1a shows the solution to equation 21 for an the index case starting at t = 0, and for R 0 = {0.5, 0.8, 1, 1.2}.
However, equally, we can solve the renewal equation for a single index case starting at some future time t = s 1 ,
where here we have introduced the Heaviside step function,
for importation time s i . Figure 1b shows this delayed importation, where the whole process shifts to start after s 1 , after which it is identical to the unshifted version.
And sum multiple renewal processes with exogenous inputs at different times i.e.:
Here exogenous sources occur at times s i , and the endogenous process begins at s 1 . Our superposition of multiple renewal processes differs from the S-renewal process [26] in that we do not consider differing convolutional terms. We justify this by saying there is no difference in the exogenous infections, they are the same disease as the endogenous ones, except they have entered the system from the outside and not as a secondary infection. To our knowledge this is a new derivation of the superposition renewal equation. To understand the dynamics of this superposition. In Figure   1c there are three exogenous events at times s 1 = 0.1, s 2 = 0.4, s 3 = 1. These exogenous infections seed the epidemic and allow it to increase. It is easy to see that an arbitrary function can be used in place of the Heaviside step function. As an example, figure 1d shows the example of a constant rate of importation at all times t, i.e. α(1 − G(t − s 1 )). In this figure the number of infections does not reduce beyond the exogenous rate. This derivation justifies the use of an exogenous term in the renewal equation and specifies how to create one.
There are two considerations to note, first, this exogenous term can be used to estimate when the first case occurred in an epidemic. Second, when performing inference, an analytic expression for the Heaviside function such as 1 1+e 2kx for an arbitrary large k can be used. Our final renewal equation is:
It is of interest here to note that equation 29 has deep connections with other counting processes such as Hawkes self-exciting stochastic processes [15] . Indeed, in a nice convergence of theory, it has been shown that the expected value of the Hawkes intensity function results in exactly the same renewal equation we have derived [24] .
The renewal equation 29 can be solved in closed form for a few special cases such as an exponential G(t) (Markov branching process), and often the equation is studied in lim t → ∞. In such cases the Laplace transform is taken to simplify the convolution to a product. Numerically, quadrature can be used, which results in solving a system of linear equations or using approaches like the Trapezium rule.
Often however, data is not continuous and binned into hourly, daily etc counts. For discrete data, the equation can be represented in binned form as:
In this binned discrete form, the model for f can be thought of as an Autoregression with coefficients determined by the serial interval distribution g(τ ). Once again this is a convergence of theory, [24] show that the expectation of the intensity function of a Hawkes process results exactly in equation 29, and [17, 18] have shown that a binned Hawkes process is an AR(∞) process, that can be approximated by an AR(p), with p lags. Therefore the renewal equation, in discrete form, is therefore deeply connected to standard time series approaches. These time series approaches are very effective [20] in forecasting but do not yield useful information about the underlying epidemiological mechanism and are largely "black box". Using the discrete renewal equation can have all the benefits of time series forecasting but is built from a mechanism rooted in infectious disease epidemiology and therefore has explainable and interpretable dynamics.
Equation 30 is highly flexible, and complicated non-parametric functions can be used for µ(t), and R t . From a computational complexity view, equation 30 is quadratic O(n 2 ), which is limiting, but given the discretisation of time can handle most epidemic data. The equation is also easy to evaluate and is therefore amenable to implementation in state-of-the-art Bayesian MCMC software such as Stan. In a Bayesian Hierarchical framework a general model would be:
In this hierarchical Bayesian framework, the first line are the prior distributions for hyperparameters θ, φ, µ t and R t . θ is a hyperparameter for the serial interval distribution, and can be given vague or strong priors, or fixed (given known biology). φ is a parameter for variance or overdispersion. µ(t) is the exogenous component, that models the number of new infections entering the modelled system at time t. It can incorporate information on movement etc. R t is modelled by some function such as a stochastic process, polynomials, splines etc. The second line is the discrete binned renewal equation. We note here, g(τ ) can be multivariate and incorporate information on genetics or spatial distance. Typically, g(τ ) is a Rayleigh, Log Normal, or Gamma distribution [8] . Equivalently, µ(t) can spatially vary and can be modelled effectively by log Gaussian Cox
Processes. The third and final line is the likelihood function, which for aggregated count data is generally negative binomial, i.e.
Our negative binomial is the reparameterisation where the location parameter, or mean, is our
The unnormalised posterior distribution is then
Posterior expectations can be calculated through approximate inference or via full MCMC sampling.
We fit a discrete renewal process with an exogenous component to COVID-19 case data for South
Korea. Given the high testing capacity in South Korea, case data is generally considered reliable.
However extensions can be included to model death data [10] . We consider g(τ ) to be the serial interval distribution and fixed as Gamma [5] i.e:
g ∼ Gamma(6.5, 0.62).
The serial interval distribution is discretised as g s = s+0.5 s−0.5 g(τ )dτ for s = 2, 3, ..., and g 1 = 1.5 0 g(τ )dτ . We paramaterise the time-varying reproduction number as R t = exp( t ), with the exponential to ensure positivity. t is a AR(2) process that starts with 1 ∼ N (−1, 0.1), and
with independent priors on ρ 1 and ρ 2 that are normal distributions conditioned to be in [0, 1];
the prior for ρ 1 is a N (0.8, .05) distribution constrained to the unit interval and the prior for ρ 2 is a N (0.1, 0.05) distribution constrained to the unit interval. The prior for σ t , the standard deviation of the stationary distribution of t is chosen as σ t ∼ N + (0, 1). The standard deviation of the weekly updates to achieve this standard deviation of the stationary distribution is
Other stochastic processes such as a Gaussian process or random walks could also be readily used. The exogenous component, accounting for importations into South Korea was modelled for the first t = {1, . . . , 40} days, from 2019/12/31 upto 2020/02/04 where travel restrictions were imposed [14] . We choose independent daily effects for µ t ∼ Exponential(0.5). The posterior distribution is then found through equation 35. Estimates from this model are shown in Figure 2 . For South Korea, there was a rapid rise in cases with a large R t in early January, followed by a reduction and a period of R t below 1.0. During this period, the cases numbers reduced so there were some days where no new cases were observed. In June, South Korea started experiencing smaller second waves with R t greater than 1.0 for short periods of time. Throughout this time our importation model fits a small but non-zero number of expected importations. In this paper we have derived from first principles how the renewal equation arises from a stochastic age-dependent branching process. In this derivation we show how the time-varying reproduction number emerges, and how it is possible to incorporate the exogenous infections such as importations or zoonoses. We then highlight how to perform full Bayesian inference over the renewal equation and provide an example modelling COVID-19 case data in South Korea.
The renewal equation is deeply connected with other approaches in epidemiology such as SEIR models [7] , Hawkes processes [24] , and autoregressive processes [17] . The benefit of the more Our derivation provides a means to incorporate more complex epidemiological processes within the renewal process but ensuring that these additions can be considered from a principled mathematical foundation.
SB would like to acknowledge the NIHR BRC Imperial College NHS Trust Infection and COVID themes the Academy of Medical sciences Springboard award and the Bill and Melinda Gates
Foundation.