Giter Club home page Giter Club logo

coronavirus's Introduction

SIR, SEIR and SEIRt modeling and inversion

The coronavirus (COVID-19) struck planet Earth in early 2020, just after immense wild-fires burned in Australia, and a possible US-Iran armed conflict seemed imminent. It had been quite a year so far.

The entire planet went into quarantine. First for two weeks, then for a month, then ...

Can we estimate ahead of time how long we are to be locked down?

Moreover, can we make this estimate based only on observed data?

Go to Examples below if you're not into reading.

By early April, for the US and Europe, the data, the model, the inversion and the cut-off criteria suggest late April - early May.

The picture below are estimated with data from mid April.

The SIR, SEIR and SEIRt models

These models attempt to capture the time-dependent dynamics of a population interacting with a virus.

The model-state variables, for example, are infected, recovered, dead, susceptible, quarantined, etc.

The parameters that dictate these time-dependent dynamics are, for example, infection rate, protection rate, cure rate, mortality, etc.

I used the SIR model as given here.

The SEIR model is as given by [1], although this one does not assume time dependency of any parameter.

The SEIRt model is as given by [1], with time dependency of some parameters.

The SIR, SEIR and SEIRt inversions

How long will we be locked up in quarantine?

Given the data of infected, recovered and dead - can we make an estimate on how the total population will behave in the future?

To answer this question we need to know the model parameters: infection rate, protection rate, cure rate, mortality, etc.

This package attempts to do just that using the adjoint method. The entire inversion routine is built from scratch.

A basic introduction to the adjoint method can be found in [2].

Unfortunately, the adjoint method was not able to beat Matlab's lsqcurvefit. This led for some examples to be a slightly different version of the ones in [3].

Examples

All examples are in scripts/ and are named,

  1. sir_johnH_.m and sir_johnH.m
  2. seir_johnH_.m and seir_johnH.m
  3. seirt_johnH_.m and seirt_johnH.m

The underscore determines the inversion method used:

  • With underscore: Matlab's lsqcurvefit.
  • Underscore-free: Own adjoint method.

Out of all the models and methods, the SEIRt with lsqcurvefit gives the better looking fit. So use seirt_johnH_.m first (see below).

The data is downloaded from the John Hopkins github repo.

The folder data/archive has archived data downloaded April 7, 2020. If you'd rather use that, put those files in data/.

If for some reason you chose a country and it didn't work, make sure the file data/time_series_covid19_population_global.cvs has the population for that country and/or region.

The seirt_johnH_.m example

This example takes data from the John Hopkins github repo and returns an estimate of when we will be able to leave our homes.

After having fitted the data to the SEIRt model from [1], I manually compared the fitted dead values to the cummulative deaths values in [5]. For many countries the match is close in value, +/- 1e3 at worst.

I then took the values for the fitted infectious and compared them to the all beds needed values in [5]. For many countries the match is close in value (+/- 1e3) and in lag (+/- 3 days) at worst.

However, I only use this match (between the fitted infectious and the all beds needed values) qualitatively: I assume infectious gives a qualitative curve for current cases.

This enables two useful properties,

  1. the time derivative of infectious gives (qualitatively) new cases per time,

  2. the values of infectious are proportional to current cases.

A possible way of ending the lockdown is some time after the last infectious case. Using property 1, the zero crossing of dt(infectious) gives the time when no new cases arise (plotted in blue). In orange, a two month period after the last estimated infectious case is shown.

Another way of ending the lockdown is when hospitals are relieved of COVID-19 cases. Yellow shows when only 5% of the peak of infectious is reached. This rests on property 2.

Assuming the SEIRt model captures the nature of the coronavirus spread, estimates on the end of the lockdown can be made only on the John Hopkings observed data.

Estimate on lockdown end (by early April)

Most countries in the western northern hemisphere have the yellow (5% of peak cases) and orange (one month after last infected) cut-off times by late April or early May. In contrast other countries like Iran, Argentina and Peru show a yellow cut-off by August.

More pictures in pics/.

Contact

[email protected]

[email protected]

References

[1] Peng et. al. Epidemic analysis of COVID-19 in China by dynamical modeling

[2] Andrew M. Bradley. PDE-constrained optimization and the adjoint method

[3] ECheynet

[4] John Hopkings data

[5] The Institute for Health Metrics and Evaluation (IHME)

coronavirus's People

Contributors

diegozain avatar

Watchers

 avatar  avatar

Forkers

468301239

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.