# Tool for FreeBSD which extracts, curve-fits a logistic function and transposes JHU-CSSE's Covid-19 data by country



## obsigna (Mar 24, 2020)

You'll find said tool on my GitHub repository - https://github.com/cyclaero/xcssecovid

*Quick Start*

`svnlite co https://github.com/cyclaero/xcssecovid.git/trunk xcssecovid`
`cd xcssecovid`
`clang -g0 -O3 -march=native xcssecovid.c -Wno-parentheses -lm -o xcssecovid`
`fetch -qo - https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv | ./xcssecovid US - US.tsv`
`cat US.tsv`

```
# Model: a/(1 + exp(-b·(x - c)))
#        a =    144036 ± 13.179 %
#        b =  0.364201 ± 2.7248 %
#        c =   64.2688 ± 0.8798 %
#   ChiSqr =  92220.86
t/d    C    L
-20    *    0.000000
-19    *    0.000000
-18    *    0.000000
-17    *    0.000000
...
...
-1    *    0.000007
0    *    0.000010
1    1    0.000014
2    1    0.000020
3    2    0.000029
4    2    0.000042
5    5    0.000061
6    5    0.000088
7    5    0.000126
8    5    0.000181
9    5    0.000261
10    7    0.000376

...
...
50    1281    792.802927
51    1663    1138.378834
52    2179    1632.871155
53    2727    2338.647108
54    3499    3342.320651
55    4632    4762.262397
56    6421    6756.478624
57    7783    9528.646839
58    13677    13327.803195
59    19100    18434.120243
60    25489    25120.832956
61    33276    33584.499721
62    43847    43848.254080
63    *    55667.801935
64    *    68495.183556
65    *    81550.592732
66    *    93997.986502
67    *    105148.182477
68    *    114592.002038
69    *    122218.258863
70    *    128143.172369
...
...
80    *    143569.151663
81    *    143711.229374
82    *    143810.103724
83    *    143878.876950
84    *    143926.695982
85    *    143959.937038
86    *    143983.040349
87    *    143999.095772
88    *    144010.252408
89    *    144018.004514
90    *    144023.390792
...
...
```






*What the hell is a Logisitc Function?*

According to Wikipedia - https://en.wikipedia.org/wiki/Logistic_function:
A *logistic function* or *logistic curve* is a common "S" shape (sigmoid curve), with equation:






The logistic function finds applications in a range of fields, including artificial neural networks, biology (especially ecology), biomathematics, chemistry, demography, economics, geoscience, mathematical psychology, probability, sociology, political science, linguistics, and statistics.

As a matter of fact it is THE MODEL for almost all natural growth processes, and it would be extremely surprising if not for the present spread of Covid-19 in given populations. I proved already, that the logistic function described very well the spread in China. So why not in other regions of the world as well.

*What is this good for?*

One very important property of the logistic function is its symmetry around the turning point _x₀_. That means, once a spread has been verified to have passed the turning point, we know with a probability approaching certainty how it ends up.

*What is Curve Fitting?*

We have a Model (here the logistic function consisting of 3 parameters). We have a time series. The curve fitting algorithm iteratively varies the parameters so that the sum of the squares of the differences between each of the simulated values to each data point becomes minimal (least squares method). In said tool, I implemented the Levenberg–Marquardt algorithm as the least squares method.

*Why would we care?*

Look at the results of the curve fit of the LF to yesterday's US data according to the JHU/CSSE time series - https://github.com/CSSEGISandData/COVID-19/tree/master/csse_covid_19_data

Parameter *a* ist the limiting value, however, since in the US we didn't reach the turning point yet (parameter *c* = day 64, i.e. March, 25th), the prevision of the limiting value = 144036 confirmed Covid-19 infections is yet a bit uncertain.

Now, you want to know, how your country is doing, for example Spain?
`fetch -qo - https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv | ./xcssecovid Spain - Spain.tsv`
`head Spain.tsv`

```
# Model: a/(1 + exp(-b·(x - c)))
#        a =   70273.9 ± 8.228 %
#        b =  0.264668 ± 3.1934 %
#        c =    62.172 ± 0.91822 %
#   ChiSqr =  129867.3
t/d    C    L
-20    *    0.000025
-19    *    0.000033
-18    *    0.000043
-17    *    0.000056
```

Turning point was yesterday. In case there are no bigger changes in the containment measures, the spread in Spain will end up with more than 70k confirmed infections in apprx. 2 to 3 weeks.





I follow the time series for Germany, Italy and Brazil on my BLog - https://obsigna.com/articles/1584931539.html. Others may want to follow the spread in their country using said tool.

God help us all.


----------



## Crivens (Mar 24, 2020)

You sure all that data can be compared? Looks like there is disagreement in how to measure. https://www.telegraph.co.uk/global-...se/have-many-coronavirus-patients-died-italy/

Otherwise, good on you, nice work.


----------



## obsigna (Mar 24, 2020)

Crivens said:


> You sure all that data can be compared? Looks like there is disagreement in how to measure. https://www.telegraph.co.uk/global-...se/have-many-coronavirus-patients-died-italy/
> 
> Otherwise, good on you, nice work.


While the absolute numbers are definitely not exactly comparable, the course of the spread over the time can be compared. What I want to say is, it does not make a huge difference to me (a German living in Brazil) whether the final count of infections reaches 10k or 20k (prevision from yesterday). What makes a huge difference to me is, whether it takes 3 weeks or 3 months until the spread approaches its limit. People seem to be afflicted with the absolute numbers, and questioning whether there aren't millions of unreported cases, which didn't enter into the statistics. My answer here is, the absolute numbers do not matter to us mere mortals, as long as its course over time follows the law of logistic growth.
Somebody wrote in a comment on Z.On - https://www.zeit.de/wissen/gesundhe...tung-epidemie-karte?cid=52054033#cid-52054033:


> You are healthy. -> Then stay at home!
> You feel sick. -> Then stay at home!
> Your test is positive. -> Above all, stay at home!
> Your test is negative. -> Anyway, stay at home!
> ...


Given the course in Brazil, I stay at home, however, I happily do not put 10000 rolls of toilet paper on stock.


----------



## ralphbsz (Mar 24, 2020)

Fun. But obviously one has to be super careful. As Crivens already said, the data from different countries can not be compared to each other, since different countries use different definitions of what constitutes as "case", whether it's based on antibody tests or symptoms. And even within those two categories, there are many different possible definitions. As an example, yesterday the German press had many articles that Russia is (a) using an antibody test that is much less sensitive than the ones in the rest of the world, so it likely underestimates the number of cases, and (b) doesn't recognize Covid-19 as a cause of death (instead patients are considered to have died of pneumonia), so there are no deaths reported in Russia. If one can't compare data from different countries, one can also not add them.

Second, even within a single country, the testing regimen and the definition of what is a "case" probably changes as a function of time. Early on, no tests were even available; then tests became manufactured in large numbers (in some countries they are supposedly available over the counter for cash), and in other places even hospitals have too few tests available. As an example, here in Silicon Valley (one of the richest places on the planet), a friend-of-a-friend is in the hospital with a serious pneumonia, but the hospital only has 6 test kits left, so they are not even testing that patient, since the test result will not directly affect their care at the moment. So is this patient counted? Will they be counted later this week, when large shipments of test kits are supposed to arrive? If yes, will their data be backdated to when they actually started having symptoms?

And the problem is that right now, this is a very dangerous extrapolation. Fitting a logistics curve depends crucially on finding the turning point, which in turn depends solely on a small number of data points at the end. Try this for fun: take the raw data, and change each data point by +- one sigma (by sqrt of the count, since for large enough counts, 20 or more, the standard deviation of a binomial ). In theory, if there was lots of data points and the fit were stable, those changes should cancel, and the estimate of turning point position and final height should be pretty stable. I'm going to bet that right now, for most countries doing this will make the extrapolation fluctuate all over. This sort of gives you a guess of how trustworthy the results are.


----------



## ralphbsz (Mar 24, 2020)

And a specific comment about Brasil. I don't know where in Brasil you are (probably RJ or SP), but a large fraction of Brasil's population is hard to reach, hard to measure, and hard to get data on. I'm a bit familiar with the southwestern state of Mato Grosso do Sul and its capital Campo Grande: The state has ~4 million inhabitants, only one large city (which is nearly a million people), a few small cities of tens of thousands, and the rest of the population distributed all over the rural area. I bet that nobody knows how many cases there are in the rural areas. My educated guess is that there is a similar situation in Rio and Sao Paulo, with the population in the favelas receiving relatively little care, and not being well counted. The logistics curve assumes that the disease spreads through the (measured) population, causes immunity, and runs its course. In a place where a large fraction of the population is (a) not measured, and (b) only interacts slowly with the population in the big centers (not just Campo Grande and other provincial capitals, but in particular Rio and Sao Paulo, which have their own reservoirs in the favelas), this kind of forecasting becomes harder.


----------



## obsigna (Mar 24, 2020)

ralphbsz said:


> ... Fitting a logistics curve depends crucially on finding the turning point ...



I know this of course, and for this reason I wrote _"That means, once a spread has been verified to have passed the turning point, we know with a probability approaching certainty how it ends up."_

To be sure, that we passed the turning point, the curve fitting must be repeated when new data is available. I did this with my time series analysis of the spread in China and the previsions were quite valid.

Personally, I am not interested to compare the numbers of Russia with those of other countries. Again more important to me than case numbers is, how long it takes, and according to all the data which I've already analysed, it will take 2 to 3 weeks after the turnning point was passed.


----------



## ralphbsz (Mar 24, 2020)

obsigna said:


> I know this of course ...


I think the important part is to make sure that everyone who finds this and has less knowledge of statistics understands the limitations of the data.


----------



## obsigna (Mar 24, 2020)

ralphbsz said:


> And a specific comment about Brasil. I don't know where in Brasil you are (probably RJ or SP), but a large fraction of Brasil's population is hard to reach, hard to measure, and hard to get data on. I'm a bit familiar with the southwestern state of Mato Grosso do Sul and its capital Campo Grande: The state has ~4 million inhabitants, only one large city (which is nearly a million people), a few small cities of tens of thousands, and the rest of the population distributed all over the rural area. I bet that nobody knows how many cases there are in the rural areas. My educated guess is that there is a similar situation in Rio and Sao Paulo, with the population in the favelas receiving relatively little care, and not being well counted. The logistics curve assumes that the disease spreads through the (measured) population, causes immunity, and runs its course. In a place where a large fraction of the population is (a) not measured, and (b) only interacts slowly with the population in the big centers (not just Campo Grande and other provincial capitals, but in particular Rio and Sao Paulo, which have their own reservoirs in the favelas), this kind of forecasting becomes harder.


I am in São Paulo, and be assured, I am following very well all the news. The Brazilian authorities acted strictly in a timely manner, when the reported case numbers were still low. For example the schools here closed at the same day on Monday last week as in Germany, however in Germany the number of reported cases were already above 7000 compared to 200 in Brazil. My wife was born in a small town in the middle north of Brazil - her mother said in a phone call, that everybody tries to stay at home, because there was reported the first case. Brazil got a public health care system which is very proactive. For example, our new daughter was born in January this year. Since then, every 3 weeks an agent of the public health care station near to our home comes visiting us, only for asking if everything is going well, and reminds us not to miss out the vaccine campaigns. I am sure that we in Brazil won't see a disaster like in Italy.


----------



## ralphbsz (Mar 24, 2020)

I get my news right now second hand. You are right that the authorities in Brasil reacted nice and early. And also the public did the right thing early on. As an example, the nursing home where my parents live (they are both very old and frail) went on lockdown voluntarily a week before any cases were reported in the city.

The other good news is that Brasil actually has a fabulously good public health system. The only problem is that the system is chronically underfunded and understaffed. For example, I happen to know that the intensive care unit (ICU in English, Intensivstation in German, and CTI in Portuguese) of the public SUS hospital in a city of 3/4 million people has 14 beds. There are two more sizeable hospitals in town (university and union of public employees), but I think their intensive care units are smaller and less well equipped (I know they send super-serious cases to the public one). In normal operation already, all beds in the CTI are occupied, and triage occurs every time a patient shows up. If they get a few thousand Covid-19 cases in the state (which seems plausible), they will be completely out of places to treat them. They key for Brasil is to hold the number of serious cases down (by slowing down infection for as long as possible), without the economic side-effects killing more people.


----------



## rigoletto@ (Mar 24, 2020)

This is the last report from Russia. *[EDIT]* THIS is the right link.

The reported numbers in Russia are too good to be true but this is unlikely the situation is going crazy in there like in Western Europe[1], since they were the first to take measures, just after China. The border with China was locked and any Chinese seen on Russia was to be reported to be detained and quarantined.

The Russians returning from China with any suspicion of being infected were also quarantined, the ones in Wuhan were taken and quarantined somewhere in Siberia. There is the case of that women whom come from some resort, quarantined and then escaped of the quarantine.





_View: https://www.youtube.com/watch?v=bFbmrZDWULg_

Also, as soon the situation was going bad in some country they started to take measures of people returning from that country etc.

*[EDIT]* about the Russian tests.

In relation to Brazil, in particular to Rio de Janeiro specifically,  just today there was a reported case in a favela. The thing is high concentrated on South Zone and Barra da Tijuca since those are the places where there are more forefingers around (tourists) and people flinging abroad often.

Most other areas have very few reported cases, often 2-4 (until now).

[EDIT] also, in favelas, at least some of them, the drug lords passed an order to everyone stay in home, and their orders are always followed because there are actual consequences for those who not comply.

[1] Central and Eastern Europe also starting taking measures earlier and are in a far better situation than Germany, Spain and Italy.


----------



## Alain De Vos (Mar 24, 2020)

I use numpy,pyplot & polyfit,polyval. It will take a week before I know if predictions are ok.
My hobby model is very wet vinger work.
The code is so small I don't think I can reduce it using R or Julia
But why would someone use C for predictive models when higher level API's are available.
And a critical remark, why would a logistic function be better than other models ?


----------



## mark_j (Mar 24, 2020)

rigoletto@ said:


> This is the last report from Russia. *[EDIT]* THIS is the right link.
> 
> The reported numbers in Russia are too good to be true but this is unlikely the situation is going crazy in there like in Western Europe[1], since they were the first to take measures, just after China. The border with China was locked and any Chinese seen on Russia was to be reported to be detained and quarantined.



While I don't doubt what you're saying, the fact they stopped only Chinese seems a bit lop-sided. Surely they stopped/quarantined Russians coming from China?

Either way, you can't believe ANYTHING that comes out of China. It's hard to believe anything coming out of Russia either. Although the latter's press are a little more open; just a little.


----------



## rigoletto@ (Mar 25, 2020)

mark_j said:


> While I don't doubt what you're saying, the fact they stopped only Chinese seems a bit lop-sided. Surely they stopped/quarantined Russians coming from China?
> 
> Either way, you can't believe ANYTHING that comes out of China. It's hard to believe anything coming out of Russia either. Although the latter's press are a little more open; just a little.



This was in the very early beginning when no one was doing anything outside China[1], and as I said before people coming from China with any suspicion were quarantined too, like the women of the video.

[1] China ever formally criticized Russia about their citizens being treated very aggressive. Also, Russia received a lot of criticism at that time due to they hash very measures from Western European countries...


----------



## obsigna (Mar 25, 2020)

ralphbsz said:


> I get my news right now second hand. You are right that the authorities in Brasil reacted nice and early. And also the public did the right thing early on. As an example, the nursing home where my parents live (they are both very old and frail) went on lockdown voluntarily a week before any cases were reported in the city.
> 
> The other good news is that Brasil actually has a fabulously good public health system. The only problem is that the system is chronically underfunded and understaffed. For example, I happen to know that the intensive care unit (ICU in English, Intensivstation in German, and CTI in Portuguese) of the public SUS hospital in a city of 3/4 million people has 14 beds. There are two more sizeable hospitals in town (university and union of public employees), but I think their intensive care units are smaller and less well equipped (I know they send super-serious cases to the public one). In normal operation already, all beds in the CTI are occupied, and triage occurs every time a patient shows up. If they get a few thousand Covid-19 cases in the state (which seems plausible), they will be completely out of places to treat them. They key for Brasil is to hold the number of serious cases down (by slowing down infection for as long as possible), without the economic side-effects killing more people.


You're correct, the public health care system of Brazil got by far not the ICU resources as for example the health care system in Germany. My guess is, that everybody (but a few infamous exceptions) in Brazil is aware of this and is sufficiently scared about this, and this is the reason why a vast majority of the people here does not question and supports the precautious measures.
Like a tightrope walker is much more disciplined when walking without a safety net below the rope. In the very moment, in the district where I live, the roads are empty. At the end of last week, in a phone call to a colleague in Germany, I was informed, that in the city where he lives the public movement in the center was reduced by 33 %.

WAIT, WAIT, WAIT, the private health care system seems to be very well equipped, and according to the latest news the government entered into agreement with private hospitals to provide ICU beds to everybody who needs. They showed also a statistic and with this agreement in place, Brazil comes close with 2.63 ICU beds/10k people to the number of ICU beds in Germany 3.04/10k people. They said, only São Paulo got more ICU beds than there are in entire France. However, my wife said "mentira" once she saw this.

Now back to the time series analysis, according to the numbers, we in Brazil need to keep this regime tight for another 3 weeks and then may start to loosen it in a sensible manner. With only a little bit of luck, this can be achieved before the start of winter time.


----------



## obsigna (Mar 25, 2020)

obsigna said:


> I know this of course, and for this reason I wrote _"That means, once a spread has been verified to have passed the turning point, we know with a probability approaching certainty how it ends up."_
> 
> To be sure, that we passed the turning point, the curve fitting must be repeated when new data is available. ...



I just repeated the analysis for Germany and Italy with today's data, and both have clearly passed their turning points and the results are clearly converging, that means the differences in the limiting values as resulted by the day-to-day curve fittings are relatively small.

Italy: 112942 (today) - 115429 (yesterday)
Germany: 47664.1 (today) - 43857.6 (yesterday)

The time series for the U.S. is quite on track even if the turning point would be reached only tomorrow
150944 (today) - 144036  (yesterday)

The time series for Brazil is still quite erratic - it is simply too early, and the turning point cannot be clearly established. Here applies what ralphbsz said, that _"Fitting a logistics curve depends crucially on finding the turning point"_ and so the previsions are very very uncertain, however, it seems that finally the number of cases will be very much lower than in Europe and in the U.S.


----------



## mark_j (Mar 25, 2020)

According to a study done here, we're looking at at best 3 months of so-called "social distancing" and self isolation:








						Coronavirus could be controlled in 13 weeks if 80 per cent of people stay home, data suggests
					

The success or failure of Australia's coronavirus fight relies to a remarkable degree on just one thing, new modelling has found.




					www.abc.net.au
				




All the pre-emptive measures in the world can't help us when stupidity rules:

One of our states was stupid enough to release 2700 people from a cruise ship of which 130 have tested positive while out and about in the general populous. At least I'm 800 kms from that mayhem...


----------



## rigoletto@ (Mar 25, 2020)

obsigna said:


> WAIT, WAIT, WAIT, the private health care system seems to be very well equipped, and according to the latest news the government entered into agreement with private hospitals to provide ICU beds to everybody who needs. They showed also a statistic and with this agreement in place, Brazil comes close with 2.63 ICU beds/10k people to the number of ICU beds in Germany 3.04/10k people. They said, only São Paulo got more ICU beds than there are in entire France. However, my wife said "mentira" once she saw this.



I don't have any idea of how many ICU beds are available in the private sector but my father was in an ICU in Rio a few years ago, and they had about a hundred of beds in there, and that wasn't really one of those top private hospitals. Also, in Rio the 'Riocentro' (huge convention and event center) is already set to be converted in a field hospital if necessary.

We still have the military hospitals which are often well equipped, not crowd and the staff is well prepared.


----------



## obsigna (Mar 25, 2020)

Alain De Vos said:


> I use numpy,pyplot & polyfit,polyval. It will take a week before I know if predictions are ok.
> The model is some wet vinger work.
> The code is so small I don't think I can reduce it using R or Julia
> 
> PS: Why would someone use C for predictive models ?


Why would somebody think that a polynomial is a model?

Why C? Well, I know it. I could have implemented the Levenberg-Marqwardt algorithm in FORTRAN (actually 30 years ago, I happened to use a FOTRAN curve-fitter on the command line). However, it would have never come to my mind to implement the LM algorithm and LU matrix decomposition in Python. Even JavaScript would be faster. That said, I could have simply used the GNU Octaves's (C++) leasqr() function for curve fitting, however, that would have left me anyway with the problem of data extraction.


----------



## Alain De Vos (Mar 25, 2020)

Every tool is good if it does the job.
But why is a logistic function better than another model ? Meaning choice of model can have big impact on prediction certainly farther in the future.


----------



## obsigna (Mar 25, 2020)

Alain De Vos said:


> ...
> But why is a logistic function better than another model?
> ...



I have written in my initial post:


obsigna said:


> As a matter of fact it is THE MODEL for almost all natural growth processes, and it would be extremely surprising if not for the present spread of Covid-19 in given populations. I proved already, that the logistic function described very well the spread in China. So why not in other regions of the world as well.



Besides that I gave tons of links which would tell you everything you always wanted to know about the logistic function and were afraid to ask for.


----------



## Alain De Vos (Mar 25, 2020)

Well , the only time I saw a logistic function was when modeling a neuron.
And I did not say that the logistic function is not the best choice.
Bye the way, tanh has also a nice graph,


----------



## obsigna (Mar 25, 2020)

Alain De Vos said:


> Well , the only time I saw a logistic function was when modeling a neuron.
> And I did not say that the logistic function is not the best choice.


Yeah, electrochemical transport controlled (diffusion and migration limited) processes are 100 % matches for the logistic function. I am an electrochemist and the LF is well known in our field.

PS: Here comes the curve for Belgium with the data of today:





We need to wait a few more days, to be sure, but it seems to be a quite good fit. It says the turning point was today, but because of the deviation of the cases data on the weekend, the fit of tomorrow might tell us otherwise.

```
Model: a/(1 + exp(-b·(x - c)))
       a =   8739.46 ± 6.5144 %
       b =  0.249949 ± 2.5576 %
       c =   63.1012 ± 0.76079 %
  ChiSqr =  1393.336
```

PPS:


Alain De Vos said:


> Bye the way, tanh has also a nice graph,


The tanh function is out of question, because it crosses 0 in an 45° angle. We are looking for a function which starts at 0 with a gradient of 0 and then slowly grows up. The mere exponential function does this as well, however, this is out of question, because it quickly approaches to infinity, and besides it does not fit to the data as nicely as the logistic function does. Here again Belgium with an exponential curve fit:


----------



## Alain De Vos (Mar 25, 2020)

In Belgium there is a capacity of 2000 "high care" beds for Corona of which currently 200 are used.


----------



## obsigna (Mar 25, 2020)

Alain De Vos said:


> In Belgium there is a capacity of 2000 "high care" beds for Corona of which currently 200 are used.


In case the previsions of today's curve fit are better validated in the next few days, then you would need up to 400 beds in the next two weeks. Let's hope for the best, and anyway, let's stay at home.


----------



## ralphbsz (Mar 25, 2020)

obsigna said:


> You're correct, the public health care system of Brazil got by far not the ICU resources as for example the health care system in Germany. My guess is, that everybody (but a few infamous exceptions) in Brazil is aware of this and is sufficiently scared about this, and this is the reason why a vast majority of the people here does not question and supports the precautious measures.


I had the bad luck of spending several weeks doing daily visits to a patient in the ICU of a rural Brasilian hospital (my father). Both times he survived. The care in the ICU was excellent, the doctors well trained, hygiene good, nursing staff plentiful, helpful, and skilled. But in rural Brasil, the number of available ICU beds is low. As I said: Campo Grande has 14 at the Santa Casa (the SUS hospital), and at most another 10 or a dozen at the other three hospitals in town, for a city of 3/4 million people (which is also the supercenter for a state of 2.8 million people (I wrote 4 above, wrong). Of those, 1 (!) is an isolation bed in a separate room. That's WAY below european standards. I just saw in the news that the Uniklinik (university hospital) in Leipzig alone has 14 beds in the isolation ward of the ICU alone, and Leipzig is a medium-size town!

Where things fall apart in Brasil is in the non-intensive non-specialty part of the public health system. The regular parts of the government hospital there has serious problems with staffing, medication, supplies (even alcohol for disinfecting and toilet paper is chronically in short supply, we ended up bringing it). Nutrition for the patients is not good, and the expectation is that families station people in the hospital to be with the patient, to supplant the minimal nursing staff. Been there, done that. Not fun.

And if you go outside of cities, it gets REALLY dire. My parents used to live in a village of 2000 people, about an hour from the nearest city. There is a health post there, with one doctor from 9-5, and two nurses. And one ambulance, but half the time that ambulance is on the way to the city or back. It's better than nothing, but it is not good at all. If you then go to farms that are another hour away from little villages (and where a certain fraction of the rural population lives), health care is non-existing. Only serious cases get brought to cities, often only when they have reached very serious condition.

But then, you can't average rural brasil, not even a provincial capital, with Sao Paulo and Rio, which are big, somewhat wealthy, and international cities. With the wealth, they also have way more private health care, whereas in rural Brasil, the public system takes care of much more.

Let me tell you a little story about how good the Brasilian public health care system is. My dad has heart problems (and many others), and being part German, he got an artificial heart valve in Germany. But he got a hyper-modern one, which didn't require cutting him open like an oyster, but was inserted through the aorta. When he was in the ICU in Brasil, all the cardiologists at the hospital were amazed: they had heard that such things exist, but had never seen such a valve! They asked where he had it implanted, and my sister and me explained that it was the common standard of care for elderly patients in Germany. Then they said that there was only ONE hospital in Brasil that was able to implant those valves: the big SUS hospital in Sao Paulo (no, not the Albert Einstein or the Campinas University one, the public SUS one). We heard similar things from doctors (we spent a lot of time chatting with them) and folks in the elder-care industry (both my parents are in nursing care): the private health system in Brasil is medically decent, comfortable, and caters to the wishes of the middle and upper class. The public health system is unfomfortable, dirty, poor, and excellent. If you have something minor (uncomplicated baby delivery, broken arm), you go to the private medical system for luxury and comfort. If you have something seriously life threatening, you go to the SUS public system, or you fly abroad. Now, I don't know whether this applies also so much in Rio and Sao Paulo; my uncle in Sao Paulo swears by the Albert Einstein hospital, which is clearly very good and private.



> WAIT, WAIT, WAIT, the private health care system seems to be very well equipped, and according to the latest news the government entered into agreement with private hospitals to provide ICU beds to everybody who needs. They showed also a statistic and with this agreement in place, Brazil comes close with 2.63 ICU beds/10k people to the number of ICU beds in Germany 3.04/10k people. They said, only São Paulo got more ICU beds than there are in entire France. However, my wife said "mentira" once she saw this.


Well, "mentira" (which means lies) may be a bit of an exaggeration. A lot depends on how you define "ICU". In Campo Grande, the moment you need a ventilator, you will be in the ICU, or else you will be dead if all 14 beds are occupied. I know that in Germany, they use ventilators in intermediate rooms (better equipped than regular rooms, but not ICU). So comparing the numbers isn't all that easy. So counting what is an ICU bed or not probably depends on local definitions.



> Now back to the time series analysis, according to the numbers, we in Brazil need to keep this regime tight for another 3 weeks and then may start to loosen it in a sensible manner. With only a little bit of luck, this can be achieved before the start of winter time.


Next time you update, if you happen to have graphs for other countries, posting then would be appreciated.


----------



## Crivens (Mar 25, 2020)

That is why I like this place. Someone solves a problem he has,  makes that public, and the sure-as-heck to come  probing (otherwise known as bickering) of the methods is both civil and on a level most people out there won't get. Great.

W.r.t. Russia, my grapevine sings about them stamping almost all deaths of this bug as pneumonia. That may be technically correct.

One lesson learned from this is to check and _heavily control_ the use of antibiotics in livestock management. The areas with high rates of people dying correlates with high-density animal farming. MRSA is a high cause factor here.


----------



## rigoletto@ (Mar 25, 2020)

ralphbsz said:


> my uncle in Sao Paulo swears by the Albert Einstein hospital, which is clearly very good and private.



The two best private hospitals in Brazil are Albert Einstein and Sírio-Libanês, hard to know which one is better (and more luxurious), and a large part (likely the majority) of the doctors in those hospitals, specially the most specialized ones, are also the ones you will meet in the top public ones.

The public ones is where they make their name and the private ones is where they make their wealth.


----------



## obsigna (Mar 25, 2020)

rigoletto@ said:


> I don't have any idea of how many ICU beds are available in the private sector but my father was in an ICU in Rio a few years ago, and they had about a hundred of beds in there, and that wasn't really one of those top private hospitals. Also, in Rio the 'Riocentro' (huge convention and event center) is already set to be converted in a field hospital if necessary.
> 
> We still have the military hospitals which are often well equipped, not crowd and the staff is well prepared.


I also tend to believe, that in extremis a lot of resources can be mobilized by joined efforts. I am still optimistic in respect to the outcome of the situation in Brazil.


----------



## obsigna (Mar 25, 2020)

ralphbsz said:


> I had the bad luck of spending several weeks doing daily visits to a patient in the ICU of a rural Brasilian hospital (my father). Both times he survived. The care in the ICU was excellent, the doctors well trained, hygiene good, nursing staff plentiful, helpful, and skilled. But in rural Brasil, the number of available ICU beds is low. As I said: Campo Grande has 14 at the Santa Casa (the SUS hospital), and at most another 10 or a dozen at the other three hospitals in town, for a city of 3/4 million people (which is also the supercenter for a state of 2.8 million people (I wrote 4 above, wrong). Of those, 1 (!) is an isolation bed in a separate room. That's WAY below european standards. I just saw in the news that the Uniklinik (university hospital) in Leipzig alone has 14 beds in the isolation ward of the ICU alone, and Leipzig is a medium-size town!



Except Hamburg, Berlin and Munich, all towns in Germany are medium sized, compared to world standards.



ralphbsz said:


> Where things fall apart in Brasil is in the non-intensive non-specialty part of the public health system. The regular parts of the government hospital there has serious problems with staffing, medication, supplies (even alcohol for disinfecting and toilet paper is chronically in short supply, we ended up bringing it). Nutrition for the patients is not good, and the expectation is that families station people in the hospital to be with the patient, to supplant the minimal nursing staff. Been there, done that. Not fun.



Hospitals in Dresden and now hospitals in Nordrhein Westfalen were opened for and received already the first patients from northern Italy in order to help out with their capacities. Per Google Maps, Bergamo to Dresden is 951 km and a 10 h drive. Of course this can be done in Brazil and elsewhere as well.



ralphbsz said:


> But then, you can't average rural brasil, not even a provincial capital, with Sao Paulo and Rio, which are big, somewhat wealthy, and international cities. With the wealth, they also have way more private health care, whereas in rural Brasil, the public system takes care of much more.



I do not have much experience with hospitals neither in Brazil nor in Germany. My son was born in a private hospital in São Bernardo do Campo and my daughter was born in the pseudo public IAMSP hospital in São Paulo. The private hospital had a nicer designed interior, but I tend to believe that the professionalism of IAMSP is in front. In both cases everything went well and quick, so we neither did appreciate much the design nor were in need of any seriously critical professional skill.



ralphbsz said:


> Well, "mentira" (which means lies) may be a bit of an exaggeration. A lot depends on how you define "ICU". In Campo Grande, the moment you need a ventilator, you will be in the ICU, or else you will be dead if all 14 beds are occupied. I know that in Germany, they use ventilators in intermediate rooms (better equipped than regular rooms, but not ICU). So comparing the numbers isn't all that easy. So counting what is an ICU bed or not probably depends on local definitions.



I believe that dedication of the medical staff is as least if not more important than the technical resources. Once there was a joke about a German engineer. _"He goes into the jungle having a knife and a tin can, he comes out with a compass on a bicycle."_
I can tell you, this time has gone in Germany, nothing, really nothing is on any level at any scale creatively provisional. I think, a lot of people in Brazil are what German engineers were believed to be long time ago. At least, I don't regret it living in Brazil and not in Germany in the moment.


----------



## obsigna (Mar 25, 2020)

ralphbsz said:


> Next time you update, if you happen to have graphs for other countries, posting then would be appreciated.



Which countries are you interested in?

Perhaps, in my initial post the Quick Start section was too brief. Now I will show step-by-step how to achieve the data extraction and curve fitting for example for Italy:

Checkout the xcssecovid sources from my GitHub repository:
`svnlite co https://github.com/cyclaero/xcssecovid.git/trunk xcssecovid`


Compile the tool:
`cd xcssecovid`
`clang -g0 -O3 -march=native xcssecovid.c -Wno-parentheses -lm -o xcssecovid`


Fetch the Covid-19 data from the GitHub repository of CSSE at the Johns Hopkins University (repeat this daily):
`fetch https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv`


Extract, curve-fit to the logistic function and transpose the data of Italy into a .tsv file:
`./xcssecovid Italy time_series_covid19_confirmed_global.csv Italy.tsv`


Look at the produced TSV file. The parameters which resulted from the curve fitting are at the head:
`head Italy.tsv`

```
# Model: a/(1 + exp(-b·(x - c)))# a = 112942 ± 2.7875 %
# b = 0.199317 ± 1.5662 %
# c = 60.6516 ± 0.4692 %
# ChiSqr = 200158.7
t/d C L
-20 * 0.011789
-19 * 0.014390
-18 * 0.017564
-17 * 0.021437
```


Open the TSV file in your favorite graphing application and look at the curves:






In a semilogarithmic plot, it becomes more apparent that we already left the exponential and entered the logistic regime:




The percentages behind the resulted parameters are estimated standard deviations. This means that the probability that the predicted result within the range of ±std.-dev. will actually occur is 68.3 %. In a range of ±3·std.-dev. the probability would be 99.7 %. Currently the 99.7 % prediction of the outcome of the number of cases in Italy in 2 weeks would be from 109493 - 3·2.79% = *100328* to 109493 + 3·2.79% = *118658*. (Actually it is a bit more complicated, because we would need to take the std.-dev.s of the other parameters into account as well, but presumably this would not change the said range significantly).

For other countries, you would only change the first argument on the xcssecovid command line.

We must not simply believe the curve fit results. It is important to examine the curve and verify that we really passed the turning point of the logistic function. For some countries, the course of the reported spread is everything but logistic, for example Iran. Other countries are still in a very slow exponential regime, for example Australia, and/or the course of the reported cases is somewhat erratic, for example Brazil. In yet other countries a second spread has started on top of the almost finished initial one, for example South Korea.


----------



## PMc (Mar 25, 2020)

Crivens said:


> That is why I like this place. Someone solves a problem he has,  makes that public, and the sure-as-heck to come  probing (otherwise known as bickering) of the methods is both civil and on a level most people out there won't get. Great.
> 
> W.r.t. Russia, my grapevine sings about them stamping almost all deaths of this bug as pneumonia. That may be technically correct.



Well, it is correct. What we happen to have is a flu and a mass hysteria.

There were kinds of flu in the past which were highly contagious, and a flu could always lead to pneumonia, and that could always be fatal, specifically for the old and the weak. There is nothing out of the ordinary.



> One lesson learned from this is to check and _heavily control_ the use of antibiotics in livestock management. The areas with high rates of people dying correlates with high-density animal farming. MRSA is a high cause factor here.



This is not surprizing, but there is a lot more to it. We are used to have vaccination against flu, which lots of people get.
The effect is that the physis does never learn how to go thru a severe infection and survive, which leads to generally less stamina in that regard - because, just like everything in the physis (brain, muscles, etc.), this also has to be trained. And worse, at work we are not expected to be ill for a week or two and go thru it, we are expected to have the modern medicine just switch the illness off. That is against nature.
Furthermore, we have a high population of elderly people, many of these being still alive only because of the features of that modern medicine, and being trained to be dependent on these. Otoh, it was always the task of nature to weed out the old, weak and permanently ill, and that is true for as long as life exists. Over all, the regimen of "modern science" is against nature in almost all regards, and sooner or later that must backfire.


----------



## obsigna (Mar 25, 2020)

FAZ.net: Covid-19 trifft auch die Jungen
Translation to English: Covid-19 hits the young as well


----------



## Crivens (Mar 25, 2020)

PMc well, what we have is a flu that doubles the normal amount of dead people in a city per time. That _is_ not normal.

And we can be really really happy this is something from the tribe of flu and not from f.e. measels. Then the world would be really deep in the popy. Without a depth gauge.


----------



## rigoletto@ (Mar 25, 2020)

Crivens said:


> One lesson learned from this is to check and _heavily control_ the use of antibiotics in livestock management. The areas with high rates of people dying correlates with high-density animal farming. MRSA is a high cause factor here.




There was a article about the concern of the USA with its military personal, specially abroad, because of the high use of prophylactic antibiotics used by the military to treat anything...


----------



## ralphbsz (Mar 26, 2020)

obsigna said:


> Hospitals in Dresden and now hospitals in Nordrhein Westfalen were opened for and received already the first patients from northern Italy in order to help out with their capacities. Per Google Maps, Bergamo to Dresden is 951 km and a 10 h drive. Of course this can be done in Brazil and elsewhere as well.


The first two patients from Italy went to Leipzig last night (saw it in the German newspaper). They were transported in an Italian airforce transport plane, a C130, in isolation intensive care litters, directly from Bergamo to Leipzig. There are impressive pictures in some newspapers ("Die Zeit" hat an article I read). The patients were so critical that they had to be re-stabilized after transport. I haven't had time today to read newspapers; right now is the first time I have 15 minutes of free time today, and it is nearly 11 at night!



> I do not have much experience with hospitals neither in Brazil nor in Germany. My son was born in a private hospital in São Bernardo do Campo and my daughter was born in the pseudo public IAMSP hospital in São Paulo.


Small world! I was born in Campinas, but that was nearly 60 years ago. Unfortunately, I have had too much experience with hospitals in Brasil; that happens whenyou have elderly parents.



> I believe that dedication of the medical staff is as least if not more important than the technical resources.


Exactly. And this is one of the reasons the SUS (the public health system in Brasil) is so good: Well trained and highly caring and dedicated staff.

Regarding your question what countries I'm interested in: Obviously the US. I just haven't had time to download and run your code, been super busy. But I will immediately add a word of warning: It is silly to speak about "the US", because that is an average over vastly different regions. The pandemic first hit in California (right here, in the bay area), and then in New York a few days later. In the meantime, it has grown much larger in New York. But looking at "the US" as a whole ends up averaging totally disparate regions. Bay Area and New York are similarly rich, and similarly well networked internationally, but the Bay Area has much more connection to Asia, in particular China, while New York has much more connection to Europe. The US is also very big, the distance from Seattle to Miami is about like Madrid to Moscow, not just in kilometers, but also in cultural and economic difference. And the US has subregions that are economically and geograpically very distinct; Kentucky and Montana are neither like Boston, or Chicago, or San Francisco. Taking infection statistics and averaging then over all of the US really makes a mess of the data.


----------



## unitrunker (Mar 26, 2020)

I've been using this for reference - but working with the data directly has its own appeal.

https://www.worldometers.info/coronavirus/

Caution: above does have ads in the sidebar.

Looking at the John Hopkins data - the USA data is under "daily reports".

I'm comparing the numbers above to what the State of Texas reports.

https://txdshs.maps.arcgis.com/apps/opsdashboard/index.html#/ed483ecd702b4298ab01e8b9cafc8b83

If that link does not work ... go to the main page and click on the "COVID-19 Dashboard" link.

https://dshs.texas.gov/coronavirus/

The numbers aren't exact 1:1 but seem to agree.


----------



## obsigna (Mar 26, 2020)

ralphbsz said:


> Regarding your question what countries I'm interested in: Obviously the US. I just haven't had time to download and run your code, been super busy. But I will immediately add a word of warning: It is silly to speak about "the US", because ... Taking infection statistics and averaging then over all of the US really makes a mess of the data.



Unfortunately, this is what the CSSE@JHU did on March 23 (the day before I started this thread). Up to March 22, US time series were separated by state and the series of the total numbers was not given. Since then the state's series were removed from the data set, and replaced by the US total time series. The old files with updated series until 2020-03-22 has been archived.



			https://github.com/CSSEGISandData/COVID-19/raw/master/archived_data/archived_time_series/time_series_19-covid-Confirmed_archived_0325.csv
		


With a tiny modifications, my tool can be used to extract and curve fit the data for example of New York and California - but only up to the reported date.
Change line 125 to:

```
if (len != col && (line = strstr(line, country)) && line[cl] == ',')
```
Change line 128 to:

```
for (i = 0; i < 4; i++)
```
Change line 168 to:

```
if (--n > m)
```
Finally, line 197 to:

```
if (isfinite(c[i]) && i < n)
```








The red/blue course belongs to New York and the orange/green course to California. However, in those states the case reports start only on 10th of March and I do not consider the count of case numbers being sufficient for a valid forecast.


----------



## obsigna (Mar 26, 2020)

unitrunker said:


> I've been using this for reference - but working with the data directly has its own appeal.
> 
> https://www.worldometers.info/coronavirus/
> 
> ...


This thread is about analysis of time series and not about the competition on who is able to report the latest and greatest numbers. For analysis of time series, consistency of the data set is the most important factor. Differences of the numbers between data sources can be mostly attributed to different reporting periods, and this must be consistent along the series.

CSSE@JHU provides the whole Covid-19 data set for download. They even do maintain the data set by correcting numbers from previous days if erratas arrive. Can we download somewhere any sort of maintained Covid-19 time series from Worldometer's site? Or from anywhere else?


----------



## unitrunker (Mar 26, 2020)

obsigna said:


> Can we download somewhere any sort of maintained Covid-19 time series from Worldometer's site? Or from anywhere else?


Unknown. If I find such a source, I'll post here. How I got here was compiling my own time series from local reported daily numbers which quickly became a pain.

It's a little odd that the JH data does include USA numbers but omits the data in their time series. Not a big deal to generate the series from the daily files.

As stated above, working directly with the data has its own appeal.


----------



## PMc (Mar 26, 2020)

Crivens said:


> PMc well, what we have is a flu that doubles the normal amount of dead people in a city per time. That _is_ not normal.



Okay. But then, who defines "normal"?
I prefer a different approach: there was a way people used to live, right from the beginning (say minus 100k years, or maybe a million) until about 100 years ago, and it did not change so very much during this long time. That way of living has proven to work, because otherwise we wouldn't be here. 
And there is an other way how people live, that was established during the last 100 years. If you care to look, that way is very different - and it has not yet proven to work.
In the old way, it was normal to grow your own food, and to work mostly outside. It was also normal to get 10 children, where six of them would die before the age of 4.
I don't say the old way was better, I only say, the changes aren't yet verified to be ok (that takes a couple of generations).

In my youth I was told that good food and working mostly outside (or doing things like walking barefoot in the snow) strengthens the resistability against catching a cold and such. Few people nowadays do such things; they rather prefer to believe in antibiotics and medicine.
There are many such little changes, and all together they may explain the death toll.


----------



## unitrunker (Mar 26, 2020)

obsigna said:


> Can we download somewhere any sort of maintained Covid-19 time series from Worldometer's site? Or from anywhere else?



Summary of alternatives. 









						Stay Informed: How To Pull Your Own COVID-19 Data
					

For all the technology we have, it can still be frustratingly difficult to get any concrete information from the media. Sometimes all you want to do is to cut through the noise and see some real nu…




					hackaday.com
				




None look as good as the JH dataset. Turns out the Texas link above derives from the JH dataset.


----------



## obsigna (Mar 26, 2020)

unitrunker said:


> Summary of alternatives.
> 
> 
> 
> ...


OK, I will stay with the CSSE@JHU Covid-19 time series. I am back at the drawing board of modelling now. A group at the Humboldt University in Berlin set up modified SIR differential equations in order to explain why almost all the curves are not exponential ad infinitum: http://rocs.hu-berlin.de/corona/docs/forecast/model/
I know why, because according to Einstein only two things are infinite, the universe and human stupidity, and he continued, that he is even not sure about the former. Anyway, I will build an ODE integrator into my tool, so it can do curve fitting of a set of ordinary differential equations against said CSSE series. Don't tell me that it is not possible to use an ODE solver together with the LM algorithm, I did this in the past several times with success.


----------



## ralphbsz (Mar 26, 2020)

PMc said:


> I prefer a different approach: there was a way people used to live, right from the beginning (say minus 100k years, or maybe a million) until about 100 years ago, and it did not change so very much during this long time. That way of living has proven to work, because otherwise we wouldn't be here.


It worked barely. Humanity was nearly wiped out several times by infectious diseases, such as the bubonic plague. At times, whole parts humanity (geographic, cultural or ethnic groups) were fully wiped out; if you look at the history of for example the pacific island nations or Greenland, quite a few were settled multiple times, because the previous settlers had become extinct. Not to mention wars; the 30 year war was way more brutal than anything in recent memory.

Compared to that, the last 100 years were not particularly worse. Except from an ethical point of views.



> In the old way, it was normal to grow your own food, and to work mostly outside.


That has not been the norm since about roman times in the west, so this is old news.


----------



## Crivens (Mar 26, 2020)

PMc you may be partly right, but almost exactly 100 years ago the spanish flu was out and about. And it killed more people than WW1 did. So the lifestyle does not really serve as an argument. We have factors in both ways. I for one do not know enough of these factors to have a conclusion. But I know whom to ask...


----------



## unitrunker (Mar 26, 2020)

obsigna said:


> according to Einstein only two things are infinite, the universe and human stupidity, and he continued, that he is even not sure about the former.


This made me laugh.


----------



## obsigna (Apr 2, 2020)

obsigna said:


> Unfortunately, this is what the CSSE@JHU did on March 23 (the day before I started this thread). Up to March 22, US time series were separated by state and the series of the total numbers was not given. Since then the state's series were removed from the data set, and replaced by the US total time series. The old files with updated series until 2020-03-22 has been archived. ...



Only a quick note. On April 1, CSSE@JHU put online consolidated time series for the states of the U.S. in separate files. The total count of U.S. cases is still present together with the ROW in the global files - see: https://github.com/CSSEGISandData/COVID-19/tree/master/csse_covid_19_data/csse_covid_19_time_series


----------



## obsigna (Apr 2, 2020)

obsigna said:


> OK, I will stay with the CSSE@JHU Covid-19 time series. I am back at the drawing board of modelling now. A group at the Humboldt University in Berlin set up modified SIR differential equations in order to explain why almost all the curves are not exponential ad infinitum: http://rocs.hu-berlin.de/corona/docs/forecast/model/
> I know why, because according to Einstein only two things are infinite, the universe and human stupidity, and he continued, that he is even not sure about the former. Anyway, I will build an ODE integrator into my tool, so it can do curve fitting of a set of ordinary differential equations against said CSSE series. Don't tell me that it is not possible to use an ODE solver together with the LM algorithm, I did this in the past several times with success.



Done, I updated my xcssecovid tool for FreeBSD or macOS on my Cyclaero GitHub repository. It includes an ODE integrator, and a bunch of options can be set on the command line, and the options are explained in the Usage instructions:
`./xcssecovid -h`

```
Extract, curve fit an epidemiological model and transpose CSSE@JHU's Covid-19 cases data per country - Copyright Dr. Rolf Jansen (c) 2020 - Version 1.0.1
Usage: xcssecovid [-a<0-9> value] [-f (0-9)+] [-m model] [-e] [-r] [-s] [-o day#] [-z day#] [-h|-?|?] <Country> <CSV Input file> <TSV Output File>

       -a<0..9> value      Optionally set initial values for model's parameters the Differential Equation Solver and Curve Fitting.
                           The models deduce its initial parameters from the boundaries of the imported time series and by common
                           knowledge/best educated guesses. Example: -a0 0.57 -a1 125000

       -f (0-9)+           Overrides the default selection of a model's parameters which take part in curve fitting, and which usually is a0, a1, a2.
                           Example: -f 1245 would lead to curve fitting against the paramters a1, a2, a4 and a5, while a0 and a would be left untouched.
                           Different models got different number of parameters, which is currently 3 to 6.

       -m model            Select the model for curve fitting and simulation:
                           - LF   Logistic Function -- https://en.wikipedia.org/wiki/Logistic_function
                           - LDE  Logistic Differential Equation -- https://en.wikipedia.org/wiki/Logistic_function#Logistic_differential_equation
                           - SI   Epidemiological SI-Model (basically another form of the LDE) -- https://de.wikipedia.org/wiki/SI-Modell
                           - SIR  Epidemiological SIR-Model [default] -- https://en.wikipedia.org/wiki/Mathematical_modelling_of_infectious_disease#The_SIR_model

       -e                  Only export the extracted and transposed time series without curve fitting and simulation of the model.

       -r                  Only report the model description and the values of its parameters with or without fitting, but without exporting any curve data.

       -s                  Simulate the model without curve fitting before.

       -o day#             The day# of the first data point in the imported time series to be included for curve fitting.
                           [default: first day with more than 17 cases].

       -z day#             The day# of the last data point in the imported time series to be included for curve fitting.
                           [default: last day of the imported eries].

       -h|-?|?             Show these usage instructions.

       <Country>           Select the country for which the time series shall be processed.

       <CSV Input file>    Path to the CSSE@JHU's Covid-19 time series CSV file.

       <TSV Output File>   Path to the TSV output file containing the extracted and transposed time series for the given <Country>, including
                           a column for a simulated time series by the given model, using the parameter as resulted from curve fitting.
```

Now we may choose among 4 models for post processing the imported CSSE Covid-19 data. The Logistic Function (LF) is still present, which is the analytical solution of the Logistic Differential Equation (LDE). The epidemiological SI Model is just another form of writing down the LDE and got another name, so Epidemiologists feel comfortable with the math behind. Now the SIR model is a set of differential equations based on the SI model and amended by one term, the Removal of infectious individuals from the infection chain. This is the default model of the updated tool.

At the beginning, the LF model resulted in considerably good curve fits. However, on a day to day bases, the resulting parameters were moving, and more and more systematic deviations became evident. This usually means that the model needs a refinement. The LDE and the SI model are only included into the tool for proving that these are essentially the LF model, and would give neither different nor better results. Actually the SIR model is the refinement which does a very good job to the present stage. The day to day curve fittings for Italy, Germany and the U.S. do converge, while the results of the LF = LDE = SI model do diverge.


```
svnlite co https://github.com/cyclaero/xcssecovid.git/trunk xcssecovid
cd xcssecovid
clang -g0 -O3 -march=native xcssecovid.c -Wno-parentheses -lm -o xcssecovid
fetch https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv
./xcssecovid US time_series_covid19_confirmed_global.csv US.tsv
```
`head -15 US.tsv`

```
# US
#
# Model: SIR Differential Equations
#   dy0/dt = -a0/a1·y0·y1         || y0(a5) = a1
#   dy1/dt =  a0/a1·y0·y1 - a3·y1 || y1(a5) = a2
#   dy2/dt =  a3·y1               || y2(a5) = a4
#
#      a0 =   0.623407 ± 0.88468 %
#      a1 =     529773 ± 3.5909 %
#      a2 =    12.6712 ± 13.753 %
#      a3 =   0.333333
#      a4 =         20
#      a5 =         34
#
#  ChiSqr =    1527959
```

Day #71 is April 1. In case a strong containment regime is maintained or even improved, we would see much less new infections per day by the end of April (day #100) in Germany, Italy and the U.S. Here are the curves for the U.S.:









One crucial parameter in the SIR model is a3. This is the rate at which infectious individuals are removed from the infection chain, i.e. by any means won't infect others. 0.333... means that it would take 3 days for an infectious person to be identified and put under effective quarantine, this is roughly 5 days to 1 week after the person was infected him-/herself.


----------



## PMc (Apr 2, 2020)

Crivens said:


> PMc you may be partly right, but almost exactly 100 years ago the spanish flu was out and about.  And it killed more people than WW1 did.



I am most times only partial right - that's human nature. But this is basically what I am saying: such things have happened before - there is nothing out of the ordinary. And yes, it kills people. That is also normal, it fact there is only one thing we know for certain: that we will die.
I travelled quite a bit thru Africa and Asia, and one thing that impressed me very much, is, that death is much more conscious there, as something that is normal and can always happen. Consequentially, life is also more vivid and colourful there, because that relates, and you can't have one without the other. And I for my part enjoyed that freedom much, not being protected 24-hours by buerocrats, but actually being allowed to take care for myself. Only that way I learned that actually Nature -or God, which equates- takes care for me, and I found many things that way, even water in the desert.
In contrast, our super-protected and super-insured, super-sterile western life makes us being full of fear and neurosis that something bad might happen to that life which we most of the time don't really live. But probably, now, we can make a great step forward and reduce ourselves further to mere online-creatures, cage-kept roboters existing only for work and consume.


----------



## obsigna (Apr 2, 2020)

Dead people on Ecuador's streets


----------



## obsigna (Apr 2, 2020)

obsigna said:


> Unfortunately, this is what the CSSE@JHU did on March 23 (the day before I started this thread). Up to March 22, US time series were separated by state and the series of the total numbers was not given. Since then the state's series were removed from the data set, and replaced by the US total time series. The old files with updated series until 2020-03-22 has been archived. ...



Only a quick note. On April 1, CSSE@JHU put online consolidated time series for the states of the U.S. in separate files. The total count of U.S. cases is still present together with the ROW in the global files - see: https://github.com/CSSEGISandData/COVID-19/tree/master/csse_covid_19_data/csse_covid_19_time_series


----------

