finalsize is an R package to calculate the final size of a SIR epidemic in populations with heterogeneity in social contacts and infection susceptibility.
finalsize provides estimates for the total proportion of a population infected over the course of an epidemic, and can account for a demographic distribution (such as age groups) and demography-specific contact patterns, as well as for heterogeneous susceptibility to infection between groups (such as due to age-group specific immune responses) and within groups (such as due to immunisation programs).
finalsize implements methods outlined in Andreasen (2011), Miller (2012), Kucharski et al. (2014), and Bidari et al. (2016).
finalsize can help provide rough estimates of the effectiveness of pharmaceutical interventions in the form of immunisation programmes, or the effect of naturally acquired immunity through previous infection (see the vignette).
finalsize relies on Eigen via RcppEigen for fast matrix algebra, and is developed at the Centre for the Mathematical Modelling of Infectious Diseases at the London School of Hygiene and Tropical Medicine as part of the Epiverse-TRACE.
The package can be installed from CRAN using
install.packages("finalsize")
The current development version of finalsize can be
installed from Github using the
remotes
package. The development version documentation can
be found here.
if(!require("pak")) install.packages("pak")
::pak("epiverse-trace/finalsize") pak
The main function in finalsize is final_size()
,
which calculates the final size of an epidemic. Helper functions
included in finalsize are provided to calculate the effective
\(R_0\), called \(R_{eff}\), from demographic and
susceptibility distribution data, while other helpers can convert
between \(R_0\) and the transmission
rate \(\lambda\).
Here, an example using social contact data from the socialmixr package investigates the final size of an epidemic when the disease has an R0 of 1.5, and given three age groups of interest — 0-19, 20-39 and 40+. The under-20 age group is assumed to be fully susceptible to the disease, whereas individuals aged over 20 are only half as susceptible as those under 20.
# load finalsize
library(finalsize)
# Load example POLYMOD data included with the package
data(polymod_uk)
# Define contact matrix (entry {ij} is contacts in group i reported by group j)
<- polymod_uk$contact_matrix
contact_matrix
# Define population in each age group
<- polymod_uk$demography_vector
demography_vector
# Define susceptibility of each group
<- matrix(
susceptibility data = c(1.0, 0.5, 0.5),
nrow = length(demography_vector),
ncol = 1
)
# Assume uniform susceptibility within age groups
<- matrix(
p_susceptibility data = 1.0,
nrow = length(demography_vector),
ncol = 1
)
# R0 of the disease
<- 1.5 # assumed for pandemic influenza
r0
# calculate the effective R0 using `r_eff()`
r_eff(
r0 = r0,
contact_matrix = contact_matrix,
demography_vector = demography_vector,
susceptibility = susceptibility,
p_susceptibility = p_susceptibility
)#> [1] 1.171758
# Calculate the proportion of individuals infected in each age group
final_size(
r0 = r0,
contact_matrix = contact_matrix,
demography_vector = demography_vector,
susceptibility = susceptibility,
p_susceptibility = p_susceptibility
)#> demo_grp susc_grp susceptibility p_infected
#> 1 [0,20) susc_grp_1 1.0 0.32849966
#> 2 [20,40) susc_grp_1 0.5 0.10532481
#> 3 40+ susc_grp_1 0.5 0.06995193
More details on how to use finalsize can be found in the online documentation as package vignettes, under “Articles”.
To report a bug please open an issue.
Contributions to finalsize are welcomed. Please follow the package contributing guide.
Please note that the finalsize project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
citation("finalsize")
#> To cite package 'finalsize' in publications use:
#>
#> Gupte P, Van Leeuwen E, Kucharski A (2023). _finalsize: Calculate the
#> Final Size of an Epidemic_.
#> https://github.com/epiverse-trace/finalsize,
#> https://epiverse-trace.github.io/finalsize/.
#>
#> A BibTeX entry for LaTeX users is
#>
#> @Manual{,
#> title = {finalsize: Calculate the Final Size of an Epidemic},
#> author = {Pratik Gupte and Edwin {Van Leeuwen} and Adam Kucharski},
#> year = {2023},
#> note = {https://github.com/epiverse-trace/finalsize,
#> https://epiverse-trace.github.io/finalsize/},
#> }