Help me model event of pandemic proportion

Please help me model the event of
global cases of coronavirus with
a Logistic function.

I am trying the find the values of these three parameters

  1. L
  2. X0 (X_zero)
  3. k

$ cat data.txt
17.0,41.0
19.0,62.0
20.0,201.0
21.0,291.0
22.0,440.0
24.0,830.0
25.0,1287.0
26.0,1975.0

According to desmos, L is around 6000.

Only 6000? That’s not much of a pandemic. Latest figures

https://www.scmp.com/news/china/scie…onavirus-china

Total 2748 cases including 80 deaths (CHINA)
Total 2806 cases including 80 deaths (GLOBAL)

… (and also discuss the antivirals being trialed)

The National Health Commission said that
a combination of antiretroviral drugs used to treat HIV – lopinavir and ritonavir – had been given to some patients
infected with the Wuhan coronavirus at three of the capital’s hospitals…

maybe using the SIR model?

Agreed, however this curve fits pretty well. Coronavirus R^2=.998. Much of the problem will be that the Chinese government is somewhat notorious for lying about disease spread to make things look better than they really are. This might be a case of GIGO

3 Likes

Fitting for the maximum value is pretty useless with data like this. You would need to be able to see the data curve down to make this prediction. (e.g. it still fits with L=1E9, Coronavirus).

1 Like

To answer the question, this is how you would fit this in julia:

julia> using LsqFit

julia> d = [17,19,20,21,22,24,25,26];

julia> C = [41,62,201,291,440,830,1287,1975];

julia> model(x,p) = @. p[1]/(1+exp(p[2]*(p[3]-x)));

julia> fit = curve_fit(model,d,C,[10000,0.5,10]);

julia> coef(fit)
3-element Array{Float64,1}:
  3.2851466556639015e6
  0.40385634551986366
 44.38662397812089

julia> confidence_interval(fit, 0.05)
3-element Array{Tuple{Float64,Float64},1}:
 (-3.1459929604011664e9, 3.1525632537124944e9)
 (0.27660508963623914, 0.5311076014034881)
 (-2336.174503656719, 2424.947751612961)

Interestingly we get a different value for L, not sure why. However, as expected, the confidence interval is huge, showing that this parameter is not important to the fit.

Note that LsqFit currently returns symmetric confidence intervals, which is why the lower bound makes no sense here.

4 Likes

Thank you, I got it

using LsqFit, CSV, DataFrames

csv = CSV.File("/Users/ssiew/juliascript/coronavirus/data.txt")
df = DataFrame!(csv)

day = df[:,:day]
cases = df[:,:cases]

model(x,p) = @. p[1]/(1+exp(p[2]*(p[3]-x)));
fit = curve_fit(model,day,cases,[10000,0.5,10]);

parameter = coef(fit)
conf_interval = confidence_interval(fit, 0.05)
display(parameter)
display(conf_interval)
$ cat data.txt
"day","cases"
17.0,41.0
19.0,62.0
20.0,201.0
21.0,291.0
22.0,440.0
24.0,830.0
25.0,1287.0
26.0,1975.0
27.0,2806.0