-
Notifications
You must be signed in to change notification settings - Fork 7
/
README.Rmd
144 lines (103 loc) · 6.27 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
---
output: github_document
bibliography: vignettes/references.json
link-citations: true
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# {{ packagename }}: Calculate the final size of an epidemic <img src="man/figures/logo.svg" align="right" width="130"/>
<!-- badges: start -->
<a href="https://app.digitalpublicgoods.net/a/10557"><img src="https://digitalpublicgoods.net/registry/dpgicon.svg" alt="Digital Public Good" height="25">
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/license/mit)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![R-CMD-check](https://github.com/{{ gh_repo }}/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/{{ gh_repo }}/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/{{ gh_repo }}/branch/main/graph/badge.svg)](https://app.codecov.io/gh/{{ gh_repo }}?branch=main)
[![CRAN status](https://www.r-pkg.org/badges/version/finalsize)](https://CRAN.R-project.org/package=finalsize)
<!-- badges: end -->
_{{ packagename }}_ is an R package to calculate the final size of a SIR epidemic in populations with heterogeneity in social contacts and infection susceptibility.
_{{ packagename }}_ 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). An advantage of this approach is that it requires fewer parameters to be defined compared to a model that simulates the full transmission dynamics over time, such as models in the [_epidemics_ package](https://epiverse-trace.github.io/epidemics/articles/epidemics.html).
_{{ packagename }}_ implements methods outlined in @andreasen2011, @miller2012, @kucharski2014, and @bidari2016.
_{{ packagename }}_ 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).
_{{ packagename }}_ relies on [Eigen](https://gitlab.com/libeigen/eigen) via [RcppEigen](https://github.com/RcppCore/RcppEigen) for fast matrix algebra, and is developed at the [Centre for the Mathematical Modelling of Infectious Diseases](https://www.lshtm.ac.uk/research/centres/centre-mathematical-modelling-infectious-diseases) at the London School of Hygiene and Tropical Medicine as part of the [Epiverse-TRACE](https://data.org/initiatives/epiverse/).
## Installation
The package can be installed from CRAN using
```r
install.packages("finalsize")
```
### Development version
The current development version of _{{ packagename }}_ can be installed from [Github](https://github.com/{{ gh_repo }}) using the `remotes` package.
The development version documentation can be found [here](https://epiverse-trace.github.io/finalsize/dev/).
```r
if(!require("pak")) install.packages("pak")
pak::pak("{{ gh_repo }}")
```
## Quick start
The main function in _{{ packagename }}_ is `final_size()`, which calculates the final size of an epidemic given the $R_0$.
```{r}
# load finalsize
library(finalsize)
final_size(1.5)
```
Optionally, `final_size()` can estimate the epidemic size for populations with differences among demographic groups in their social contact patterns, in their susceptibility to infection.
We can use social contact data (here, from the _socialmixr_ package) to estimate the final size of an epidemic when the disease has an R<sub>0</sub> 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.
```{r}
# Load example POLYMOD social contacts data included with the package
data(polymod_uk)
# Define contact matrix (entry {ij} is contacts in group i reported by group j)
contact_matrix <- polymod_uk$contact_matrix
# Define population in each age group
demography_vector <- polymod_uk$demography_vector
# Define susceptibility of each group
susceptibility <- matrix(
data = c(1.0, 0.5, 0.5),
nrow = length(demography_vector),
ncol = 1
)
# Assume uniform susceptibility within age groups
p_susceptibility <- matrix(
data = 1.0,
nrow = length(demography_vector),
ncol = 1
)
# R0 of the disease
r0 <- 1.5 # assumed for pandemic influenza
# 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
)
```
Helper functions included in _{{ packagename }}_ 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$.
```{r}
# 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
)
```
## Package vignettes
More details on how to use _{{ packagename }}_ can be found in the [online documentation as package vignettes](https://epiverse-trace.github.io/finalsize/), under "Articles".
## Help
To report a bug please open an [issue](https://github.com/{{ gh_repo }}/issues/new/choose).
## Contribute
Contributions to _{{ packagename }}_ are welcomed. Please follow the [package contributing guide](https://github.com/{{ gh_repo }}/blob/main/.github/CONTRIBUTING.md).
## Code of conduct
Please note that the _{{ packagename }}_ project is released with a [Contributor Code of Conduct](https://github.com/epiverse-trace/.github/blob/main/CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.
## Citing this package
```{r message=FALSE, warning=FALSE}
citation("finalsize")
```
## References