Populations are often heterogeneous in their susceptibility to infection following exposure, independent of the exposure risk that comes from different social contact patterns. Such heterogeneity may be age-dependent and vary between age groups. It may also vary within age groups due to prior infection resulting in immunity or due to immunisation. Combinations of within- and between-group variation in susceptibility may also occur, and can be incorporated into final size calculations (Miller 2012).

**New to finalsize?** It may help to read the “Get started” and “Modelling heterogeneous contacts” vignettes first!

There is substantial **heterogeneity in susceptibility to infection** in a population. We want to know how this heterogeneity could affect the final size of the epidemic.

- In addition to the infection \(R_0\), demography data, and social contact data;
- Data on within- and between-group variation in susceptibility to the infection; and
- Data on the proportion (or probability) of individuals in any demographic group in a specific susceptibility (or risk) group.

- In addition to an SIR epidemic;
- The partitioning of individuals into demographic and risk groups is complete, i.e., no individuals remain unaccounted for.

A working definition of susceptibility is the probability of becoming infected on contact with an infectious person.

Age-specific factors influencing the susceptibility of individuals include, but are not limited to, direct (immunological) susceptibility to infection upon exposure (e.g., due to natural susceptibility from previous infections, differences in vaccination status), and age-specific heterogeneous risk behaviour (Franco et al. 2022).

For example, for SARS-CoV-2, children are less susceptible to it than adults. Decreased susceptibility could result from immune cross-protection from other coronaviruses (Huang et al. 2020), or from non-specific protection resulting from recent infection by other respiratory viruses (Cowling et al. 2012), which children experience more frequently than adults (Tsagarakis et al. 2018; Davies et al. 2020).

```
# load finalsize
library(finalsize)
# load necessary packages
if (!require("socialmixr")) install.packages("socialmixr")
if (!require("ggplot2")) install.packages("ggplot2")
if (!require("colorspace")) install.packages("colorspace")
library(ggplot2)
library(colorspace)
```

This example uses social contact data from the POLYMOD project (Mossong et al. 2008) to estimate the final size of an epidemic in the U.K. These data are provided with the `socialmixr`

package.

These data are handled just as in the “Get started” vignette, and the code is not displayed here. This example also considers a disease with an \(R_0\) of 1.5.

```
# get UK polymod data
<- socialmixr::polymod
polymod <- socialmixr::contact_matrix(
contact_data
polymod,countries = "United Kingdom",
age.limits = c(0, 5, 18, 40, 65),
symmetric = TRUE
)
# get the contact matrix and demography data
<- t(contact_data$matrix)
contact_matrix <- contact_data$demography$population
demography_vector
# scale the contact matrix so the largest eigenvalue is 1.0
<- contact_matrix / max(Re(eigen(contact_matrix)$values))
contact_matrix
# divide each row of the contact matrix by the corresponding demography
<- contact_matrix / demography_vector
contact_matrix
<- length(demography_vector) n_demo_grps
```

`<- 1.5 r0 `

This example considers a scenario in which susceptibility to infection varies between age groups, but not within groups. In this example, susceptibility to infection increases with age.

This can be modelled as a susceptibility matrix with higher values for the 40 – 64 and 65 and over age groups, and relatively lower values for other groups.

```
# susceptibility is higher for the old
<- matrix(
susc_variable data = c(0.75, 0.8, 0.85, 0.9, 1.0)
)<- 1L n_susc_groups
```

**Note** that the susceptibility matrix (`susc_variable`

) still has only one column. The next example will show why this is modelled as a matrix.

The corresponding demography-susceptibility group distribution matrix is a one-column matrix of 1.0s: there is no variation in susceptibility within groups.

```
<- matrix(
p_susc_uniform data = 1.0,
nrow = n_demo_grps,
ncol = n_susc_groups
)
```

The effective \(R_0\) of the epidemic can often be different in a population with heterogeneous social contacts and heterogeneous susceptibility, both within and between groups.
The effective \(R_0\) is called \(R_{\text{eff}}\) and can be calculated using the function `r_eff()`

.

```
# calculate the effective R0 using `r_eff()`
r_eff(
r0 = r0,
contact_matrix = contact_matrix,
demography_vector = demography_vector,
susceptibility = susc_variable,
p_susceptibility = p_susc_uniform
)#> [1] 1.25815
```

This calculation shows that the user-specified \(R_0\) = 1.5 gives an \(R_{\text{eff}}\) of \(\approx\) 1.258 in this population, because not all individuals are fully susceptible to infection.

We can compare the final size in a population with heterogeneous susceptibility against that of a population with a uniform, high susceptibility.

```
# run final_size with default solvers and control options
# final size with heterogeneous susceptibility
<- final_size(
final_size_heterog r0 = r0,
contact_matrix = contact_matrix,
demography_vector = demography_vector,
susceptibility = susc_variable,
p_susceptibility = p_susc_uniform
)
```

```
# prepare uniform susceptibility matrix
<- matrix(1.0, nrow = n_demo_grps, ncol = n_susc_groups)
susc_uniform
# run final size with uniform susceptibility
<- final_size(
final_size_uniform r0 = r0,
contact_matrix = contact_matrix,
demography_vector = demography_vector,
susceptibility = susc_uniform,
p_susceptibility = p_susc_uniform
)
```

Visualise the effect of modelling age-dependent susceptibility against uniform susceptibility for all age groups.

```
# assign scenario name and join data
$scenario <- "heterogeneous"
final_size_heterog$scenario <- "uniform"
final_size_uniform
# join dataframes
<- rbind(
final_size_data
final_size_heterog,
final_size_uniform
)
# prepare age group order
$demo_grp <- factor(
final_size_data$demo_grp,
final_size_datalevels = contact_data$demography$age.group
)
# examine the combined data
final_size_data#> demo_grp susc_grp susceptibility p_infected scenario
#> 1 [0,5) susc_grp_1 0.75 0.2288298 heterogeneous
#> 2 [5,18) susc_grp_1 0.80 0.4639058 heterogeneous
#> 3 [18,40) susc_grp_1 0.85 0.3517122 heterogeneous
#> 4 [40,65) susc_grp_1 0.90 0.3119224 heterogeneous
#> 5 65+ susc_grp_1 1.00 0.2163372 heterogeneous
#> 6 [0,5) susc_grp_1 1.00 0.4160682 uniform
#> 7 [5,18) susc_grp_1 1.00 0.6888703 uniform
#> 8 [18,40) susc_grp_1 1.00 0.5379381 uniform
#> 9 [40,65) susc_grp_1 1.00 0.4639496 uniform
#> 10 65+ susc_grp_1 1.00 0.3042623 uniform
```

```
ggplot(final_size_data) +
geom_col(
aes(
x = demo_grp, y = p_infected,
fill = scenario
),col = "black",
position = position_dodge(
width = 0.75
)+
) expand_limits(
x = c(0.5, length(unique(final_size_data$demo_grp)) + 0.5)
+
) scale_fill_discrete_qualitative(
palette = "Cold",
name = "Population susceptibility",
labels = c("Heterogeneous", "Uniform")
+
) scale_y_continuous(
labels = scales::percent,
limits = c(0, 1)
+
) theme_classic() +
theme(
legend.position = "top",
legend.key.height = unit(2, "mm"),
legend.title = ggtext::element_markdown(
vjust = 1
)+
) coord_cartesian(
expand = FALSE
+
) labs(
x = "Age group",
y = "% Infected"
)
```

**Note** that, as shown in this example, a population with heterogeneous susceptibility is *always* expected to have a lower final epidemic size overall than an otherwise identical population that is fully susceptible.

This illustrates the broader point that infections in any one age group are *not independent* of the infections in other age groups. This is due to direct or indirect social contacts between age groups.

Reducing the susceptibility (and thus infections) of one age group can indirectly help to reduce infections in other age groups as well, because the overall level of epidemic transmission will be reduced.

This example considers a scenario in which susceptibility to infection varies within and between age groups. Immunisation against infection through an intervention campaign is a common cause of within-age group variation in susceptibility, and this example can be thought of as examining the effect of vaccination.

The effect of immunisation on susceptibility can be modelled as a reduction of the initial susceptibility of each age group. This is done by adding a column to the susceptibility matrix, with lower values than the first column.

```
# immunisation effect
<- 0.25 immunisation_effect
```

This example considers a modest 25% reduction in susceptibility due to vaccination.

```
# model an immunised group with a 25% lower susceptibility
<- cbind(
susc_immunised
susc_variable,* (1 - immunisation_effect)
susc_variable
)
# assign names to groups
colnames(susc_immunised) <- c("Un-immunised", "Immunised")
<- ncol(susc_immunised) n_risk_groups
```

**Note** that because there are two susceptibility groups, the susceptibility matrix has two columns. The corresponding **demography-susceptibility distribution matrix** must also have two columns!

We also need to model the proportion of each age group that has been immunised, and which therefore has lower susceptibility to the infection. To do this, we can modify the demography-susceptibility distribution matrix.

This example model considers half of each age group to be in the immunised and non-immunised groups.

In general terms, this could be interpreted as the rate of vaccine uptake, or as the effect of existing immunity from previous infection by a similar pathogen.

For within-group differences in susceptibility, such as due to immunisation, users could obtain this information from age-specific vaccination uptake statistics from national governments (here, the UK). When antibody response decays are known for an immunisation course (Iyer et al. 2020), more detailed statistics on the percentage of people vaccinated in the preceding few months only (here, in the UK), may be more informative.

```
# immunisation rate is uniform across age groups
<- rep(0.5, n_demo_grps)
immunisation_rate
# add a second column to p_susceptibility
<- cbind(
p_susc_immunised susceptible = p_susc_uniform - immunisation_rate,
immunised = immunisation_rate
)
```

**Recall** that each row of the demography-susceptibility distribution matrix must always sum to 1.0!

```
# we run final size over all r0 values
<- final_size(
final_size_immunised r0 = r0,
contact_matrix = contact_matrix,
demography_vector = demography_vector,
susceptibility = susc_immunised,
p_susceptibility = p_susc_immunised
)
```

The effect of immunisation (or some other reduction in susceptibility) can be visualised by comparing the proportion of the immunised and un-immunised groups that are infected.

```
# add scenario identifier
$scenario <- "immunisation"
final_size_immunised
# prepare age group order
$demo_grp <- factor(
final_size_heterog$demo_grp,
final_size_heteroglevels = contact_data$demography$age.group
)
$demo_grp <- factor(
final_size_immunised$demo_grp,
final_size_immunisedlevels = contact_data$demography$age.group
)
# examine the data
final_size_immunised#> demo_grp susc_grp susceptibility p_infected scenario
#> 1 [0,5) Un-immunised 0.7500 0.10882106 immunisation
#> 2 [5,18) Un-immunised 0.8000 0.25096327 immunisation
#> 3 [18,40) Un-immunised 0.8500 0.17473366 immunisation
#> 4 [40,65) Un-immunised 0.9000 0.15172135 immunisation
#> 5 65+ Un-immunised 1.0000 0.10075783 immunisation
#> 6 [0,5) Immunised 0.5625 0.08277964 immunisation
#> 7 [5,18) Immunised 0.6000 0.19484900 immunisation
#> 8 [18,40) Immunised 0.6375 0.13414414 immunisation
#> 9 [40,65) Immunised 0.6750 0.11609844 immunisation
#> 10 65+ Immunised 0.7500 0.07656251 immunisation
```

Compare scenarios in which susceptibility is heterogeneous between groups, against the immunisation scenario in which susceptibility also varies within groups.

```
ggplot(final_size_immunised) +
geom_col(
data = final_size_heterog,
aes(
x = demo_grp, y = p_infected,
fill = "baseline",
colour = "baseline"
),width = 0.75,
show.legend = TRUE
+
) geom_col(
aes(
x = demo_grp, y = p_infected,
fill = susc_grp
),col = "black",
position = position_dodge()
+
) facet_grid(
cols = vars(scenario),
labeller = labeller(
scenario = c(
heterogeneous = "Between groups only",
immunisation = "Within & between groups"
)
)+
) expand_limits(
x = c(0.5, length(unique(final_size_immunised$demo_grp)) + 0.5)
+
) scale_fill_discrete_qualitative(
palette = "Dynamic",
rev = TRUE,
limits = c("Immunised", "Un-immunised"),
name = "Immunisation scenario",
na.value = "lightgrey"
+
) scale_colour_manual(
values = "black",
name = "No immunisation",
labels = "Susceptibility homogeneous\nwithin groups"
+
) scale_y_continuous(
labels = scales::percent,
limits = c(0, 0.5)
+
) theme_classic() +
theme(
legend.position = "bottom",
legend.key.height = unit(2, "mm"),
legend.title = ggtext::element_markdown(
vjust = 1
),strip.background = element_blank(),
strip.text = element_text(
face = "bold",
size = 11
)+
) guides(
colour = guide_legend(
override.aes = list(fill = "lightgrey"),
title.position = "top",
order = 1
),fill = guide_legend(
nrow = 2,
title.position = "top",
order = 2
)+
) coord_cartesian(
expand = FALSE
+
) labs(
x = "Age group",
y = "% Infected",
title = "Heterogeneous susceptibility",
fill = "Immunisation\nscenario"
)
```

Cowling, Benjamin J., Vicky J. Fang, Hiroshi Nishiura, Kwok-Hung Chan, Sophia Ng, Dennis K. M. Ip, Susan S. Chiu, Gabriel M. Leung, and J. S. Malik Peiris. 2012. “Increased Risk of Noninfluenza Respiratory Virus Infections Associated With Receipt of Inactivated Influenza Vaccine.” *Clinical Infectious Diseases* 54 (12): 1778–83. https://doi.org/10.1093/cid/cis307.

Davies, Nicholas G., Petra Klepac, Yang Liu, Kiesha Prem, Mark Jit, and Rosalind M. Eggo. 2020. “Age-Dependent Effects in the Transmission and Control of COVID-19 Epidemics.” *Nature Medicine* 26 (8): 1205–11. https://doi.org/10.1038/s41591-020-0962-9.

Franco, Nicolas, Pietro Coletti, Lander Willem, Leonardo Angeli, Adrien Lajot, Steven Abrams, Philippe Beutels, Christel Faes, and Niel Hens. 2022. “Inferring Age-Specific Differences in Susceptibility to and Infectiousness Upon SARS-CoV-2 Infection Based on Belgian Social Contact Data.” *PLOS Computational Biology* 18 (3): e1009965. https://doi.org/10.1371/journal.pcbi.1009965.

Huang, Angkana T., Bernardo Garcia-Carreras, Matt D. T. Hitchings, Bingyi Yang, Leah C. Katzelnick, Susan M. Rattigan, Brooke A. Borgert, et al. 2020. “A Systematic Review of Antibody Mediated Immunity to Coronaviruses: Kinetics, Correlates of Protection, and Association with Severity.” *Nature Communications* 11 (1): 4704. https://doi.org/10.1038/s41467-020-18450-4.

Iyer, Anita S., Forrest K. Jones, Ariana Nodoushani, Meagan Kelly, Margaret Becker, Damien Slater, Rachel Mills, et al. 2020. “Persistence and Decay of Human Antibody Responses to the Receptor Binding Domain of SARS-CoV-2 Spike Protein in COVID-19 Patients.” *Science Immunology* 5 (52): eabe0367. https://doi.org/10.1126/sciimmunol.abe0367.

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.

Mossong, Joël, Niel Hens, Mark Jit, Philippe Beutels, Kari Auranen, Rafael Mikolajczyk, Marco Massari, et al. 2008. “Social Contacts and Mixing Patterns Relevant to the Spread of Infectious Diseases.” *PLOS Medicine* 5 (3): e74. https://doi.org/10.1371/journal.pmed.0050074.

Tsagarakis, Nikolaos J., Anthi Sideri, Panagiotis Makridis, Argyro Triantafyllou, Alexandra Stamoulakatou, and Eleni Papadogeorgaki. 2018. “Age-Related Prevalence of Common Upper Respiratory Pathogens, Based on the Application of the FilmArray Respiratory Panel in a Tertiary Hospital in Greece.” *Medicine* 97 (22): e10903. https://doi.org/10.1097/MD.0000000000010903.