-
Notifications
You must be signed in to change notification settings - Fork 11
/
README.Rmd
149 lines (103 loc) · 6.69 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
145
146
147
148
149
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "75%",
fig.align = "center"
)
```
# epiparameter <img src="man/figures/logo.png" align="right" width="120" />
<!-- badges: start -->
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![R-CMD-check](https://github.com/epiverse-trace/epiparameter/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/epiverse-trace/epiparameter/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/epiverse-trace/epiparameter/branch/main/graph/badge.svg)](https://app.codecov.io/gh/epiverse-trace/epiparameter?branch=main)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.11110881.svg)](https://doi.org/10.5281/zenodo.11110881)
[![CRAN status](https://www.r-pkg.org/badges/version/epiparameter)](https://CRAN.R-project.org/package=epiparameter)
[![CRAN downloads](https://cranlogs.r-pkg.org/badges/epiparameter)](https://cran.r-project.org/package=epiparameter)
<!-- badges: end -->
`{epiparameter}` is an `R` package that contains a library of epidemiological parameters for infectious diseases as well as classes and helper functions to work with the data. It also includes functions to extract and convert parameters from reported summary statistics.
`{epiparameter}` 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](https://www.lshtm.ac.uk/) as part of [Epiverse-TRACE](https://data.org/initiatives/epiverse/).
## Installation
The package can be installed from CRAN using
```r
install.packages("epiparameter")
```
The development version of `{epiparameter}` can be installed from [GitHub](https://github.com/epiverse-trace/epiparameter) using the `{pak}` package:
``` r
# check whether {pak} is installed
if(!require("pak")) install.packages("pak")
pak::pak("epiverse-trace/epiparameter")
```
Alternatively, install pre-compiled binaries from [the Epiverse TRACE R-universe](https://epiverse-trace.r-universe.dev/epiparameter)
``` r
install.packages("epiparameter", repos = c("https://epiverse-trace.r-universe.dev", "https://cloud.r-project.org"))
```
## Quick start
```{r load-epiparameter}
library(epiparameter)
```
To load the library of epidemiological parameters into `R`:
```{r load-data}
epiparameters <- epiparameter_db()
epiparameters
```
This results in a list of database entries. Each entry of the library is an `<epiparameter>` object.
Alternatively, the library of epiparameters can be viewed as a vignette locally (`vignette("database", package = "epiparameter")`) or on the [{epiparameter} website](https://epiverse-trace.github.io/epiparameter/articles/database.html).
The results can be filtered by disease and epidemiological distribution. Here we set `single_epiparameter = TRUE` as we only want a single database entry returned, and by default (`single_epiparameter = FALSE`) it will return all database entries that match the disease (`disease`) and epidemiological parameter (`epi_name`).
```{r load-single-epiparameter}
influenza_incubation <- epiparameter_db(
disease = "influenza",
epi_name = "incubation period",
single_epiparameter = TRUE
)
influenza_incubation
```
To quickly view the list of epidemiological distributions returned by `epiparameter_db()` in a table, the `parameter_tbl()` gives a summary of the data, and offers the ability to subset you data by `disease`, `pathogen` and epidemiological parameter (`epi_name`).
```{r parameter-tbl}
parameter_tbl(epiparameters)
parameter_tbl(
epiparameters,
epi_name = "onset to hospitalisation"
)
```
The `<epiparameter>` object can be plotted.
```{r plot-epiparameter}
plot(influenza_incubation)
```
The CDF can also be plotted by setting `cumulative = TRUE`.
```{r, plot-epiparameter-cdf}
plot(influenza_incubation, cumulative = TRUE)
```
### Parameter conversion and extraction
The parameters of a distribution can be converted to and from mean and standard deviation. In `{epiparameter}` we implement this for a variety of distributions:
- gamma
- lognormal
- Weibull
- negative binomial
- geometric
The parameters of a probability distribution can also be extracted from other summary statistics, for example, percentiles of the distribution, or the median and range of the data. This can be done for:
- gamma
- lognormal
- Weibull
- normal
## Contributing to library of epidemiological parameters
The library of epidemiological parameters that can be loaded by `{epiparameter}` using the `epiparameter_db()` function is stored in the [`{epiparameterDB}` R package](https://github.com/epiverse-trace/epiparameterDB). If you would like to contribute to the library of epiparameters you can either:
1. Add data to a public [google sheet](https://docs.google.com/spreadsheets/d/1eCL3n_woseg5Npu7XD7TcuNoLUIhMBu8ZoLCkVdATUE/edit?usp=sharing). This spreadsheet contains two example entries as a guide to what fields are accepted. We are monitoring this sheet for new entries that will subsequently be included in the package.
2. Add to the [JSON file holding the database](https://github.com/epiverse-trace/epiparameterDB/blob/main/inst/extdata/parameters.json) directly via a Pull Request. See the [contributing guide](https://github.com/epiverse-trace/.github/blob/main/CONTRIBUTING.md) for instructions.
You can find a description of the epidemiological parameter data structure and contents in the [data dictionary](https://github.com/epiverse-trace/epiparameterDB/blob/main/inst/extdata/data_dictionary.json). This documents the valid format and data types to ensure consistency and accuracy. All entries in the parameter library are automatically validated against the data dictionary using an GitHub action workflow.
## Help
To report a bug please open an [issue](https://github.com/epiverse-trace/epiparameter/issues/new/choose)
## Contribute
Contributions to `{epiparameter}` are welcomed. [package contributing guide](https://github.com/epiverse-trace/.github/blob/main/CONTRIBUTING.md).
## Code of Conduct
Please note that the `{epiparameter}` 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("epiparameter")
```