How to resolve the algorithm Logistic curve fitting in epidemiology step by step in the Arturo programming language
How to resolve the algorithm Logistic curve fitting in epidemiology step by step in the Arturo programming language
Table of Contents
Problem Statement
The least-squares method (see references below) in statistics is used to fit data
to the best of a family of similar curves by finding the parameters for a curve
which minimizes the total of the distances from each data point to the curve.
Often, the curve used is a straight line, in which case the method is also called
linear regression. If a curve which uses logarithmic growth is fit, the method can be
called logistic regression.
A commonly used family of functions used in statistical studies of populations,
including the growth of epidemics, are curves akin to the logistic curve:
Though predictions based on fitting to such curves may error, especially if used to
extrapolate from incomplete data, curves similar to the logistic curve have had
good fits in population studies, including modeling the growth of past epidemics.
Given the following daily world totals since December 31, 2019 for persons who have become infected with the novel coronavirus Covid-19:
Use the following variant of the logistic curve as a formula: Where:
The R0 of an infection (different from r above) is a measure of how many new individuals will become infected for every individual currently infected. It is an important measure of how quickly an infectious disease may spread. R0 is related to the logistic curve's r parameter by the formula: where G the generation time, is roughly the sum of the incubation time, perhaps 5 days, and the mean contagion period, perhaps 7 days, so, for covid-19, roughly we have:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Logistic curve fitting in epidemiology step by step in the Arturo programming language
Source code in the arturo programming language
K: 7.8e9
N0: 27
Actual: [
27.0, 27.0, 27.0, 44.0, 44.0, 59.0, 59.0,
59.0, 59.0, 59.0, 59.0, 59.0, 59.0, 60.0,
60.0, 61.0, 61.0, 66.0, 83.0, 219.0, 239.0,
392.0, 534.0, 631.0, 897.0, 1350.0, 2023.0, 2820.0,
4587.0, 6067.0, 7823.0, 9826.0, 11946.0, 14554.0, 17372.0,
20615.0, 24522.0, 28273.0, 31491.0, 34933.0, 37552.0, 40540.0,
43105.0, 45177.0, 60328.0, 64543.0, 67103.0, 69265.0, 71332.0,
73327.0, 75191.0, 75723.0, 76719.0, 77804.0, 78812.0, 79339.0,
80132.0, 80995.0, 82101.0, 83365.0, 85203.0, 87024.0, 89068.0,
90664.0, 93077.0, 95316.0, 98172.0, 102133.0, 105824.0, 109695.0,
114232.0, 118610.0, 125497.0, 133852.0, 143227.0, 151367.0, 167418.0,
180096.0, 194836.0, 213150.0, 242364.0, 271106.0, 305117.0, 338133.0,
377918.0, 416845.0, 468049.0, 527767.0, 591704.0, 656866.0, 715353.0,
777796.0, 851308.0, 928436.0, 1000249.0, 1082054.0, 1174652.0
]
f: function [r][
result: 0
loop 0..dec size Actual 'i [
eri: exp r * to :floating i
guess: (N0 * eri) // (1 + N0 * (eri - 1) // K)
diff: guess - Actual\[i]
result: result + diff * diff
]
return result
]
solve: function [fn][
guess: 0.5
eps: 0.0
result: guess
delta: guess
f0: call fn @[result]
factor: 2.0
while [and? -> delta > eps
-> result <> result - delta][
nf: call fn @[result-delta]
if? nf < f0 [
f0: nf
result: result - delta
]
else [
nf: call fn @[result+delta]
if? nf < f0 [
f0: nf
result: result + delta
]
else [
factor: 0.5
]
]
delta: delta * factor
]
return result
]
r: solve 'f
r0: exp 12 * r
print ["r =" r]
print ["R0 =" r0]
You may also check:How to resolve the algorithm Langton's ant step by step in the Scala programming language
You may also check:How to resolve the algorithm Text processing/Max licenses in use step by step in the Python programming language
You may also check:How to resolve the algorithm Trigonometric functions step by step in the Fantom programming language
You may also check:How to resolve the algorithm String case step by step in the Java programming language
You may also check:How to resolve the algorithm First-class functions step by step in the Python programming language