# COVID-19 Confirmed Cases Growth Estimation In Tunisia

Posted 9 months ago
446 Views
|
0 Replies
|
0 Total Likes
|

## Concept

I have created this simple algorithm that generates two different regression functions of the confirmed cases in Tunisia. The data is imported from a subreddit. The first regression function is exponential which predicts the highest possible infection growth. The second one is logistic which predicts the minimum infection growth. I have used also the predefined Interpolation function to generate an Extrapolated function that gives an estimated number of cases on a given day. The three functions give an interval that predicts the number of cases. More parameters and modifications are required.

d=ToExpression[ StringExtract[Import["https://www.reddit.com/r/coronavirustunisia/comments/fjmd12/\cases_in_order/"], 40]];
f = GeneralizedLinearModelFit[d, x, x, ExponentialFamily -> "Poisson"];
i = Interpolation[d];
c0 = Max[d];
logistic = NonlinearModelFit[d, c/(1 + a*Exp[-b*x]), {a, {b, 0.1}, {c, c0}}, x];
NonlinearModelFit[d, c/(1 + a*Exp[-b*x]), {a, {b, 0.1}, {c, c0}}, x];
Off[InterpolatingFunction::dmval];
Off[Syntax::stresc];
Manipulate[Panel @

Dynamic @
Column[
{Row[{Text["Estimated Cases of Covid-19 in Tunisia on the  "]}],
Row[
{DatePlus[Now, m - 1], "
", "(", n = m + Length[d],
" days after the first case recorded", ")",
"
",
Button["Estimate",
If[Round[Numerator[Normal[logistic]]/2] > n,
Print["The estimated number of cases on the ",
DatePlus[Now, m - 1], " is between ",
If[(logistic[n]*100)/f[n] > 70, Round[logistic[n]],
Round[Abs[i[n]]]], " and ", Round[f[n]], "
", "The rate is  " s, "
", Style["Best case scenario : ", Green],
"The estimated number of unconfirmed cases ",
" is between ", Style[Round[logistic[n]*2.2], Underlined],
" and ", Style[Round[logistic[n]*3], Underlined], ".", "
", Style["Average case scenario : ", Gray],
"The estimated number of unconfirmed cases ",
" is between ", Style[Round[Abs[i[n]*2.2]], Underlined],
" and ", Style[Round[Abs[i[n]*3]], Underlined], ".", "
", Style["Worst case scenario : ", Red],
"The estimated number of unconfirmed cases ",
" is between ", Style[Round[f[n]*2.2], Underlined], " and ",
Style[Round[f[n]*3], Underlined], ".", "
", "The accuracy is ", (logistic[n]*100)/f[n], " %" , " (",
If[(logistic[n]*100)/f[n] > 50,
msg = Panel["accurate", Background -> LightGreen],
msg = Panel["not accurate", Background -> LightRed]], ").",
"
",
Column[
{Show[Plot[Normal[f], {x, 0, n}],
p = ListPlot[d, PlotStyle -> Red],
Plot[Abs[i[\[FormalX]]], {\[FormalX], 1, n},
PlotStyle -> Dashed],
Plot[Normal[logistic], {x, 0, n}, PlotStyle -> Pink],
ImageSize -> Medium]
}, s = Panel["increasing", Background -> LightRed]]],
Print["The estimated number of cases on the ",
DatePlus[Now, m - 1], " is between ",
If[(logistic[n]*100)/f[n] > 70, Round[logistic[n]],
Round[Abs[i[n]]]], " and ", Round[f[n]], "
", "The rate is ", s, "
", Style["Best case scenario : ", Green],
"The estimated number of unconfirmed cases ",
" is between ", Style[Round[logistic[n]*2.2], Underlined],
" and ", Style[Round[logistic[n]*3], Underlined], ".", "
", Style["Average case scenario : ", Gray],
"The estimated number of unconfirmed cases ",
" is between ", Style[Round[Abs[i[n]*2.2]], Underlined],
" and ", Style[Round[Abs[i[n]*3]], Underlined], ".", "
", Style["Worst case scenario : ", Red],
"The estimated number of unconfirmed cases ",
" is between ", Style[Round[f[n]*2.2], Underlined], " and ",
Style[Round[f[n]*3], Underlined], ".", "
",
Column[
{Show[Plot[Normal[f], {x, 0, n}],
p = ListPlot[d, PlotStyle -> Red],
Plot[Abs[i[\[FormalX]]], {\[FormalX], 1, n},
PlotStyle -> Dashed],
Plot[Normal[logistic], {x, 0, n}, PlotStyle -> Pink],
ImageSize -> Medium]
}, s = Panel["decreasing", Background -> LightGreen]], "
", "The accuracy is ", (logistic[n]*100)/f[n], " %" , " (",
If[(logistic[n]*100)/f[n] > 50,
msg = Panel["accurate", Background -> LightGreen],
msg = Panel["not accurate", Background -> LightRed]], ").",
"
"]],

Method -> "Queued"]}]}], {m, 1, 30, 1},
SaveDefinitions -> True] Attachments: Answer