rajeshrinet / pyross

PyRoss: inference, forecasts, and optimised control of epidemiological models in Python. github.com/rajeshrinet/pyross
https://pyross.readthedocs.io
MIT License
169 stars 57 forks source link

Least sum of squares optimization for Is+Ia #20

Closed technOslerphile closed 4 years ago

technOslerphile commented 4 years ago

Hi,

I was simulating the asymptomatic (Ia) + symptomatic (Is) scenario to fit and find the best beta. In the findBetaIsandIa function, the sum of squares error is computed as below:

findBeta

I see a potential issue here. The cases here consists only the Is, while the Ic consists of both the Is as well as Ia. So this could be biasing the optimization. I believe the cases have to be modified to reflect an estimate of Is+Ia in there. This can be done by using alpha. By default, alpha is zero (no Ia), but in case if alpha is non-zero, then cases have to be multiplied by a factor of 1/(1-alpha) to reflect the total number of cases (Ia + Is). This would make the the estimate of beta to fit better with the total number of cases (Is + Ia). Let me know your thoughts.

rajeshrinet commented 4 years ago

@technOslerphile there are two methods there one to fit Is and another to both Is and Ia. One has to choose which method to use from their knowledge of the cases file. It is in this spirit, the two different methods are provided. Hope it answers you question.

technOslerphile commented 4 years ago

@technOslerphile there are two methods there one to fit Is and another to both Is and Ia. One has to choose which method to use from their knowledge of the cases file. It is in this spirit, the two different methods are provided. Hope it answers you question.

The second method returns beta for Is+Ia, but the error that is getting minimized in this method is Is- estimated(Is+Ia) instead of (Is+Ia) - estimated(Is + Ia)

My intention is to find the best beta for Is+Ia. So the second method, findBetaIsandIa, is the one I am interested in. Why? Because it returns the estimated Is and Ia. My worry here is that the error that is getting minimized is not reflecting the true error as the 'cases' array contains only the Is cases from the actual data. I have modified my error function to reflect the 'actual' Ia cases as well. How? By extrapolating alpha to the actual number Is cases which we already know.

rajeshrinet commented 4 years ago

@technOslerphile Yes, you will need to update cases. I have been a bit lazy in writing that function. I assume that cases contains Is and Ia and it has been pre-computed, as you have said in your comment. Clearly cases in the two functions need to be different.

technOslerphile commented 4 years ago

@technOslerphile Yes, you will need to update cases. I have been a bit lazy in writing that function. I assume that cases contains Is and Ia and it has been pre-computed, as you have said in your comment. Clearly cases in the two functions need to be different.

No issues. I just wanted to know how you felt about this because I could be missing something that's in the backend functions. Nonetheless, I am able to use the modified error estimate and find the betas for Is+Ia. If you want, please feel free to check the notebook attached here... fitParamBeta.zip Note that I haven't touched the beta finding functions in SEIR for now and have commented it all out....

rajeshrinet commented 4 years ago

@technOslerphile thanks. I have updated the example using your fix.