# Fit Virus

Sean‘s pick this week is fitVirus by milan batista

I hope you and your family remain safe and healthy over the coming weeks.

This unfortunate situation does provide interesting data to be analyzed. Milan has provided a set of functions with corresponding live script documents to study and predict the COVID-19 infection rates with a logistic regression.

Here is the plot for the regression applied to South Korea. You can see the logistic regression estimate from the previous dates and how well those line up with the actual infection rates and that Korea is currently transitioning out of the rapid rise of infections.

fitVirus03(@getDataSouthKorea);
**** Estimation of epidemy size for South Korea
Initial guess K = 7940.33  r = 5.12261  A = 1186.3
Regression parameters for complet data set
mdl =
Nonlinear regression model:
y ~ fitVirus03/fun(b,X)

Estimated Coefficients:
Estimate      SE       tStat       pValue
________    _______    ______    __________
K     7944.1      87.914    90.363    1.3377e-27
r    0.37476     0.01125    33.311     5.377e-19
A     93.692      11.063    8.4691    4.7801e-08

Number of observations: 23, Error degrees of freedom: 20
Root Mean Squared Error: 126
F-statistic vs. zero model: 1.04e+04, p-value = 4.15e-32

Evaluation of model parameters for South Korea
day       date        C        K       r    C0   Tau        end  dCdt tpeak       peak    R2
(cases)  (cases) (1/day) (cases) (day)            (c/day) (day)
12 29-Feb-2020     3150    17145   0.328   102    12 19-Mar-2020  1405    15 04-Mar-2020 0.995
13 01-Mar-2020     4212    36984   0.313   109    12 25-Mar-2020  2896    18 07-Mar-2020 0.997
14 02-Mar-2020     4812    10186   0.363    84    11 15-Mar-2020   923    13 02-Mar-2020 0.996
15 03-Mar-2020     5328     7833   0.398    67    10 11-Mar-2020   779    11 29-Feb-2020 0.996
16 04-Mar-2020     5766     7224   0.418    58     9 11-Mar-2020   754    11 29-Feb-2020 0.997
17 05-Mar-2020     6284     7248   0.417    58     9 11-Mar-2020   755    11 29-Feb-2020 0.997
18 06-Mar-2020     6767     7447   0.406    64     9 11-Mar-2020   756    11 29-Feb-2020 0.998
19 07-Mar-2020     7134     7632   0.396    69    10 11-Mar-2020   754    11 29-Feb-2020 0.998
20 08-Mar-2020     7382     7751   0.388    74    10 11-Mar-2020   752    11 29-Feb-2020 0.998
21 09-Mar-2020     7513     7798   0.385    76    10 11-Mar-2020   751    11 29-Feb-2020 0.998
22 10-Mar-2020     7755     7883   0.379    80    10 13-Mar-2020   747    12 01-Mar-2020 0.998
23 11-Mar-2020     7869     7944   0.375    83    10 13-Mar-2020   744    12 01-Mar-2020 0.998

Short-term forecasting for South Korea
day         date     actual    predict    error % c./day act. c./day pred.     error %
18  06-Mar-2020       6767       6847       1.18        483        405       16.15
19  07-Mar-2020       7134       7156       0.31        367        309       15.80
20  08-Mar-2020       7382       7385       0.04        248        229        7.66
21  09-Mar-2020       7513       7551       0.51        131        166       26.72
22  10-Mar-2020       7755       7669       1.11        242        118       51.24
23  11-Mar-2020       7869       7753       1.47        114         84       26.32
24  12-Mar-2020          -       7812          -          -         59
25  13-Mar-2020          -       7853          -          -         41
26  14-Mar-2020          -       7881          -          -         28
27  15-Mar-2020          -       7901          -          -         20
28  16-Mar-2020          -       7914          -          -         13
29  17-Mar-2020          -       7923          -          -          9


Comparing this with Italy, we can see that milan’s model is estimating the rapid rise will continue for awhile longer.

fitVirus03(@getDataItaly);
**** Estimation of epidemy size for Italy
Initial guess K = 15178.9  r = 3.3881  A = 680.978
Regression parameters for complet data set
mdl =
Nonlinear regression model:
y ~ fitVirus03/fun(b,X)

Estimated Coefficients:
Estimate       SE       tStat       pValue
________    ________    ______    __________
K      29124       4017.3    7.2498    1.9414e-06
r    0.26146     0.011355    23.027    1.0785e-13
A     150.53       11.185    13.459    3.8388e-10

Number of observations: 19, Error degrees of freedom: 16
Root Mean Squared Error: 166
F-statistic vs. zero model: 5.97e+03, p-value = 1.35e-24

Evaluation of model parameters for Italy
day       date        C        K       r    C0   Tau        end  dCdt tpeak       peak    R2
(cases)  (cases) (1/day) (cases) (day)            (c/day) (day)
10 02-Mar-2020     2036     4970   0.394    99    10 11-Mar-2020   490     9 02-Mar-2020 0.996
11 03-Mar-2020     2502     4574   0.403    96     9 11-Mar-2020   461     9 02-Mar-2020 0.998
12 04-Mar-2020     3089     5399   0.381   105    10 13-Mar-2020   514    10 03-Mar-2020 0.998
13 05-Mar-2020     3858     7463   0.343   124    11 15-Mar-2020   639    11 04-Mar-2020 0.998
14 06-Mar-2020     4636     8999   0.325   135    12 17-Mar-2020   730    12 05-Mar-2020 0.998
15 07-Mar-2020     5883    15152   0.287   166    13 23-Mar-2020  1086    15 08-Mar-2020 0.998
16 08-Mar-2020     7382    28837   0.261   193    15 31-Mar-2020  1881    19 12-Mar-2020 0.998
17 09-Mar-2020     9172    49198   0.248   209    16 04-Apr-2020  3054    21 14-Mar-2020 0.998
18 10-Mar-2020    10149    23859   0.273   175    14 27-Mar-2020  1628    17 10-Mar-2020 0.998
19 11-Mar-2020    12462    29124   0.261   192    15 31-Mar-2020  1903    19 12-Mar-2020 0.998

Short-term forecasting for Italy
day         date     actual    predict    error % c./day act. c./day pred.     error %
14  06-Mar-2020       4636       4831       4.21        778        964       23.91
15  07-Mar-2020       5883       5978       1.61       1247       1147        8.02
16  08-Mar-2020       7382       7316       0.89       1499       1338       10.74
17  09-Mar-2020       9172       8839       3.63       1790       1523       14.92
18  10-Mar-2020      10149      10525       3.70        977       1686       72.57
19  11-Mar-2020      12462      12338       1.00       2313       1813       21.62
20  12-Mar-2020          -      14224          -          -       1886
21  13-Mar-2020          -      16122          -          -       1898
22  14-Mar-2020          -      17968          -          -       1846
23  15-Mar-2020          -      19704          -          -       1736
24  16-Mar-2020          -      21288          -          -       1584
25  17-Mar-2020          -      22693          -          -       1405


The current state of Italy also compares well to the current state of the whole world outside of China.

fitVirus03(@getDataWorld);
**** Estimation of epidemy size for outside of China
***Warning: Fail to calculate initial quess. Use default.
Initial guess K = 45411  r = 0.5  A = 45411
Regression parameters for complet data set
mdl =
Nonlinear regression model:
y ~ fitVirus03/fun(b,X)

Estimated Coefficients:
Estimate        SE        tStat       pValue
__________    _________    ______    __________
K    1.1398e+05       8373.7    13.611    2.2411e-17
r       0.20839    0.0042262     49.31     3.774e-40
A         18334       1653.8    11.086     2.525e-14

Number of observations: 46, Error degrees of freedom: 44
Root Mean Squared Error: 311
F-statistic vs. zero model: 4.04e+04, p-value = 1.53e-72

Evaluation of model parameters for outside of China
day       date        C        K       r    C0   Tau        end  dCdt tpeak       peak    R2
(cases)  (cases) (1/day) (cases) (day)            (c/day) (day)
23 17-Feb-2020      896  2952775   0.105    86    37 11-Aug-2020 77719    99 04-May-2020 0.994
24 18-Feb-2020      999  3724881   0.106    85    37 13-Aug-2020 98804   100 05-May-2020 0.995
25 19-Feb-2020     1124  3933032   0.107    84    37 13-Aug-2020 105326   100 05-May-2020 0.996
26 20-Feb-2020     1212  3622161   0.110    79    36 07-Aug-2020 99347    97 02-May-2020 0.996
27 21-Feb-2020     1385  1939550   0.107    84    37 30-Jul-2020 51957    93 28-Apr-2020 0.998
28 22-Feb-2020     1715  3615812   0.112    76    35 03-Aug-2020 101504    95 30-Apr-2020 0.994
29 23-Feb-2020     2055  2982829   0.120    65    33 22-Jul-2020 89482    89 24-Apr-2020 0.990
30 24-Feb-2020     2429  3167110   0.127    57    31 16-Jul-2020 100206    86 21-Apr-2020 0.988
31 25-Feb-2020     2764  4075977   0.131    51    30 14-Jul-2020 133744    85 20-Apr-2020 0.990
32 26-Feb-2020     3332  1908412   0.139    42    28 26-Jun-2020 66549    76 11-Apr-2020 0.990
33 27-Feb-2020     4288  1421367   0.152    30    26 14-Jun-2020 53853    70 05-Apr-2020 0.986
34 28-Feb-2020     5373  2776810   0.165    21    24 16-Jun-2020 114571    71 06-Apr-2020 0.985
35 29-Feb-2020     6789  7273608   0.180    13    22 20-Jun-2020 327757    73 08-Apr-2020 0.986
36 01-Mar-2020     8564  9574865   0.194     9    20 16-Jun-2020 464267    71 06-Apr-2020 0.989
37 02-Mar-2020    10298 33497614   0.199     7    20 26-Jun-2020 1664896    76 11-Apr-2020 0.992
38 03-Mar-2020    12751  8758570   0.203     6    19 12-Jun-2020 443969    69 04-Apr-2020 0.995
39 04-Mar-2020    14907 50617907   0.199     7    20 30-Jun-2020 2516184    78 13-Apr-2020 0.996
40 05-Mar-2020    17855   753574   0.198     8    20 19-May-2020 37234    57 23-Mar-2020 0.997
41 06-Mar-2020    21393   188240   0.204     6    19 05-May-2020  9599    50 16-Mar-2020 0.998
42 07-Mar-2020    25408   147511   0.207     6    19 01-May-2020  7631    48 14-Mar-2020 0.999
43 08-Mar-2020    29255   103948   0.214     5    18 27-Apr-2020  5564    46 12-Mar-2020 0.999
44 09-Mar-2020    33627    91962   0.218     4    18 25-Apr-2020  5015    45 11-Mar-2020 0.999
45 10-Mar-2020    38169    87077   0.221     4    18 25-Apr-2020  4801    45 11-Mar-2020 0.999
46 11-Mar-2020    45411   113974   0.208     6    19 29-Apr-2020  5937    47 13-Mar-2020 0.999

Short-term forecasting for outside of China
day         date     actual    predict    error % c./day act. c./day pred.     error %
41  06-Mar-2020      21393      21120       1.28       3538       3353        5.23
42  07-Mar-2020      25408      24943       1.83       4015       3823        4.78
43  08-Mar-2020      29255      29240       0.05       3847       4297       11.70
44  09-Mar-2020      33627      33994       1.09       4372       4754        8.74
45  10-Mar-2020      38169      39164       2.61       4542       5170       13.83
46  11-Mar-2020      45411      44680       1.61       7242       5516       23.83
47  12-Mar-2020          -      50450          -          -       5770
48  13-Mar-2020          -      56359          -          -       5909
49  14-Mar-2020          -      62282          -          -       5923
50  15-Mar-2020          -      68091          -          -       5809
51  16-Mar-2020          -      73670          -          -       5579
52  17-Mar-2020          -      78920          -          -       5250


As for some subtle things to make this easier for milan:

• The data are being entered in the MATLAB *.m files themselves using a construct we call “data as code”. It might make more sense to just store the data in a CSV file and read that in with readtable. All data could be stored in one file and the corresponding variable extracted as necessary. I think this would make updating it easier too.
• Since milan is keeping this current(!) it might make sense to link the repository to GitHub so a simple git commit/push would do the update rather than having to go through the File Exchange. It would also allow anyone to go to a previous state and see the record from that time.