ImperialCollegeLondon / covid19model

Code for modelling estimated deaths and cases for COVID19.
MIT License
944 stars 271 forks source link

Errors due to forecast duration (N2) for data after the 18/04/2020 #77

Closed payoto closed 4 years ago

payoto commented 4 years ago

Describe the bug

When running with data including and after the 18/04/20 the plot-forecast.r fail to run.

Diagnostic

This is because, at that stage Italy has 84 days of data, the forecasting is attempted for 7 days (hard coded in the forecast), and the model is only run for 90 days N2 in base.r.

The fixes

After a bit of poking around to find a fix:

To Reproduce

Steps to reproduce the behavior:

  1. Run Rscript data/fetch-ecdc.r
  2. Run Rscript base.r base --debug
  3. Inspect closely the output (this does not appear in the CI runs as they don't monitor the status of intermediate steps)

Error message

Saving 10 x 7 in image
Error in estimated.deaths[, 1:N2, i] : subscript out of bounds
Calls: make_forecast_plot -> colMeans -> is.data.frame
In addition: Warning messages:
1: Transformation introduced infinite values in continuous y-axis
2: Removed 27 rows containing missing values (geom_bar).
3: Transformation introduced infinite values in continuous y-axis
4: Removed 27 rows containing missing values (geom_bar).
5: Transformation introduced infinite values in continuous y-axis
6: Removed 27 rows containing missing values (geom_bar).
7: Transformation introduced infinite values in continuous y-axis
8: Removed 27 rows containing missing values (geom_bar).
Execution halted
[1] "Running results/base-414043-stanfit.Rdata"
Error in prediction[, 1:length(x), i] : subscript out of bounds
Calls: colMeans -> is.data.frame
Execution halted
s-mishra commented 4 years ago

Hi @payoto, yeah I was worried about this. Anyways we are soon releasing a new version with the ability to do forecasts for much longer. Importantly we will remove N2 to be a pre-defined value. Just give us some time as we are in middle of a busy period.

payoto commented 4 years ago

Hi @s-mishra no worries, thanks for the quick answer, If you have time could you comment on the validity of applying 0s for longer forecast periods?

s-mishra commented 4 years ago

Solved by merging your PR and new commit too 865806ff6f7afb393