GithubHelp home page GithubHelp logo

chrism0dwk / wuhan Goto Github PK

View Code? Open in Web Editor NEW
74.0 17.0 19.0 1.28 MB

Modelling of the nCoV-2019 outbreak in Wuhan, China, by Jon Read, Jess Bridgen, and Chris Jewell at Lancaster University.

R 100.00%
2019-ncov wuhan coronavirus lancaster-university epidemic epidemic-model

wuhan's Introduction

Early analysis of Wuhan nCoV-2019 outbreak in Wuhan, China.

This R package implements an ODE-based model of the novel coronavirus outbreak in Wuhan, China. It presents a simulator and likelihood function assuming Poisson-distributed increments in the number of new cases in Wuhan, in the rest of China via the airline network, and to the rest of the world.

Data required:

  • china_cases daily case reports in all Chinese cities (see data(package='wuhan'))
  • world_cases daily case reports from other countries (see data(package='wuhan'))
  • K daily numbers of passengers going between cities in China via airline network, available from OAG Traffic Analyzer
  • W daily numbers of passengers going between Chinese cities and other countries via airline network, available from OAG Traffic Analyzer
  • china_population the population size in each Chinese city (see data(package='wuhan'))

Parameters:

  • beta the human-human basic transmission rate
  • gamma the removal rate (inverse of infectious period)
  • I0W the number of initial infectives in Wuhan
  • phi the case ascertainment rate in Wuhan

To use the package, assume the following workflow in R:

# Load required packages
> install.packages('devtools')
> devtools::install_git('https://github.com/chrism0dwk/wuhan.git')
> library(wuhan)

# Instantiate ODE model, simulate up to day 22.
> simulator = NetworkODEModel(N=china_population, K=K, init_loc='Wuhan', alpha=1/4, max_t=22) 

# Instantiate LogLikelihood function
> llik = LogLikelihood(y=china_cases[,1:22], z=world_cases[,1:22], N=N, K=K, W=W, sim_fun=simulator)

# Find MLEs using optimisation
> par_init = c(0.4, 0.142857142857143, 1, 0.5)  # Starting point
> fit = optim(log(par_init), llik, control=list(fnscale=-1))
> p_hat = fit$par

Asymptotic assumptions for confidence intervals fail in our case, since the parameter space is highly non-orthogonal. Confidence intervals are therefore calculated using parametric bootstrap. p_hat is calculated on the log scale (logit scale for the phi parameter), so needs to be transformed first:

> p_hat[1:3] = exp(p_hat[1:3])
> p_hat[4] = invlogit(p_hat[4])

The samples can then be drawn by bootstrap, for which a computing cluster is highly recommended (thanks Lancaster University HEC facility!).

> samples = bootstrap(p_hat, K, W, alpha=1/4, max_t=22, n_samples=1000)

Since the airline connectivity matrices are not included in this package, samples from the parameters (for 4 different values of the latent period $1/\alpha$) are provided as in-build datasets. See data(package='wuhan').

wuhan's People

Contributors

chrism0dwk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wuhan's Issues

for those who want to use its data

I don't know how the china_cases data were compiled, but at least the history for Wuhan is not accurate. for example, on day one (1/1/20), there is already 27 officially confirmed cases. but it is 0 in the rda file.

Typos in README.md

From: Luca Brugnolini [email protected]
Sent: 28 January 2020 13:27
To: Read, Jonathan [email protected]
Subject: RE: [External] Paper data Novel coronavirus 2019-nCov

Thanks a lot for the answer,

This is probably also the reason why I get an error with dimension mismatch using the package, as in the example max_t is set to 22 but china_cases.R and world_cases.R still contain 24 days – thus assertthat::assert_that(all(dim(y_prime) == dim(exp_incr_prime))) fails. While if I put 24 or reduce the dataset in the package it works.

Also, just to flag, in the example on github you have

> p_hat[1:3] = exp(p_hat[1:3])
> p_hat[4] = exp(p_hat[4])

However p_hat is a list containings also $value and $counts beside $par, so I believe this should be p_hat$par – as likely also in the bootstrap function, but I didn’t check that

> samples = bootstrap(p_hat, K, W, alpha=1/4, max_t=22, n_samples=1000)

Hope this may help,

Best

Luca

In the readme.rd

gamma: the infectious period
-> gamma: 1 / the infectious period

p_hat[4] = exp(p_hat[4])
-> p_hat[4] = invlogit(p_hat[4])

Error in rownames(K) : object 'K' not found

Hi sir,
I tried to run the package using your guide :

Load required packages

install.packages('devtools')
devtools::install_git('https://github.com/chrism0dwk/wuhan.git')
library(wuhan)

Instantiate ODE model, simulate up to day 22.

simulator = NetworkODEModel(N=china_population, K=K, init_loc='Wuhan', alpha=1/4, max_t=22)

Instantiate LogLikelihood function

llik = LogLikelihood(y=china_cases, z=world_cases, N=N, K=K, W=W, sim_fun=simulator)

Find MLEs using optimisation

p_hat = optim(log(par_init), llik, control=list(fnscale=-1))

However I met a problem:

p_hat = optim(log(par_init), llik, control=list(fnscale=-1))
Error in rownames(K) : object 'K' not found
In addition: Warning message:
In rownames(K) : restarting interrupted promise evaluation

Since I do not use R very much, I cannot find the bug. Could you please help me with that? I appreciate a lot.

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.