Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix calculation of new infected cases #190

Merged
merged 4 commits into from
Mar 23, 2020
Merged

Fix calculation of new infected cases #190

merged 4 commits into from
Mar 23, 2020

Conversation

cjbayesian
Copy link
Collaborator

Closes #189

@cjbayesian
Copy link
Collaborator Author

Old (broken):
image

New:
image

@cjbayesian cjbayesian added the bug Something isn't working label Mar 23, 2020
@@ -74,7 +74,7 @@ def admitted_patients_chart(

return (
alt.Chart(census.head(plot_projection_days))
.transform_fold(fold=["Hospitalized Census", "ICU Census", "Ventilated Census"])
.transform_fold(fold=["Hospitalized", "ICU", "Ventilated"])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just to get the graphs' x-axes to line up vertically. Label redundant to plot title and y-label.

@PhilMiller
Copy link
Collaborator

PhilMiller commented Mar 23, 2020

There's an approximate invariant you can use to test the admissions values, no matter how they're calculated:

sum(admissions[:d]) == hospitalization_rate * market_share * (I[d]+R[d]) - initially_hospitalized

That's saying that everyone who should now be or have been hospitalized at the subject hospital was (counted as) admitted on some particular day.

I've very roughly hacked this in to test_parameters as follows and can confirm that your change to parameters.py takes it from failing to passing:

    admissions = build_admissions_df(param)
    cumulative_admissions = admissions.cumsum()
    diff = cumulative_admissions["Hospitalized"][1:-1] - (0.05*0.05 * (param.infected_v[1:-1] + param.recovered_v[1:-1]) - 100)
    assert (diff.abs() < 0.1).all()

@mdbecker mdbecker requested review from Hanisha13 and machow March 23, 2020 10:57
@mdbecker mdbecker mentioned this pull request Mar 23, 2020
@mdbecker mdbecker merged commit a068838 into develop Mar 23, 2020
@mdbecker mdbecker deleted the fix_189 branch March 23, 2020 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix calculation of daily new infections
3 participants