WOLFRAM NOTEBOOK

COVID-19 Analysis
Global data from Our World in Data
In[]:=
In[]:=
DateString[]
Out[]=
Tue 9 Mar 2021 09:11:09
Download global data
In[]:=
If[Not[ValueQ[wdata]],wdata=SemanticImport["https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/owid-covid-data.csv"]];(*Keys[wdata[1]]*)
Characteristics of the data
In[]:=
attributes=Length[wdata[1,All]]rows=Length[wdata[All,1]]
Out[]=
59
Out[]=
73384
Extract the data for Australia, Brazil and the USA from the global dataset
In[]:=
UScases=wdataSelect#location
United States
COUNTRY
&,{"date","new_cases"};BRcases=wdataSelect#location
Brazil
COUNTRY
&,{"date","new_cases"};AUcases=wdataSelect#location
Australia
COUNTRY
&,{"date","new_cases"};USdeaths=wdataSelect#location
United States
COUNTRY
&,{"date","new_deaths"};AUdeaths=wdataSelect#location
Australia
COUNTRY
&,{"date","new_deaths"};BRdeaths=wdataSelect#location==
Brazil
COUNTRY
&,{"date","new_deaths"};UStests=wdataSelect#location
United States
COUNTRY
&,{"date","new_tests"};AUtests=wdataSelect#location
Australia
COUNTRY
&,{"date","new_tests"};BRtests=wdataSelect#location
Brazil
COUNTRY
&,{"date","new_tests"};
Plot new cases per day
In[]:=
plotAUcases=DateListPlot[{AUcases},PlotRangeAll,PlotLabel"New Covid-19 Cases per day - Australia"];plotUScases=DateListPlot[{UScases},PlotRangeAll,PlotLabel"New Covid-19 Cases per day - USA"];plotBRcases=DateListPlot[{BRcases},PlotRangeAll,PlotLabel"New Covid-19 Cases per day - Brazil"];
Plot deaths per day
In[]:=
plotUSdeaths=DateListPlot[{USdeaths},PlotRangeAll,PlotLabel"Covid-19 Deaths per day - USA "];plotAUdeaths=DateListPlot[{AUdeaths},PlotRangeAll,PlotLabel"Covid-19 Deaths per day - Australia"];plotBRdeaths=DateListPlot[{BRdeaths},PlotRangeAll,PlotLabel"Covid-19 Deaths per day - Brazil"];
Plot tests per day
In[]:=
plotUStests=DateListPlot[{UStests},PlotRangeAll,PlotLabel"Covid-19 Tests per day - USA "];plotAUtests=DateListPlot[{AUtests},PlotRangeAll,PlotLabel"Covid-19 Tests per day - Australia"];plotBRtests=DateListPlot[{BRtests},PlotRangeAll,PlotLabel"Covid-19 Tests per day - Brazil"];
Display the plots
In[]:=
GraphicsRow[{plotAUcases,plotAUdeaths,plotAUtests}]GraphicsRow[{plotUScases,plotUSdeaths,plotUStests}]GraphicsRow[{plotBRcases,plotBRdeaths,plotBRtests}]
Out[]=
Out[]=
Out[]=
Lag hypothesisIn online discussion several people claimed the unusual relationship between new cases and new deaths in the USA could be explained by a lag between infection and death.The following section computes normalised samples of deaths and new cases so they can be plotted on the same chart.
In[]:=
d=GaussianFilter[USdeaths[All,"new_deaths"],10]//Normal;m=Mean[d];max=Max[d];min=Min[d];(*a=ListLinePlot[(d-m)/(max-min),PlotRange->All,PlotStyle{Black}];*)a=ListLinePlot[d,PlotRange->All,PlotStyle{Black}];d=GaussianFilter[UScases[All,"new_cases"]*1.7/100,10]//Normal;m=Mean[d];max=Max[d];min=Min[d];(*b=ListLinePlot[(d-m)/(max-min),PlotRange->All,PlotStyle{Red}];*)b=ListLinePlot[d,PlotRange->All,PlotStyle{Red}];
GaussianFilter
:The first argument Dataset[411] is neither a rectangular array nor an image.
GaussianFilter
:The first argument 0.017(Dataset[411]) is neither a rectangular array nor an image.
In[]:=
Show[a,b,AxesLabel{HoldForm[Days],RawBoxes[RowBox[{RowBox[{"Normalised"," ","infections"}],","," ","deaths"}]]},PlotLabelHoldForm[USA],LabelStyle{GrayLevel[0]}]
Out[]=
The chart shows cases leading deaths, but after 160 days the lines diverge. The noticeable departure between infections per day and deaths per day cannot be explained by a lag between infection and death.
Until late July 2020 infections per day data was published by the CDC and deaths per day by the US government. In late July 2020 the US government required new infections per day be reported directly to the US government rather than the CDC. It will be interesting to see if infections per day change to match deaths per day after this.
SwedenSweden is offered as an example of what can happen if you dont bother with travel restrictions or social isolation policies (CountryData[Sweden, population])Lets compare Sweden with Denmark and Norway, which both followed WHO recommendations.
In[]:=
SWcases=wdataSelect#location
Sweden
COUNTRY
&,{"date","new_cases"};SWdeaths=wdataSelect#location
Sweden
COUNTRY
&,{"date","new_deaths"};DEcases=wdataSelect#location
Denmark
COUNTRY
&,{"date","new_cases"};DEdeaths=wdataSelect#location
Denmark
COUNTRY
&,{"date","new_deaths"};NGcases=wdataSelect#location
Norway
COUNTRY
&,{"date","new_cases"};NGdeaths=wdataSelect#location
Norway
COUNTRY
&,{"date","new_deaths"};plotSWcases=DateListPlot[{SWcases},PlotRangeAll,PlotLabel"New Covid-19 Cases per day - Sweden"];plotSWdeaths=DateListPlot[{SWdeaths},PlotRangeAll,PlotLabel"Covid-19 Deaths per day - Sweden"];plotDEcases=DateListPlot[{DEcases},PlotRangeAll,PlotLabel"New Covid-19 Cases per day - Denmark"];plotDEdeaths=DateListPlot[{DEdeaths},PlotRangeAll,PlotLabel"Covid-19 Deaths per day - Denmark"];plotNGcases=DateListPlot[{NGcases},PlotRangeAll,PlotLabel"New Covid-19 Cases per day - Norway"];plotNGdeaths=DateListPlot[{NGdeaths},PlotRangeAll,PlotLabel"Covid-19 Deaths per day - Norway"];Spop=CountryData["Sweden","Population"]Dpop=CountryData["Denmark","Population"]Npop=CountryData["Norway","Population"]GraphicsRow[{plotSWcases,plotSWdeaths}]GraphicsRow[{plotDEcases,plotDEdeaths}]GraphicsRow[{plotNGcases,plotNGdeaths}]
Wolfram Cloud

You are using a browser not supported by the Wolfram Cloud

Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


I understand and wish to continue anyway »

You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.