Coder Social home page Coder Social logo

covoid's Introduction

COVID-19 Open-source Infection Dynamics (COVOID)

R build status

eRum2020::CovidR

COVOID is a R package for modelling COVID-19 and other infectious diseases using deterministic compartmental models (DCMs). It contains a built-in Shiny app enabling easy use and demonstration of key concepts to those without R programming backgrounds, along with an expanding API for simulating and estimating homogeneous and age-structured SIR, SEIR and extended models. In particular COVOID allows the simultaneous simulation of age specific (e.g. school closures) and general interventions over varying time intervals.

Acknowledgements

Work on COVOID is facilitated by the generous assistance of Ian Sharp, philanthropic supporter of UNSW research.

If you would like to support our work, please click on the Sponsor button at the top of this page for details of how to donate.

Modelling COVID-19

For information on installing COVOID and a basic illustrating of the programming API keep reading, or visit the COVOID website for more information. Click here to use the interactive Shiny platform.

Installation

You can install the development version of COVOID from GitHub with:

# install.packages("devtools")
devtools::install_github("cbdrh/covoid",build_vignettes = TRUE)

Example

This is a basic introduction to COVOID package syntax. We demonstrate how to simulate an epidemic along with the impact of disease prevention policies using an age structured SIR model. The populations demographics are matched to that of Australia, with a population of 4 million and 10 initial cases. The functions import_contact_matrix and import_age_distribution import data from Prem et al (2017) and the United Nations Population Division (2019) on age specific contact rates and distributions, both grouped by 5 years. There are ~150 countries with both contact and age demographic information available in COVOID.

library(covoid)
cm_oz <- import_contact_matrix("Australia","general")
p_age_oz <- import_age_distribution("Australia")
# initial conditions
S <- p_age_oz*4e6
I <- c(0,0,0,0,5,3,1,2,0,0,0,0)
R <- rep(0,length(S))

We first consider the case without any interventions, in which the epidemic runs its course. The sir_c_param takes uses the basic reproduction number R0 and the inverse of the average disease length gamma to parameterise the system of ODEs, and infer other parameters such the probability of disease transmission.

param <- sir_c_param(R0 = 2.5,gamma = 0.1,cm=cm_oz,dist=p_age_oz)
state0 <- sir_c_state0(S0 = S0,I0 = I0,R0 = R0)
res <- simulate_sir_c(t = 200,state_t0 = state0,param = param)
plot(res,y=c("S","I","R"),main="No intervention")

We can add in time varying interventions that reduce contact rates across the population using create_contact_intervention. The below example reduces all physical contact by 20% in order to simulate physical distancing.

phys_dist <- contact_intervention(start = 10,stop = 150,reduce = 0.8,start_delay = 5,stop_delay = 5)
param <- sir_c_param(R0 = 2.5,gamma = 0.1,cm=cm_oz,dist=p_age_oz,contact_intervention = phys_dist)
state0 <- sir_c_state0(S0 = S0,I0 = I0,R0 = R0)
res <- simulate_sir_c(t = 200,state_t0 = state0,param = param)
plot(res,y=c("S","I","R"),main="Physical distancing")

The COVOID package also allows you to separate the contact rates into different settings - e.g. school, work and home.

cm_oz_all <- import_contact_matrix("Australia","general")
cm_oz_sch <- import_contact_matrix("Australia","school")
# separate out school and general population contact rates
cm_oz_all <- cm_oz_all - cm_oz_sch
p_all <- plot(cm_oz_all) + labs(title = "General") +
  theme(axis.text.x = element_text(size=6, angle=0),
          axis.text.y = element_text(size=6))
p_sch <- plot(cm_oz_sch) + labs(title = "School") +
  theme(axis.text.x = element_text(size=6, angle=0),
          axis.text.y = element_text(size=6))
gridExtra::grid.arrange(p_all,p_sch,ncol=2)

We can then add in time varying interventions using create_intervention to each setting. The below example reduces general contact by 20% to simulate physical distancing combined with a reduction in school age contact by 80% to simulate school closures.

cm <- list(all = cm_oz_all, sch = cm_oz_sch)
int <- list(sch=contact_intervention(start = 10,stop = 150,reduce = 0.2,start_delay = 5,stop_delay = 5),
           all=contact_intervention(start = 10,stop = 150,reduce = 0.8,start_delay = 5,stop_delay = 5))
param <- sir_c_param(R0 = 2.5,gamma = 0.1,cm=cm,dist=p_age_oz,contact_intervention = int)
state0 <- sir_c_state0(S0 = S0,I0 = I0,R0 = R0)
res <- simulate_sir_c(t = 200,state_t0 = state0,param = param)
plot(res,y=c("S","I","R"),main="Physical distancing + school closures")

For more information check out the package vignettes (below) or visit the COVOID website

# A description of the models available in COVOID:
vignette("available-models")

# An instroduction to modelling epidemics and the impact of their 
# interventions using age structured DCMs:
vignette("age-structured-mixing")

# An overview of the mathematical background of age structured DCMs, 
# with links to more further reading: 
vignette("age-structured-mixing-background")

References

Prem, K., Cook, A. R., & Jit, M. (2017). Projecting social contact matrices in 152 countries using contact surveys and demographic data. PLoS computational biology, 13(9), e1005697.

United Nations, Department of Economic and Social Affairs, Population Division (2019). World Population Prospects 2019, Online Edition. Rev. 1.

covoid's People

Contributors

oizin avatar markhanly avatar timchurches avatar handcock avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.