Home

Awesome

covid19model DOI

Code for modelling estimated deaths and infections for COVID-19 from "Estimating the effects of non-pharmaceutical interventions on COVID-19 in Europe", Flaxman, Mishra, Gandy et al, Nature, 2020, the published version of our original Report 13.

If you are looking for the individual based model used in Imperial's Report 9, Ferguson, Laydon, Nedjati-Gilani et al, please look here.

Version 12 Release DOI

This is the release related to our Tiers paper, where we use latent factor model to estimate the effectiveness of tiers systems in England. Peer reviewed version to be out soon. All other code is still the same for previous releases.

To reproduce results of the paper either from Rstudio source("tiers/spline_LFA.R") or from the command line Rscript tiers/spline_LFA.R.

The instructions for reproducing European report , Italy report , Brazil report , USA report , Nature, IFR, USA age specific report, Nature Communincations, and Science paper are the same as earlier (Look at version 3, version 4, version 5, version 6, version 7, version 8, version 9, version 10 and version 11). This release is specific to Tiers paper.

This release has been checked on macOS Catalina version 10.15.6/7 and Ubuntu version 18.04.2.

The authors of version 12 Release are Daniel J Laydon, Swapnil Mishra, and Samir Bhatt

Version 11 Release DOI

This is the release related to our Science paper, where we use age-specific mobility data to estimate the epidemic in the USA by accounting for age-specific heterogeneity. All other code is still the same for previous releases.

To run this code you need to follow the steps listed in the age-specific model here.

The code should be run in full mode to obtain credible results. Not running a full run to estimate anything is not recommended and discouraged. Only a full run should be used to get results.

The instructions for reproducing European report , Italy report , Brazil report , USA report , Nature, IFR, USA age specific report and Nature Communincations are the same as earlier (Look at version 3, version 4, version 5, version 6, version 7, version 8, version 9 and version 10). This release is specific to Science paper.

This release has been checked on macOS Catalina version 10.15.6/7 and Ubuntu version 18.04.2.

The authors of version 11 Release are Melodie Monod, Alexandra Blenkinsop, Xiaoyue Xi, H Juliette Unwin, Swapnil Mishra, Oliver Ratmann"

Version 10 Release DOI

This is the release related to Unwin, H.J.T., Mishra, S., Bradley, V.C. et al. State-level tracking of COVID-19 in the United States. Nat Commun 11, 6189 (2020). https://doi.org/10.1038/s41467-020-19652-6, where we use mobility data to estimate situation in all states of the USA. All other code is still the same.

To run this code you can directly run the base-usa.r file or from command line after seting the current directory as the repository directory run the following command Rscript base-usa-cases.r

The code should be run in full mode to obtain credible results. Not running a full run to estimate anything is not recommended and discouraged. Only a full run should be used to get results.

The instructions for European, Italy, Brazil, USA, Nature, IFR, USA age-specific code are the same as earlier (Look at version 3, version 4, version 5, version 6, version 7, version 8, and version 9). This release is specific to [ usa-paper (soon to be out) and medRxiv paper.

This release has been checked on macOS Catalina version 10.15.6/7 and Ubuntu version 18.04.2.

Version 9 Release DOI

This is the release related to report 32 and medRxiv paper, where we use age-specific mobility data to estimate the epidemic in the USA by accounting for age-specific heterogeneity. All other code is still the same for previous releases.

To run this code you need to follow the steps listed in the age-specific model here.

The code should be run in full mode to obtain credible results. Not running a full run to estimate anything is not recommended and discouraged. Only a full run should be used to get results.

The instructions for European, Italy, Brazil, USA, Nature, and IFR code are the same as earlier (Look at version 3, version 4, version 5, version 6, version 7, and version 8). This release is specific to report 32.

This release has been checked on macOS Catalina version 10.15.6/7 and Ubuntu version 18.04.2.

Version 8 Release DOI

The code for running models remains unchanged in the release. We provide scripts to calculate ifr for European countries and USA states. We hope the release of ifr computation code will enable the researchers to adapt the ifr calculations as per their requirements. The two files to run are compute-ifr-europe.r and compute-ifr-usa.r.

The code for ifr calculation for a new country will need changes if you have different age-specific bands. The code provided is not a universal code that will work for each country, the intention is to help researchers to modify the code easily for their setup.

The code for ifr needs an additional package named socialmixr, which is not specified in environment file as it doesn't exist with conda. You will need to download it via CRAN.

Version 7 Release DOI

This code is the exact code that was used in Flaxman, Mishra, Gandy et al. "Estimating the effects of non-pharmaceutical interventions on COVID-19 in Europe," Nature, 2020. https://www.nature.com/articles/s41586-020-2405-7

To run the code from the main folder in Rstudio source("base-nature.r") or from the command line Rscript base-nature.r.

The code should be run in full mode to obtain results---debug mode is only to check that your environment has the required libraries; results will not be reliable as the MCMC chains will not have converged.

The repository with posterior draws of the model in Flaxman, Mishra, Gandy et al. "Estimating the effects of non-pharmaceutical interventions on COVID-19 in Europe," Nature, 2020. https://www.nature.com/articles/s41586-020-2405-7 is here.

This code doesn't supersede our earlier model, it is here for everyone to have direct access to code used in Flaxman, Mishra, Gandy et al. "Estimating the effects of non-pharmaceutical interventions on COVID-19 in Europe," Nature, 2020.https://www.nature.com/articles/s41586-020-2405-7.

The instructions for European, Italy, Brazil, and USA code are the same as earlier (Look at version 3, version 4, version 5, version 6).

Version 6 Release

This is the release related to report 23, where we use mobility data to estimate situation in all states of the USA. All other code is still the same.

To run this code you can directly run the base-usa.r file or from command line after seting the current directory as the repository directory run the following command Rscript base-usa.r

The code should be run in full mode to obtain any results. Not running full model to estimate anything is not recommended and discouraged. Only full run should be used to get results.

The instructions for European, Italy and Brazil code are same as earlier (Look at version 3, version 4 and version 5). This release is specific to USA report.

This release has been checked on macOS Catalina version 10.15.6 and Ubuntu version 18.04.2. A full run takes about 20 hours using 4 cores.

Version 5 Release

This is the release related to report 21, where we use mobility data to estimate situation in Brazil. All other code is still the same.

To run this code you can directly run the base-Brazil.r file or from command line after seting the current directory as the repository directory run the following command Rscript base-Brazil.r

The code shold be run in full mode to obtain any results. Not running full model to estimate anything is not recommended and discouraged. Only full run should be used to get results.

The instructions for European and Italy code are same as earlier (Look at version 3 and version 4). This release is specific to Brazil report

Version 4 Release

This is the release related to report 20, where we use mobility data to estimate situation in Italy. All other code is still the same.

To run this code you can directly source the base-italy.r file in rstudio inside the project or from command line after setting the current directory as the repository directory run the following command Rscript base-italy.r base-italy google interventions '~ -1 + residential + transit + averageMobility' '~ -1 + residential + transit + averageMobility'

The code for scenarios runs only in full mode not in short run or debug mode. Not running full model to estimate anything is not recommended and discouraged. Only full run should be used to get results.

The instructions for European code are below. This release is specific to Italy report

Version 3 Release

In this update, we first extended our model from version 2 to have 'partial-pooling' for lockdown across all countries. This means now we have a global effect of lockdown along with each country having its own different lockdown effect. We also made our code modular, stan code faster (with help from the community) and now we create CSV outputs too for usage.

You can directly get csv files here and new model description here

Notice

:warning: Python code is right now not updated and won't work. Python code is good for only version 1 model and data.

:warning: base_general.r and base_general.stan, base_general_speed.stan and base_general_speed2.stan are now valid models for only version2

:warning: This code is released with no support. We try our best to look at issues and pull request but can't help people with setup most of the time. We have docker images and conda environment file to make it easy for you to get started with the setup, any other approach assumes user can handle their computing environments approriately.

:warning: This model is in active development and so parameter name and behaviours, and output file formats will change without notice.

:warning: As with any mathematical model, it is easy to misconfigure inputs and therefore get meaningless outputs. The development team only endorses outputs it has itself generated.

Version 2 Release

In this update we extend our original model to include (a) population saturation effects, (b) prior uncertainty on the infection fatality ratio and (c) a more balanced prior on intervention effects. We also (d) included another 3 countries (Greece, the Netherlands and Portugal). The updated technical detail is available here.

You can directly look at our results here

This repository has code for replication purposes. The bleeding edge code and advancements are done in a private repository. Ask report authors for any collaborations.

Contributing

We welcome all potential collaborators and contributors from the wider community. Please see contributing for more details.

Installing dependencies

Using Conda

An environment.yml file is provided and can be used to build a virtual environment containing all model dependencies. Create the environment using:

conda env create -f environment.yml

Then activate the environment for use:

conda activate covid19model

This does not include the packages required for plotting maps. The following packages are required:

library(ggplot2)
library(ggstance)
library(ggrepel)
library(cowplot)
library(geofacet)
library(broom)
library(maptools)
library(rgeos)
library(rgdal)
library(colorspace)
library(sf)
library(scales)
library(bayesplot)
library(matrixStats)
library(boot)
library(lubridate)

Using Docker

A Docker image providing all model dependencies is available. See docker/README.md for details of running the model with Docker.

Other

If you wish to install packages into your native R environment or with a system package manager please see environment.yml for a full list of dependencies.

How to run the code

There are two ways to run our code:-

Please note to not make you wait for long we have by default set run sampling to a short period. For proper estimates please run it in FULL mode either by setting the flag --full or the environment variable FULL=TRUE. This will run sampling for 4000 iterations with 2000 warmups and 4 chains. The run time for 14 countries using new faster code is around 50 mins/1hr for the version 3 code.

Run mode settings

Three different run modes are supported:

Results