This repo is just a place to store some links, notes, code and other resources related to c19 hospital impact modeling.
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.
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.
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.
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.
- Online hospital impact simulator - v1.1.5 (2020-04-08) still running
- https://github.com/CodeForPhilly/chime
- Bayes CHIME - all public facing activity appears ceased
- CHIME docs
- CHIME pub in Annals of Internal Medicine
- #covid19-chime-penn Slack channel
- Announcing CHIME blog post
- Main reports page
- State level model explainer page
- Nature paper - June 2020
- Report 13 - Flaxman
- State level tracking in the US
- Source code for Report 13 state level model
- Source code for Report 9 microsimulation model
- Report 9 - Ferguson
- IHME - COVID-19 Projections - paper describing methodology is here
- America’s most influential coronavirus model just revised its estimates downward. But not every model agrees.
- The IMHE COVID-19 model is fatally flawed
Jump to:
- modeling multiple mitigation dates and relative contact rates - added functionality to
sim_chime_scenario_runner
to model relative contact rates that change over time as social distancing policies change. - chime_flow_resources_p2 notebook - a queueing based approach to census modeling in CHIME
- Impact of mitigation date, contact rate, infectious days on projection accuracy - scenario analysis
sim_chime_scenario_runner
- CHIME wrapper (Python) that can be used from command line or as importable library- chime_flow_resources_p1 notebook - modeling principles, math and code behind the resource modeling in CHIME
- Early model calibration/validation - comparison of actual hospital admits to projections during early growth phase of virus
- Download and prep NY Times Covid-19 data - state and county level data
- Capacity driven census and admission adjustments to CHIME model - idea notes
- Cheat sheet for installing CHIME locally
- https://www.nytimes.com/interactive/2020/05/12/upshot/coronavirus-models.html
- Inside a Chicago hospital built to deal with a pandemic
- mathbabe post on covid-19
- Coronavirus modelers factor in new public health risk: Accusations their work is a hoax
- A War Footing: Surfing the Curve
- The Flaw of Averages in Flattening the Curve
- A combination of coronavirus and the flaw of averages can drive you nuts
- https://www.covid19sim.org/ (MIT, Ga Tech, Harvard) - Shiny App
- https://covidtracking.com/ - state level data including testing and grades
- https://alhill.shinyapps.io/COVID19seir/
- https://metasd.com/2020/03/interactive-coronavirus-models/
- https://metasd.com/2020/03/community-coronavirus-model-bozeman/
- https://forio.com/app/jeroen_struben/corona-virus-covid19-seir-simulator/index.html#introduction.html
- http://covidsim.eu/
- https://www.hsye.org/covid-19-capacity-mgmt (Healthcare Systems Engineering Institute at Northeastern U.)
Simulating SD models in Python - https://pysd.readthedocs.io/en/master/
Can read Vensim .mdl files. They are just text files.
Mesa - https://github.com/projectmesa/mesa and https://mesa.readthedocs.io/en/master/index.html
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
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-27relative-contact-rate
: 0.05 to 0.80 in 0.05 incrementsinfectious-days
: 8, 9, 10, 11 and 12 days
R based analysis knitted to pdf
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.
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.
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 .
ofsim_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.
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
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
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.
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
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