When analysing an epidemic-prone infection, such as pandemic influenza, it is important to understand how many infections there could be in total. The overall number of infections that occur during such an epidemic, is called the ‘final epidemic size’.
The expected final size of an epidemic can be calculated using methods detailed in Andreasen (2011), Miller (2012), Kucharski et al. (2014), and Bidari et al. (2016), and which are implemented in the *finalsize* package.

An epidemic is underway. We want to know **how many individuals we would expect to be infected in total** for a given level of transmission and population susceptibility: this is the cumulative sum of all infections, or the *final size* of the epidemic.

- An estimate of the infection’s basic reproduction number \(R_0\);
- An estimate of the population size;
- An estimate of the susceptibility of the population to the infection.

- That the infection dynamics can be captured using a Susceptible-Infectious-Recovered (SIR) or Susceptible-Exposed-Infectious-Recovered (SEIR) model, where individuals who have been infected acquire immunity against subsequent infection, at least for the remaining duration of the epidemic.

```
# load finalsize
library(finalsize)
```

A number of statistical methods can be used to estimate the \(R_0\) of an epidemic in its early stages from available data. These are not discussed here, but some examples are given in the *episoap* package.

Instead, this example considers a infection with an \(R_0\) of 1.5, similar to that which could potentially be observed for pandemic influenza.

```
# define r0 as 1.5
<- 1.5 r0
```

Population estimates at the country scale are relatively easy to get from trusted data aggregators such as Our World in Data. More detailed breakdowns of population estimates at the sub-national scale may be available from their respective national governments. Here, we use an estimate for the U.K. population size of about 67 million.

```
# get UK population size
<- 67 * 1e6 uk_pop
```

This initial example assumes uniform mixing, i.e., that all individuals in the population have a similar number of social contacts. This can be modelled in the form of a single-element contact matrix, which must be divided by the population size.

```
# prepare contact matrix
<- matrix(1.0) / uk_pop contact_matrix
```

Social contacts are well known to be non-uniform, with age being a strong influence on how many contacts a person has and, moreover, on the ages of their contacts. A relatively simple example is that of children of school-going age, who typically have more social contacts than the elderly, and most of whose social contacts are with other schoolchildren.

The “Modelling heterogeneous contacts” vignette explores how this can be incorporated into final epidemic size calculations using *finalsize*.

In this initial example, the population is assumed to be fully susceptible to infection. This is modelled in the form of a matrix with a single element, called `susceptibility`

.

```
# all individuals are fully susceptible
<- matrix(1.0) susceptibility
```

Since all individuals are fully susceptible, the break-up of the population into susceptibility groups can be represented as another single-element matrix, called `p_susceptibility`

.

```
# all individuals are in the single, high-susceptibility group
<- matrix(1.0) p_susceptibility
```

Susceptibility to infection is well known to vary due to a number of factors, including age, prior exposure to the pathogen, or immunisation due to a vaccination campaign.

The “Modelling heterogeneous susceptibility” vignette explores how variation in susceptibility within and between demographic groups can be incorporated into final epidemic size calculations using *finalsize*.

`final_size`

The final size of the epidemic in the population can then be calculated using the only function in the package, `final_size()`

. This example allows the function to fall back on the default options for the arguments `solver`

(`"iterative"`

) and `control`

(an empty list).

```
# calculate final size
<- final_size(
final_size_data r0 = r0,
contact_matrix = contact_matrix,
demography_vector = uk_pop,
susceptibility = susceptibility,
p_susceptibility = p_susceptibility
)
# view the output data frame
final_size_data#> demo_grp susc_grp susceptibility p_infected
#> 1 demo_grp_1 susc_grp_1 1 0.5828132
```

This is the final epidemic size without accounting for heterogeneity in social contacts by age or other factors, and without accounting for variation in susceptibility to infection between or within demographic groups.

This value, of about 58% of the population infected, is easily converted to a count, and suggests that about 39 million people would be infected over the course of this epidemic.

Andreasen, Viggo. 2011. “The Final Size of an Epidemic and Its Relation to the Basic Reproduction Number.” *Bulletin of Mathematical Biology* 73 (10): 2305–21. https://doi.org/10.1007/s11538-010-9623-3.

Bidari, Subekshya, Xinying Chen, Daniel Peters, Dylanger Pittman, and Péter L. Simon. 2016. “Solvability of Implicit Final Size Equations for SIR Epidemic Models.” *Mathematical Biosciences* 282 (December): 181–90. https://doi.org/10.1016/j.mbs.2016.10.012.

Kucharski, Adam J., Kin O. Kwok, Vivian W. I. Wei, Benjamin J. Cowling, Jonathan M. Read, Justin Lessler, Derek A. Cummings, and Steven Riley. 2014. “The contribution of social behaviour to the transmission of influenza A in a human population.” *PLoS pathogens* 10 (6): e1004206. https://doi.org/10.1371/journal.ppat.1004206.

Miller, Joel C. 2012. “A Note on the Derivation of Epidemic Final Sizes.” *Bulletin of Mathematical Biology* 74 (9): 2125–41. https://doi.org/10.1007/s11538-012-9749-6.