PedroHPCintra / Coronavirus

Source code for simulations using SEIRD model for the coronavirus pandemic crisis
2 stars 1 forks source link

least square #1

Open pinkfloydisch opened 4 years ago

pinkfloydisch commented 4 years ago

Hi, Thanks for your very nice code, may I ask you please in fitting the parameters with the real data, tell me how can I implement the least square error?

Thanks a lot for your time and help.

PedroHPCintra commented 4 years ago

Hi, sorry for the delay. You referer to the error of the fitting or the error on the parameters found by the fitting?

pinkfloydisch commented 4 years ago

Thanks for your answer, I mean to find the parameters, you used this code : fittedParameters, pcov = curve_fit(comboFunc, comboX, comboY, initialParameters)

I am highly interested to see the results with Sum Least Square error for example : sum(( I - infected_data)**2 and then minimize this one. in your fitted parameters, as you used recovered data in the second step, you have very nice feet. can you please write a code to estimate the parameters with sum least square, and another request, how can we use infected , death and recovered data for "minimize sum least square error"

sorry for the long message

PedroHPCintra commented 4 years ago

Well I'll look for it and write back to you

PedroHPCintra commented 4 years ago

Hi!Sorry it took so long, I tried to find something about this method for fitting data but all I could find was regarding a linear regression. These simulations do not yield a linear function, making other methods more realiable for fitting. About using all three curves to find a better fit: It could be done if the data were more reliable, since countries tend to loose a lot of infections and at some stages even deaths, the curve of recoveries extracted by ''Total cases - Infections - Deaths'' carries some errors that make the three curves not perfect for each other. For that reason I choose to fit two at a time, not three. I hope I explained it well enough.

If still have any doubt, feel free to contact

pinkfloydisch commented 4 years ago

Thanks alot, it was very very useful. honestly, your codes and results are very very good, the problem was that several times for each I or D or R ... you created a separate script and this was new for me. and another point is that in your code you considered S0 ~ N . Usually in the model it is for example : dEdt = beta S I / N - sigmaE.... and for solving it, we consider N = S then ,.,, solving the : dEdt = betaI - sigma*E ... but you considered S0 equal to N. but as you put it in predictions or fittingparameters, ex: mod2(t, mu, gamma, beta, I0, R0, D0, N) , I was wondering maybe it can cause the problem. I tried it, for exmaple for Wuhan or Hubei with 59e6 population it has a lot big impact... if I take N or N - D0 - I0 - R0 -E0 because for Hubei , infected on 21.1.2020 is 444 people.

Thanks a lot for your explanation, it was very useful, and if you have free time, it will be great if you explain a little bit more regarding my new message. Thanks, have a nice and safe days