lisphilar / covid19-sir

CovsirPhy: Python library for COVID-19 analysis with phase-dependent SIR-derived ODE models.
https://lisphilar.github.io/covid19-sir/
Apache License 2.0
109 stars 44 forks source link

[Fix] negative Rt in parameters forecast with `fit_predict()` for larger delay #507

Closed Inglezos closed 3 years ago

Inglezos commented 3 years ago

Summary

With the current implementation of parameters forecast, sometimes the predicted Rt value can become negative if delay is large. For example I tried hardcoded delay of 30 days instead of the recovery period (changed delay to 30 in _fit_create_data()) and I ran the estimator for Greece. The result was to have a phase with extremely small duration (zero or one day) and Rt to become negative: image image

Codes

import covsirphy as cs

data_loader = cs.DataLoader(directory="kaggle/input")
jhu_data = data_loader.jhu()
population_data = data_loader.population()
oxcgrt_data = data_loader.oxcgrt()

gre_scenario = cs.Scenario(jhu_data, population_data, "Greece")
gre_scenario.records().tail()
_ = gre_scenario.trend()
gre_scenario.estimate(cs.SIRF)
gre_scenario.add(name="Main", days=30)
gre_scenario.add(name="Forecast", days=30)
gre_scenario.fit_predict(oxcgrt_data=oxcgrt_data, name="Forecast").summary(name="Forecast")
gre_scenario.summary()
gre_sim_df_main = gre_scenario.simulate(name="Main")
gre_sim_df_forecast = gre_scenario.simulate(name="Forecast")

Environment

lisphilar commented 3 years ago

(This may be related to #513. 30 days may not be acceptable for Greece at this time.)

lisphilar commented 3 years ago

In version 2.16.2-kappa-fu2, delay-30 for Greece did not show negative values. https://gist.github.com/lisphilar/4b889de957bbc3554a13062d531d6e94