-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathREADME.Rmd
More file actions
157 lines (118 loc) · 6.04 KB
/
README.Rmd
File metadata and controls
157 lines (118 loc) · 6.04 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
out.width = "100%",
fig.path = "man/figures/README-"
)
set.seed(111)
```
# _{{ packagename }}_: Simulate infectious disease transmission with contact tracing
<!-- badges: start -->

[](https://github.com/{{ gh_repo }}/actions/workflows/R-CMD-check.yaml)
[](https://app.codecov.io/gh/{{ gh_repo }}?branch=main)

[](https://opensource.org/licenses/MIT)
<!-- badges: end -->
_{{ packagename }}_ is an R package that provides methods to simulate infectious
disease transmission in the presence of contact tracing. It was
initially developed to support a paper written in early 2020 to assess
the feasibility of controlling
COVID-19; see the [companion analysis code](https://github.com/cmmid/ringbp) and
[paper](https://doi.org/10.1016/S2214-109X(20)30074-7) for more details.
_{{ packagename }}_ is an R package that provides methods to simulate infectious disease transmission in the presence of contact tracing.
It was initially developed to support a paper written in early 2020 to assess the [feasibility of controlling COVID-19](https://github.com/cmmid/ringbp).
For more details on the methods implemented here, see the associated [paper](https://doi.org/10.1016/S2214-109X(20)30074-7).
## Installation
The current development version of _{{ packagename }}_ can be installed from [GitHub](https://github.com/) using the `pak` package.
```r
if(!require("pak")) install.packages("pak")
pak::pak("{{ gh_repo }}")
```
## Quick start
The main functionality of the package is in the `scenario_sim()` function.
Here is an example for running 10 simulations of a given scenario:
```{r scenario_sim}
library("ringbp")
library("ggplot2")
res <- scenario_sim(
n = 10, ## 10 simulations
initial_cases = 1, ## one initial case in each of the simulations
offspring = offspring_opts(
## non-isolated individuals have R0 of 2.5 and a dispersion parameter
community = \(n) rnbinom(n = n, mu = 2.5, size = 0.16),
## isolated individuals have R0 of 0.5 and a dispersion parameter
isolated = \(n) rnbinom(n = n, mu = 0.5, size = 1)
## by default asymptomatic individuals are assumed to have the same R0
## and dispersion as non-isolated individuals
),
delays = delay_opts(
incubation_period = \(x) stats::rweibull(n = x, shape = 2.322737, scale = 6.492272),
onset_to_isolation = \(x) stats::rweibull(n = x, shape = 1.651524, scale = 4.287786)
),
event_probs = event_prob_opts(
## 10% asymptomatic infections
asymptomatic = 0.1,
## 50% probability of onward infection time being before symptom onset
presymptomatic_transmission = 0.5,
## 20% probability of ascertainment by contact tracing
symptomatic_traced = 0.2
),
## whether quarantine is in effect
interventions = intervention_opts(quarantine = FALSE),
sim = sim_opts(
## don't simulate beyond 350 days
cap_max_days = 350,
## don't simulate beyond 4500 infections
cap_cases = 4500
)
)
```
### Plot of weekly cases
```{r plot}
ggplot(
data = res, aes(x = week, y = cumulative, col = as.factor(sim))
) +
geom_line(show.legend = FALSE, alpha = 0.3) +
scale_y_continuous(name = "Cumulative number of cases") +
theme_bw()
```
### Estimate extinction probability
```{r extinct_prob}
extinct_prob(res)
```
## Contribute
Contributions to _{{ packagename }}_ are welcomed. Please follow the [package contributing guide](https://github.com/epiforecasts/ringbp/blob/main/.github/CONTRIBUTING.md).
## Contributors
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
All contributions to this project are gratefully acknowledged using the [`allcontributors` package](https://github.com/ropensci/allcontributors) following the [all-contributors](https://allcontributors.org) specification. Contributions of any kind are welcome!
### Code
<a href="https://github.com/epiforecasts/ringbp/commits?author=seabbs">seabbs</a>,
<a href="https://github.com/epiforecasts/ringbp/commits?author=sbfnk">sbfnk</a>,
<a href="https://github.com/epiforecasts/ringbp/commits?author=jhellewell14">jhellewell14</a>,
<a href="https://github.com/epiforecasts/ringbp/commits?author=timcdlucas">timcdlucas</a>,
<a href="https://github.com/epiforecasts/ringbp/commits?author=amygimma">amygimma</a>,
<a href="https://github.com/epiforecasts/ringbp/commits?author=joshwlambert">joshwlambert</a>,
<a href="https://github.com/epiforecasts/ringbp/commits?author=Bisaloo">Bisaloo</a>,
<a href="https://github.com/epiforecasts/ringbp/commits?author=actions-user">actions-user</a>
### Issue Authors
<a href="https://github.com/epiforecasts/ringbp/issues?q=is%3Aissue+author%3Apearsonca">pearsonca</a>,
<a href="https://github.com/epiforecasts/ringbp/issues?q=is%3Aissue+author%3Asophiemeakin">sophiemeakin</a>
### Issue Contributors
<a href="https://github.com/epiforecasts/ringbp/issues?q=is%3Aissue+commenter%3Athimotei">thimotei</a>,
<a href="https://github.com/epiforecasts/ringbp/issues?q=is%3Aissue+commenter%3Aadamkucharski">adamkucharski</a>,
<a href="https://github.com/epiforecasts/ringbp/issues?q=is%3Aissue+commenter%3Adcadam">dcadam</a>,
<a href="https://github.com/epiforecasts/ringbp/issues?q=is%3Aissue+commenter%3Ajamesmbaazam">jamesmbaazam</a>
<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
## Code of Conduct
Please note that the _{{ packagename }}_ project is released with a
[Contributor Code of Conduct](https://github.com/epiforecasts/.github/blob/main/CODE_OF_CONDUCT.md).
By contributing to this project, you agree to abide by its terms.