Lewuathe / COVID19-SIR

COVID-19 SIR model estimation
https://www.lewuathe.com/covid-19-dynamics-with-sir-model.html
Apache License 2.0
131 stars 75 forks source link

Suggestions of some improvements #23

Open gasilva opened 4 years ago

gasilva commented 4 years ago

Here are some improvements possible:

def lossOdeint(point, data, recovered, death, s_0, i_0, r_0, d_0):
    size = len(data)
    beta, a, b = point
    def SIR(y,t):
        return [-beta*y[0]*y[1], beta*y[0]*y[1]-(a+b)*y[1], a*y[1], b*y[1]]
    y0=[s_0,i_0,r_0,d_0]
    tspan=np.arange(0, size, 1)
    res=odeint(SIR,y0,tspan)
    l1 = np.sqrt(np.mean((res[:,1]- data)**2))
    l2 = np.sqrt(np.mean((res[:,2]- recovered)**2))
    l3 = np.sqrt(np.mean((res[:,3] - death)**2))
    #weight for cases
    u = 0.25
    #weight for recovered
    v = 0.02 ##Brazil France 0.04 US 0.02 China 0.01 (it has a lag in recoveries) Others 0.15
    #weight for deaths
    w = 1 - u - v - z
    return u*l1 + v*l2 + w*l3