Skip to content
/ c19 Public

A place to organize some c19 work and resources

License

Notifications You must be signed in to change notification settings

misken/c19

Repository files navigation

Resources for COVID-19 hospital impact modelling

This repo is just a place to store some links, notes, code and other resources related to c19 hospital impact modeling.

Reflections on modeling and analysis of the pandemic

In Oct of 2021, this article appeared in MIT Technology Review:

I love this quote from above article:

He envisions research results that come not only with exhortations that “People should do this!” but also with accessible software allowing others to tinker with the tools. But for the most part, he says, epidemiologists do research, not development: “We write software, and it’s usually pretty bad, but it gets the job done. And then we write the paper, and then it's up to somebody else—some imagined other person—to make it useful in the broader context. And then that never happens. We’ve seen these failures in the context of the pandemic.”

The article above is based partially on this recent paper arguing for the need to better account for various flavors of uncertainty (stochastic, parameter and model) when doing pandemic modeling and analysis - Jon Zelner, Julien Riou, Ruth Etzioni, and Andrew Gelman.

COVID-19 Scenario Modeling Hub

This site has numerous teams submitting long term (3-6 months) forecasts that are them combined to create an ensemble forecast. Anyone can join. Since longer term forecasts are more susceptible to changes in policy and behavior (both virus and human), this site takes a scenario approach. Often four distinct scenarios are proposed and the modelers submit forecasts for each. The scenarios might involve things like vaccine uptake and NPI use.

COVID-19 Forecast Hub

This is another forecast aggregation site but with a focus on short term forecasts of cases, deaths and hospitalizations across the US. Numerous infectious modeling teams participate.

CHIME related links

Some of the work in this repo is based on the CHIME project at UPenn. This project does not appear to be active anymore, though the online hospital impact simulator is still running.

Other prominent Covid-19 models and data

Imperial College of London

Data

Papers

IHME model

Some of my work

Jump to:

More resources related to COVID-19 modeling and analysis

Articles, blog posts, vids

Other Covid19 data and simulators

Systems dynamics modeling in Python

Simulating SD models in Python - https://pysd.readthedocs.io/en/master/

Can read Vensim .mdl files. They are just text files.

Agent based modeling in Python

Mesa - https://github.com/projectmesa/mesa and https://mesa.readthedocs.io/en/master/index.html

Some project work

Dynamic relative contact rates

Added ability to specify multiple mitigation dates and associated relative contact rate values. See demo notebook for details. This should be useful for projecting impact of various changes in social distancing policies.

WARNING - NEEDS TESTING AND VALIDATION - IDEA SEEMS REASONABLE - USE AT YOUR OWN RISK

Impact of mitigation date, contact rate, infectious days on projection accuracy

I wanted to see how sensitive the CHIME projections are to values of the key input variables. Using my sim_chime_scenario_runner tool, I ran 560 scenarios based on the following ranges for each input factor:

  • mitigation-date : 2020-03-21 through 2020-03-27
  • relative-contact-rate : 0.05 to 0.80 in 0.05 increments
  • infectious-days : 8, 9, 10, 11 and 12 days

R based analysis knitted to pdf

chime_flow_resources_p1

Created: 2020-04-02

The goal for this notebook is to try to help people better understand the modeling principles, math and code behind the resource modeling in CHIME. It walks through how admits and census are computed for hospitalizations, ICU beds and vents. It also discusses some basic modeling issues related to using CHIME for assessing resource impacts of covid-19.

chime_flow_resources_p1.ipynb

chime_flow_resources_p2

In part 2, I developed a queueing model based approximation for the census distribution over time. This will allow us to include census distribution bands instead of just a deterministic point estimate of mean census.

chime_flow_resources_p2.ipynb

sim_chime_scenario_runner.py

Updated 2020-04-08 for consistency with penn-chime v1.1.3

NOTE - Input parameter file for CHIME has a few changes. See https://github.com/misken/sim_chime_scenario_runner.

A simple Python module for working with the penn_chime model from the command line or as importable functions.

Has its own repo now: https://github.com/misken/sim_chime_scenario_runner

  • A Jupyter notebook demo showing its use: using_sim_chime_scenario_runner.ipynb

  • assumes that you've pip installed penn_chime per these instructions

  • [OPTIONAL] You can do a pip install . of sim_chime_scenario_runner from the directory containing setup.py if you want to install into a virtual environment

  • allows running simulations from command line (like cli.py in penn_chime)

  • is importable so can also run simulations via function call

  • includes a few additional command line (or passable) arguments, including:

    • standard CHIME input config filename is a required input
    • a scenario name (prepended to output filenames)
    • output path
  • after a simulation scenario is run, a results dictionary is created that contains:

    • the scenario name
    • the standard admits, census, and sim_sir_w_date dataframes
    • the dispositions dataframe
    • a dictionary containing the input parameters
    • a dictionary containing important intermediate variable values such as beta, doubling_time, ...
  • writes out the results

    • dataframes to csv
    • dictionaries to json
  • (WIP) runs multiple scenarios corresponding to user specified ranges for one or more input variables.

Early model calibration and validation

Based on CHIME model as of 2020-03-30

I took our actual admits (from 2020-02-20 to a 2020-03-25) and just fit an exponential growth model, got the implied growth rate and implied doubling time. Plotted actual admits vs predicted (just using simple exp growth model) and got very nice fit. Then used implied doubling time of 3.61 in CHIME model and got spot on match with the exponential fit to admits and thus, to the actual admits. Super happy to see this!

You can see the results in this notebook: model_calibration_validation.ipynb

Jupyter notebook for downloading COVID-19 time series data

Downloads latest time series data from https://github.com/nytimes/covid-19-data

  • does a bunch of data wrangling to create global as well as US datasets (at county and state level) that are amenable to analysis
  • all dataframes are created both in semi-wide and long forms. The semi-wide forms have been date melted but contain separate columns for confirmed, deaths, and recovered. The long forms are measure melted in addition to date melted.
  • csvs explorted to path of your choosing
  • basic line plot at bottom for demo.

https://github.com/misken/c19/blob/master/get_c19_data_nytimes.ipynb

Capacity driven census and admission adjustments to CHIME model

Had idea for adjusting census and admission during early stages of virus spread to deal with census at time 0 problem.

Basic idea is that underlying epidemic has its dynamics that will play out almost independent of resources. But for capacity constrained resources it seems like there are a few phases during the early growth stage and then later stages of the virus. See my modeling notes README page.

Cheat sheet for installing CHIME locally

The docs for CHIME are great. I created this to help folks with limited exposure to this kind of stuff get CHIME installed in either Windows or Linux. The hospital based analysts we are trying to help with this work are all on Windows.

https://github.com/misken/c19/tree/master/mychime/docs

Jupyter notebook version of early CHIME model

NOTE: This was based on a very early version of the CHIME model. Nevertheless, the comments might still be useful to someone trying to understand the basic logic of the model. It should NOT be used for actual work.

I've added tons of code comments and other descriptive text throughout the notebook to help others understand exactly how this works and how we might adapt it for our use.

https://github.com/misken/c19/blob/master/mychime/archive/chime_earlyversion_annotated.ipynb

About

A place to organize some c19 work and resources

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published