-
Notifications
You must be signed in to change notification settings - Fork 10
/
README.Rmd
80 lines (65 loc) · 2.94 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
---
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 -->
![GitHub R package version](https://img.shields.io/github/r-package/v/{{ gh_repo }})
[![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)
![GitHub contributors](https://img.shields.io/github/contributors/{{ gh_repo }})
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](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](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.sim = 10, ## 10 simulations
num.initial.cases = 1, ## one initial case in each of the simulations
prop.asym = 0, ## no asymptomatic infections
prop.ascertain = 0.2, ## 20% probability of ascertainment by contact tracing
cap_cases = 4500, ## don't simulate beyond 4500 infections
cap_max_days = 350, ## don't simulate beyond 350 days
r0isolated = 0.5, ## isolated individuals have R0 of 0.5
r0community = 2.5, ## non-isolated individuals have R0 of 2.5
disp.com = 0.16, ## dispersion parameter in the community
disp.iso = 1, ## dispersion parameter of those isolated
delay_shape = 1.651524, ## shape parameter of time from onset to isolation
delay_scale = 4.287786, ## scale parameter of time from onset to isolation
k = 0, ## skew of generation interval to be beyond onset of symptoms
quarantine = FALSE ## whether quarantine is in effect
)
```
### 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)
```