CodeForPhilly / chime

COVID-19 Hospital Impact Model for Epidemics
https://codeforphilly.github.io/chime/
MIT License
205 stars 151 forks source link

Chime model & curve behavior #443

Open luistelmocosta opened 4 years ago

luistelmocosta commented 4 years ago

Hello, I am working directly with a hospital from Porto, Portugal. I have been using this amazing tool to simulate the number of UCI which is very important for us. However, I am having some trouble trying to understand a few things.

Congratulations on this amazing tool and for your effort to serve the community in these hard times. I believe you are making an impact and that's a wonderful thing to see. I hope I can keep using it and improve our methodology 😃

My curve: imagem

PhilMiller commented 4 years ago

A fix for the social interaction date differing from the forecast date is pending: #418 As a temporary work-around until that's deployed, you could input current hospitalizations as of the mitigation date, and confirm that the rest of your data tracks

luistelmocosta commented 4 years ago

You mean change the Current Date to the mitigation date and put the number of hospitalizations at that time?

PhilMiller commented 4 years ago

Yes, exactly. When doing that, please check the curve's fit against the rest of your data, perhaps adjust parameters accordingly, and report what you find.

PhilMiller commented 4 years ago

For the curve behavior:

Keep in mind that hospital census is a sum over admissions over the preceding length-of-stay days. So, if the mitigation is expected to reduce admissions in the short term, then it can temporarily reduce census if the fall is sharp enough.

Have a look at the bottom graph of Susceptible/Infected/Recovered to see the underlying curves of the model dynamics. Admissions is a fraction of the derivative of Susceptible (essentially), and then Census is a sum over a rolling window of Admissions.

PhilMiller commented 4 years ago

For substituting your own model, all the relevant code is in src/penn_chime/models.py.

It can definitely be factored better to make this easier, but the entire codebase has been developed under extreme time pressure. I'm helping refactor things to ease that, and would be happy to support others' efforts to do the same

PhilMiller commented 4 years ago

This part of the documentation will guide you on running your modified version locally: https://code-for-philly.gitbook.io/chime/open-source/making-your-own-chime-app

luistelmocosta commented 4 years ago

Thank you for all your replies!

For the curve behavior:

Keep in mind that hospital census is a sum over admissions over the preceding length-of-stay days. So, if the mitigation is expected to reduce admissions in the short term, then it can temporarily reduce census if the fall is sharp enough.

I know that but why does it go up again after the length of stay days? Shouldn't it follow more a logistic curve and reach the plateau phase? I don't think it is very clear for someone that would use this and it would be hard to explain to them why the curve goes up after a while. But it seems that doing what you suggested, going back to the mitigation day and run from there makes the curve behave differently

imagem

About the model, I did all of that. Just figuring out what would be the quickest approach. I will try to fit (no pun intended) my logistic model in here and then I could help and share my implementation.

Thanks for your help!

PhilMiller commented 4 years ago

Just to make sure we're understanding each other:

The reason the census curve starts increasing again length-of-stay days after the drop is because that's when it starts replacing the local minimum values of admissions from right after the drop with successively higher values along the slowed but still increasing admissions curve. The local maximum of the census curve there, if there is one, appears when the summed values on either side of the pre-mitigation admissions peak are at their maximum.

This is all so stark because the model currently doesn't smooth or spread out any of the dynamics at all. Every single person infected on a given day is potentially hospitalized on exactly that day, and their contribution to the census lasts for exactly length-of-stay days.