https://github.com/epiforecasts/ringbp
Simulate infectious disease transmission with contact tracing
https://github.com/epiforecasts/ringbp
controlling-outbreaks transmission
Last synced: 8 months ago
JSON representation
Simulate infectious disease transmission with contact tracing
- Host: GitHub
- URL: https://github.com/epiforecasts/ringbp
- Owner: epiforecasts
- License: other
- Created: 2020-01-23T16:38:07.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2025-09-22T13:49:32.000Z (9 months ago)
- Last Synced: 2025-09-30T03:59:03.809Z (9 months ago)
- Topics: controlling-outbreaks, transmission
- Language: R
- Homepage: http://epiforecasts.io/ringbp/
- Size: 316 MB
- Stars: 17
- Watchers: 10
- Forks: 11
- Open Issues: 28
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
README
---
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

[](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)
_{{ 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_ascertained = 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, cap_cases = 4500)
```
## Contributors
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
seabbs,
sbfnk,
jhellewell14,
timcdlucas,
amygimma,
joshwlambert,
Bisaloo,
actions-user
### Issue Authors
### Issue Contributors