Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/epiverse-trace/scenarios

[SUSPENDED]: R package to compare epidemic scenario model outcomes.
https://github.com/epiverse-trace/scenarios

epidemic-modelling epidemiology epiverse r r-package

Last synced: about 2 months ago
JSON representation

[SUSPENDED]: R package to compare epidemic scenario model outcomes.

Awesome Lists containing this project

README

        

---
output: github_document
link-citations: true
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# _{{ packagename }}_: Compare epidemic scenarios

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![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)
[![Project Status: Suspended – Initial development has started, but there has not yet been a stable, usable release; work has been stopped for the time being but the author(s) intend on resuming work.](https://www.repostatus.org/badges/latest/suspended.svg)](https://www.repostatus.org/#suspended)
[![CRAN status](https://www.r-pkg.org/badges/version/{{ packagename }})](https://CRAN.R-project.org/package={{ packagename }})

_{{ packagename }}_ was intended to provide functions to compare the outcomes of epidemic modelling simulations.

The development of _{{ packagename }}_ has been suspended in favour of increased scenario modelling and comparison functionality coming to the [_epidemics_](https://github.com/epiverse-trace/epidemics) package.
Development may resume once a use case for a separate comparison package is clearer.

## Installation

You can install the development version of _{{ packagename }}_ from [GitHub](https://github.com/) with:

```r
if (!require("remotes")) install.packages("remotes")
remotes::install_github("{{ gh_repo }}")
```

## Quick start

The examples below show the existing functionality; this is not currently planned to be developed further.

### An example with _finalsize_

Define an epidemic model scenario by creating a new `scenario` object. The standard workflow needs a model function, such as `finalsize::final_size()`, and appropriate arguments to the function.

```{r}
# load scenarios
library(scenarios)

# create a scenario for pandemic-potential influenza
# with finalsize::final_size() as the model function
scenario_pandemic_flu <- scenario(
model_function = "finalsize::final_size",
parameters = make_parameters_finalsize_UK(), # a helper function
replicates = 3
)
```

View a summary of the `scenario`.

```{r}
scenario_pandemic_flu
```

The `scenario` object is created but the model function is not initially run. This can be checked using a helper function. Tip: Many helper functions have the prefix `sce_` to help them be found quickly when using autocomplete in various text editors and IDEs.

```{r}
# check whether the scenario data have been generated
sce_has_data(scenario_pandemic_flu)
```

Model outcome data can be generated by running the model function with the parameters specified in the `scenario`.

```{r}
scenario_pandemic_flu <- run_scenario(scenario_pandemic_flu)
```

Take a peek at the column names in the model outcome replicates.

```{r}
sce_peek_outcomes(scenario_pandemic_flu)
```

Get the outcomes from all replicates as a single dataset, or aggregate an outcome variable of interest across replicates by some grouping variable.

```{r}
# get all output
head(sce_get_outcomes(scenario_pandemic_flu))

# aggregate proportion infected by demographic group
# NOTE that all replicates have the same outcome in this deterministic model
sce_aggregate_outcomes(
x = scenario_pandemic_flu,
grouping_variables = c("demo_grp"),
measure_variables = c("p_infected"),
summary_functions = c("mean", "min", "max")
)
```

### An example with _epidemics_

This example shows the same workflow applied to a simple, deterministic epidemic model from the _epidemics_ package.

```{r}
# create a new scenario
scenario_sir <- scenario(
model_function = "epidemics::sir_desolve",
parameters = make_parameters_SIR_epidemic(), # a helper function
replicates = 5L
)

# view the initial conditions and infection parameters
sce_get_information(scenario_sir, which = c("init", "parms"))

# generate scenario outcomes by running the model
scenario_sir <- run_scenario(scenario_sir)

# peek at the outcomes
sce_peek_outcomes(scenario_sir)

# view the aggregated outcomes
# this is the per-timestep, per-class (S, I, R) mean proportion
# and is the same across replicates in this deterministic model
tail(
sce_aggregate_outcomes(
scenario_sir,
grouping_variables = c("time", "state"),
measure_variables = "proportion",
summary_functions = "mean"
)
)
```

## Help

To report a bug please open an [issue](https://github.com/{{ gh_repo }}/issues/new/choose); please note that development on _{{ packagename }}_ has been suspended.

## Contribute

Development on _{{ packagename }}_ has been suspended.

However, use cases or requirements for a package that helps compare outcomes of epidemic scenario models are very welcome as issues, or on the main [Epiverse Discussion board](https://github.com/orgs/epiverse-trace/discussions).

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.