Science Score: 57.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 2 DOI reference(s) in README -
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.2%) to scientific vocabulary
Last synced: 6 months ago
·
JSON representation
·
Repository
Simulating epidemics and interventions
Basic Info
- Host: GitHub
- Owner: WHO-Collaboratory
- License: mit
- Language: R
- Default Branch: main
- Size: 8.07 MB
Statistics
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
- Releases: 0
Created almost 2 years ago
· Last pushed 8 months ago
Metadata Files
Readme
License
Citation
README.Rmd
*simex*: a disease modelling tool for decision makers
---------------------------------------------------------------
[](https://github.com/epiforecasts/EpiNow2/blob/main/LICENSE.md/) [](https://lifecycle.r-lib.org/articles/stages.html#maturing)
*simex* is an R package for simulating the spread of infectious diseases, as well as interventions such as social distancing measures, isolation and vaccination. It uses an age-structured SEIR compartmental model with country-specific age demographics and contact rates. The simplest way to interact with the tool is to use the [Shiny App](https://portal.who.int/eios-colab/rconnect/simex).
```{r, echo = FALSE}
knitr::opts_chunk$set(fig.cap = "",
fig.align = "center",
fig.path = "man/figures"
dpi = 200,
out.width = "75%")
```
Installation
-------------
To install the development version from github:
```{r, eval = FALSE}
remotes::install_github("WHO-Collaboratory/simex")
```
Load the package using:
```{r}
library("simex")
```
Running *simex*
-------------
### Shiny App
You can use *simex* interactively by launching the shiny app locally with `simex::run_shiny()`. If you want to use it programmatically, follow the steps below.
### Parameters and settings
Most settings are specified via the `get_parameters` function. The arguments and
their default values are given below:
```{r, echo = FALSE}
simex:::get_arg_table("get_parameters", type = "kable")
```
### Running default settings
To run the model using default settings, specify a parameter object `par` and feed this into the `run_model` function.
```{r, echo = TRUE}
## set parameters using defaults
pars <- get_parameters()
## run model using default parameters
output <- run_model(pars)
## look at output
print(output)
```
### Visualising outputs
To visualise the results, use the generic `plot` function defined for the `simex` class. Below, we first visualise prevalence and then incidence, specified using the `what` argument.
```{r, echo = TRUE}
## visualise prevalence
plot(output, what = "prevalence")
## visualise incidence
plot(output, what = "incidence")
```
Hospital capacity can be displayed by toggling the `show_hosp_capacity` argument.
```{r, echo = TRUE}
## visualise prevalence with hospital capaciy
plot(output, what = "prevalence", show_hosp_capacity = TRUE)
```
### Summarising outputs
To get a summary of the model state at a given point in time, use the `summary` function with the optional `day` argument. In the example below, we display the summary statistics for day 150:
```{r, eval = FALSE}
## get summary at day 150
summary(output, day = 150)
```
```{r, echo = FALSE}
## kable for Rmd
knitr::kable(summary(output, day = 150))
```
### Accessing outputs
The `output` object is of class `simex` and is a list containing four items:
* `prevalence` is an array with 3 dimensions: time (365 days) x age (16
categories) x state (12 compartments). The compartments are S (susceptible), E
(exposed, pre-symptomatic), C (symptomatic in community), H (sympomatic in
hospital), R (recovered), D (dead). Each comparment is split into unvaccinated
(with subscript _u) and vaccinated (with subscript _v). Each value in the
array represents the proportion of the population in that given age-disease
compartment on a given day.
* `deltas` is an array with the same dimensions as `prevalence`. Each value
represents the change in a given age-disease compartment from the previous
day.
* `incidence` is an array with the same dimensions as `prevalence`. Each value
represents the new additions to a given age-disease comparment on a given
day. For the exposed category E, this represents incidence of new infections,
for the hospitalised category H this represents new hospital admissions, and
for the dead category D this represents new deaths.
* `pars` contains the parameter set initially fed into `run_model`.
Accessing the data is easiest using array indexing. Remember, the dimensions are
time, age and compartment. For example, accessing the prevalence on the 250th
day is done with `output$prevalence[250,,]`:
```{r, echo = FALSE}
## extract prevalence in percent on day 250
round(100*output$prevalence[250,,], 1)
```
Accessing the prevalence of the 1st age compartment (0-4) and 1st infectious
compartment (unvaccinated susceptible) for days 130 to 135 is done with
`output$prevalence[130:135,1,1]`:
```{r, echo = FALSE}
## extract in percent on day 130-135
round(100*output$prevalence[130:135,1,1], 1)
```
The outputs can also be extracted in `tibble` form using the `extract` function,
once again using the `what` argument to specify whether prevalence or incidence
is extracted.
```{r, echo = TRUE}
## extract prevalence
extract(output, what = "prevalence")
```
If we want to filter this list for a sequence of days, we can then do basic
dataframe manipulation:
```{r, echo = TRUE}
## define start and end days
days_from <- 10
days_to <- 20
## extract prevalence
df <- extract(output, what = "prevalence")
df <- df[df$day %in% seq(days_from, days_to),]
df
```
### Modelling a single intervention
We use vaccination as an example intervention. Referencing the table above, we
can see that vaccination rate is specified using the `vax_rate` argument and
set it to 0.5% of the population per day.
```{r, echo = TRUE}
## define vaccination rate
pars <- get_parameters(vax_rate = 0.005)
## run model
output <- run_model(pars)
## visualise prevalence
plot(output)
```
We can see that the daily increase in number of vaccinated individuals, as
well as the impact on infection and disease severity.
### Specifying an initial state
The default initial state begins with an entirely susceptible, unvaccinated
population and a single infection. We can also specify a custom initial state by
passing a matrix specifying the number of individuals in each age-infection
compartment. In the example below, we extract the initial state from the
previous run, and modify the compartments so half the susceptible population is
assigned to the vaccinated compartment.
```{r, echo = TRUE}
## extract starting point from previous run
state <- output$prevalence[1,,]
## assign half of susceptibles to vaccinated
state[,"S_u"] <- state[,"S_v"] <- state[,"S_u"]/2
## run model
output <- run_model(pars, init_state = state)
## visualise prevalence
plot(output)
```
We can see that the simulation now begins with a 50% vaccinated population,
significantly reducing the size and impact of the pandemic.
### Timed interventions, multiple interventions
Sometime we only want to introduce interventions at a certain time, or we want
to model multiple, successive interventions. We can do this easily by generating
a named list of parameters, where the name gives the time that parameter set
should be used from. In the example below, we introduce isolation measures with
an adherence of 50% on the 125th day.
```{r, echo = TRUE}
## introduce isolation on the 125th day
parlist <- list(
"1" = get_parameters(),
"125" = get_parameters(isolation_adherence = 0.5)
)
## run model
output <- run_model(parlist)
## visualise prevalence
plot(output)
```
Comparing this figure with the first model run with no interventions, we can see
the proportion of deaths drops from about 0.7% to 0.4%; a reduction in deaths of
more than 40%!
### Comparing scenarios
It is useful to directly compare different scenarios visually. The
`vis_comarison` function does exactly this, and accepts a named list of `simex`
objects. In the example below, we generate a named list of lists that compares
the default scenario (no interventions) with the a scenario where isolation is
introduced on the 125th day.
```{r, echo = TRUE}
## define two scenarios, one without intervention and one with isolation
parlists <- list(
"No intervention" = get_parameters(),
"Isolation on day 125" = list(
"1" = get_parameters(),
"125" = get_parameters(isolation_adherence = 0.5)
)
)
## run model across set of parameter lists
outputs <- lapply(parlists, run_model)
## compare scenarios
vis_comparison(outputs)
```
### Contributors
------------
- [Finlay Campbell](https://github.com/finlaycampbell) (campbellf@who.int)
- Prabasaj Paul (ppaul@who.int)
**Maintainer:** Finlay Campbell
### Licensing
The simex software is made available by Collaboratory (2024) under an [MIT license](LICENSE.md) ([citation file](CITATION.cff)).
The demographic data used in this software is made available by United Nations (2024) under a [Creative Commons license CC BY 3.0 IGO](http://creativecommons.org/licenses/by/3.0/igo/). Source:
> United Nations, Department of Economic and Social Affairs, Population Division (2024). [World Population Prospects 2024, Online Edition](https://population.un.org/wpp/).
The contact data used in this software is made available by Prem et al. (2017) under a [Creative Commons license CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Source:
> Kiesha Prem, Alex R. Cook, Mark Jit, *Projecting social contact matrices in 152 countries using contact surveys and demographic data*, PLoS Comp. Biol. (2017), https://doi.org/10.1371/journal.pcbi.1005697.
Owner
- Name: WHO-Collaboratory
- Login: WHO-Collaboratory
- Kind: organization
- Repositories: 1
- Profile: https://github.com/WHO-Collaboratory
Citation (CITATION.cff)
# --------------------------------------------
# CITATION file created with {cffr} R package
# See also: https://docs.ropensci.org/cffr/
# --------------------------------------------
cff-version: 1.2.0
message: 'To cite package "simex" in publications use:'
type: software
license: MIT
title: 'simex: Simulating epidemics and interventions'
version: 1.0.0.0000
doi: 10.32614/CRAN.package.simex
abstract: Simulate epidemics and interventions using country-specific contact rates
and age demographics.
authors:
- family-names: Campbell
given-names: Finlay
email: campbellf@who.int
- family-names: Paul
given-names: Prabasaj
email: ppaul@who.int
repository: https://github.com/WHO-Collaboratory/simex
contact:
- family-names: Campbell
given-names: Finlay
email: campbellf@who.int
references:
- type: software
title: 'R: A Language and Environment for Statistical Computing'
notes: Depends
url: https://www.R-project.org/
authors:
- name: R Core Team
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2024'
version: '>= 2.10'
- type: software
title: countrycode
abstract: 'countrycode: Convert Country Names and Country Codes'
notes: Suggests
url: https://vincentarelbundock.github.io/countrycode/
repository: https://CRAN.R-project.org/package=countrycode
authors:
- family-names: Arel-Bundock
given-names: Vincent
email: vincent.arel-bundock@umontreal.ca
orcid: https://orcid.org/0000-0003-2042-7063
year: '2024'
doi: 10.32614/CRAN.package.countrycode
- type: software
title: readxl
abstract: 'readxl: Read Excel Files'
notes: Suggests
url: https://readxl.tidyverse.org
repository: https://CRAN.R-project.org/package=readxl
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
orcid: https://orcid.org/0000-0003-4757-117X
- family-names: Bryan
given-names: Jennifer
email: jenny@posit.co
orcid: https://orcid.org/0000-0002-6983-2759
year: '2024'
doi: 10.32614/CRAN.package.readxl
- type: software
title: usethis
abstract: 'usethis: Automate Package and Project Setup'
notes: Suggests
url: https://usethis.r-lib.org
repository: https://CRAN.R-project.org/package=usethis
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
orcid: https://orcid.org/0000-0003-4757-117X
- family-names: Bryan
given-names: Jennifer
email: jenny@posit.co
orcid: https://orcid.org/0000-0002-6983-2759
- family-names: Barrett
given-names: Malcolm
email: malcolmbarrett@gmail.com
orcid: https://orcid.org/0000-0003-0299-5825
- family-names: Teucher
given-names: Andy
email: andy.teucher@posit.co
orcid: https://orcid.org/0000-0002-7840-692X
year: '2024'
doi: 10.32614/CRAN.package.usethis
- type: software
title: gt
abstract: 'gt: Easily Create Presentation-Ready Display Tables'
notes: Suggests
url: https://gt.rstudio.com
repository: https://CRAN.R-project.org/package=gt
authors:
- family-names: Iannone
given-names: Richard
email: rich@posit.co
orcid: https://orcid.org/0000-0003-3925-190X
- family-names: Cheng
given-names: Joe
email: joe@posit.co
- family-names: Schloerke
given-names: Barret
email: barret@posit.co
orcid: https://orcid.org/0000-0001-9986-114X
- family-names: Hughes
given-names: Ellis
email: ellis.h.hughes@gsk.com
orcid: https://orcid.org/0000-0003-0637-4436
- family-names: Lauer
given-names: Alexandra
email: alexandralauer1@gmail.com
orcid: https://orcid.org/0000-0002-4191-6301
- family-names: Seo
given-names: JooYoung
email: jseo1005@illinois.edu
orcid: https://orcid.org/0000-0002-4064-6012
year: '2024'
doi: 10.32614/CRAN.package.gt
- type: software
title: knitr
abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R'
notes: Suggests
url: https://yihui.org/knitr/
repository: https://CRAN.R-project.org/package=knitr
authors:
- family-names: Xie
given-names: Yihui
email: xie@yihui.name
orcid: https://orcid.org/0000-0003-0645-5666
year: '2024'
doi: 10.32614/CRAN.package.knitr
- type: software
title: dplyr
abstract: 'dplyr: A Grammar of Data Manipulation'
notes: Imports
url: https://dplyr.tidyverse.org
repository: https://CRAN.R-project.org/package=dplyr
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
orcid: https://orcid.org/0000-0003-4757-117X
- family-names: François
given-names: Romain
orcid: https://orcid.org/0000-0002-2444-4226
- family-names: Henry
given-names: Lionel
- family-names: Müller
given-names: Kirill
orcid: https://orcid.org/0000-0002-1416-3412
- family-names: Vaughan
given-names: Davis
email: davis@posit.co
orcid: https://orcid.org/0000-0003-4777-038X
year: '2024'
doi: 10.32614/CRAN.package.dplyr
- type: software
title: ggplot2
abstract: 'ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics'
notes: Imports
url: https://ggplot2.tidyverse.org
repository: https://CRAN.R-project.org/package=ggplot2
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
orcid: https://orcid.org/0000-0003-4757-117X
- family-names: Chang
given-names: Winston
orcid: https://orcid.org/0000-0002-1576-2126
- family-names: Henry
given-names: Lionel
- family-names: Pedersen
given-names: Thomas Lin
email: thomas.pedersen@posit.co
orcid: https://orcid.org/0000-0002-5147-4711
- family-names: Takahashi
given-names: Kohske
- family-names: Wilke
given-names: Claus
orcid: https://orcid.org/0000-0002-7470-9261
- family-names: Woo
given-names: Kara
orcid: https://orcid.org/0000-0002-5125-4188
- family-names: Yutani
given-names: Hiroaki
orcid: https://orcid.org/0000-0002-3385-7233
- family-names: Dunnington
given-names: Dewey
orcid: https://orcid.org/0000-0002-9415-4582
- family-names: Brand
given-names: Teun
name-particle: van den
orcid: https://orcid.org/0000-0002-9335-7468
year: '2024'
doi: 10.32614/CRAN.package.ggplot2
- type: software
title: magrittr
abstract: 'magrittr: A Forward-Pipe Operator for R'
notes: Imports
url: https://magrittr.tidyverse.org
repository: https://CRAN.R-project.org/package=magrittr
authors:
- family-names: Bache
given-names: Stefan Milton
email: stefan@stefanbache.dk
- family-names: Wickham
given-names: Hadley
email: hadley@rstudio.com
year: '2024'
doi: 10.32614/CRAN.package.magrittr
- type: software
title: purrr
abstract: 'purrr: Functional Programming Tools'
notes: Imports
url: https://purrr.tidyverse.org/
repository: https://CRAN.R-project.org/package=purrr
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@rstudio.com
orcid: https://orcid.org/0000-0003-4757-117X
- family-names: Henry
given-names: Lionel
email: lionel@rstudio.com
year: '2024'
doi: 10.32614/CRAN.package.purrr
- type: software
title: abind
abstract: 'abind: Combine Multidimensional Arrays'
notes: Imports
repository: https://CRAN.R-project.org/package=abind
authors:
- family-names: Plate
given-names: Tony
email: tplate@acm.org
- family-names: Heiberger
given-names: Richard
year: '2024'
doi: 10.32614/CRAN.package.abind
- type: software
title: forcats
abstract: 'forcats: Tools for Working with Categorical Variables (Factors)'
notes: Imports
url: https://forcats.tidyverse.org/
repository: https://CRAN.R-project.org/package=forcats
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@rstudio.com
year: '2024'
doi: 10.32614/CRAN.package.forcats
- type: software
title: scales
abstract: 'scales: Scale Functions for Visualization'
notes: Imports
url: https://scales.r-lib.org
repository: https://CRAN.R-project.org/package=scales
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
- family-names: Pedersen
given-names: Thomas Lin
email: thomas.pedersen@posit.co
orcid: https://orcid.org/0000-0002-5147-4711
- family-names: Seidel
given-names: Dana
year: '2024'
doi: 10.32614/CRAN.package.scales
- type: software
title: stats
abstract: 'R: A Language and Environment for Statistical Computing'
notes: Imports
authors:
- name: R Core Team
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2024'
doi: 10.32614/CRAN.package.stats
- type: software
title: stringr
abstract: 'stringr: Simple, Consistent Wrappers for Common String Operations'
notes: Imports
url: https://stringr.tidyverse.org
repository: https://CRAN.R-project.org/package=stringr
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
year: '2024'
doi: 10.32614/CRAN.package.stringr
- type: software
title: tidyr
abstract: 'tidyr: Tidy Messy Data'
notes: Imports
url: https://tidyr.tidyverse.org
repository: https://CRAN.R-project.org/package=tidyr
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@posit.co
- family-names: Vaughan
given-names: Davis
email: davis@posit.co
- family-names: Girlich
given-names: Maximilian
year: '2024'
doi: 10.32614/CRAN.package.tidyr
- type: software
title: deSolve
abstract: 'deSolve: Solvers for Initial Value Problems of Differential Equations
(''ODE'', ''DAE'', ''DDE'')'
notes: Imports
url: http://desolve.r-forge.r-project.org/
repository: https://CRAN.R-project.org/package=deSolve
authors:
- family-names: Soetaert
given-names: Karline
email: karline.soetaert@nioz.nl
orcid: https://orcid.org/0000-0003-4603-7100
- family-names: Petzoldt
given-names: Thomas
email: thomas.petzoldt@tu-dresden.de
orcid: https://orcid.org/0000-0002-4951-6468
- family-names: Setzer
given-names: R. Woodrow
email: setzer.woodrow@epa.gov
orcid: https://orcid.org/0000-0002-6709-9186
year: '2024'
doi: 10.32614/CRAN.package.deSolve
- type: software
title: shiny
abstract: 'shiny: Web Application Framework for R'
notes: Imports
url: https://shiny.posit.co/
repository: https://CRAN.R-project.org/package=shiny
authors:
- family-names: Chang
given-names: Winston
email: winston@posit.co
orcid: https://orcid.org/0000-0002-1576-2126
- family-names: Cheng
given-names: Joe
email: joe@posit.co
- family-names: Allaire
given-names: JJ
email: jj@posit.co
- family-names: Sievert
given-names: Carson
email: carson@posit.co
orcid: https://orcid.org/0000-0002-4958-2844
- family-names: Schloerke
given-names: Barret
email: barret@posit.co
orcid: https://orcid.org/0000-0001-9986-114X
- family-names: Xie
given-names: Yihui
email: yihui@posit.co
- family-names: Allen
given-names: Jeff
- family-names: McPherson
given-names: Jonathan
email: jonathan@posit.co
- family-names: Dipert
given-names: Alan
- family-names: Borges
given-names: Barbara
year: '2024'
doi: 10.32614/CRAN.package.shiny
- type: software
title: shinyjs
abstract: 'shinyjs: Easily Improve the User Experience of Your Shiny Apps in Seconds'
notes: Imports
url: https://deanattali.com/shinyjs/
repository: https://CRAN.R-project.org/package=shinyjs
authors:
- family-names: Attali
given-names: Dean
email: daattali@gmail.com
orcid: https://orcid.org/0000-0002-5645-3493
year: '2024'
doi: 10.32614/CRAN.package.shinyjs
- type: software
title: shinyMatrix
abstract: 'shinyMatrix: Shiny Matrix Input Field'
notes: Imports
repository: https://CRAN.R-project.org/package=shinyMatrix
authors:
- family-names: Neudecker
given-names: Andreas
year: '2024'
doi: 10.32614/CRAN.package.shinyMatrix
- type: software
title: shinyWidgets
abstract: 'shinyWidgets: Custom Inputs Widgets for Shiny'
notes: Imports
url: https://dreamrs.github.io/shinyWidgets/
repository: https://CRAN.R-project.org/package=shinyWidgets
authors:
- family-names: Perrier
given-names: Victor
email: victor.perrier@dreamrs.fr
- family-names: Meyer
given-names: Fanny
- family-names: Granjon
given-names: David
year: '2024'
doi: 10.32614/CRAN.package.shinyWidgets
- type: software
title: gbRd
abstract: 'gbRd: Utilities for processing Rd objects and files'
notes: Imports
repository: https://CRAN.R-project.org/package=gbRd
authors:
- family-names: Boshnakov
given-names: Georgi N.
year: '2024'
doi: 10.32614/CRAN.package.gbRd
GitHub Events
Total
- Watch event: 3
- Delete event: 1
- Push event: 4
Last Year
- Watch event: 3
- Delete event: 1
- Push event: 4
Dependencies
DESCRIPTION
cran
- R >= 2.10 depends
- abind * imports
- dplyr * imports
- forcats * imports
- ggplot2 * imports
- magrittr * imports
- purrr * imports
- scales * imports
- stats * imports
- stringr * imports
- countrycode * suggests
- gbRd * suggests
- gt * suggests
- knitr * suggests
- readxl * suggests
- usethis * suggests