Covid-19 : US, US States, and CA counties
Author, Richard Frost - http://tangentvectors.org/
Use at your own risk.
Author, Richard Frost - http://tangentvectors.org/
Use at your own risk.
======= INITIALIZATIONS =======
======= INITIALIZATIONS =======
In[]:=
dateFormat="yyyy/mm/dd";
In[]:=
dateTickFormat={"MonthShort","/","Day"};
In[]:=
onePerson=Quantity[1,"People"];
In[]:=
oneDay=;
In[]:=
iSize=512;
In[]:=
hyperEpidemicMagnitude=0.04;
In[]:=
hyperEpidemicLevel=Quantity[hyperEpidemicMagnitude,"Percent"];
In[]:=
hyperEpidemicLevelInf=hyperEpidemicLevel-Quantity[0.01,"Percent"];
======= INPUT DATA =======
======= INPUT DATA =======
----- Covid-19 deaths -----
In[]:=
analysisURL="http://tangentvectors.org";
In[]:=
dataSourcesURL="http://tangentvectors.org/DataSources.csv";
In[]:=
dataSourcesTable=Import[dataSourcesURL];
In[]:=
dataSourcesTable//Grid
Out[]=
Data | Source | Source Data URL |
Historic US | The COVID Tracking Project | https://covidtracking.com/api/v1/us/daily.csv |
Historic US State | The COVID Tracking Project | https://covidtracking.com/api/v1/states/daily.csv |
Historic CA County | California Health and Human Services | https://data.chhs.ca.gov/dataset/6882c390-b2d7-4b9a-aefa-2068cee63e47/resource/6cd8d424-dfaa-4bdd-9410-a3d656e1176e/download/covid19data.csv |
In[]:=
USdeathsCreditsText="Data Source: "<>dataSourcesTable[[2,2]]<>" "<>"Data Analysis: "<>analysisURL;
In[]:=
USdeathsCreditsStyledText=Style[Text[USdeathsCreditsText],Black,Small];
In[]:=
USdeathsCredits=Graphics[USdeathsCreditsStyledText,ImageSize{384,12}]
Out[]=
In[]:=
CAdeathsCreditsText="Data Source: "<>dataSourcesTable[[4,2]]<>" "<>"Data Analysis: "<>analysisURL;
In[]:=
CAdeathsCreditsStyledText=Style[Text[CAdeathsCreditsText],Black,Small];
In[]:=
CAdeathsCredits=Graphics[CAdeathsCreditsStyledText,ImageSize{416,12}]
Out[]=
In[]:=
USdataURL=dataSourcesTable[[2,3]];
In[]:=
USrevDataTable=Import[USdataURL];
In[]:=
USdataHeader=USrevDataTable[[1]]
Out[]=
{date,states,positive,negative,pending,hospitalizedCurrently,hospitalizedCumulative,inIcuCurrently,inIcuCumulative,onVentilatorCurrently,onVentilatorCumulative,recovered,dateChecked,death,hospitalized,lastModified,total,totalTestResults,posNeg,deathIncrease,hospitalizedIncrease,negativeIncrease,positiveIncrease,totalTestResultsIncrease,hash}
In[]:=
CTPdateHeader="date";
In[]:=
CTPdeathHeader="death";
In[]:=
USrawDataTable=Reverse[USrevDataTable[[2;;]]];
In[]:=
Take[USrawDataTable,1]
Out[]=
{{20200122,1,1,,,,,,,,,,2020-01-22T00:00:00Z,,,2020-01-22T00:00:00Z,1,1,1,0,0,0,0,0,615132d06fd9e22bc21b1b3ec47fb9b2a0de0734}}
In[]:=
StatesDataURL=dataSourcesTable[[3,3]];
In[]:=
StatesRevDataTable=Import[StatesDataURL];
In[]:=
StatesDataHeader=StatesRevDataTable[[1]]
Out[]=
{date,state,positive,negative,pending,hospitalizedCurrently,hospitalizedCumulative,inIcuCurrently,inIcuCumulative,onVentilatorCurrently,onVentilatorCumulative,recovered,dataQualityGrade,lastUpdateEt,dateModified,checkTimeEt,death,hospitalized,dateChecked,fips,positiveIncrease,negativeIncrease,total,totalTestResults,totalTestResultsIncrease,posNeg,deathIncrease,hospitalizedIncrease,hash,commercialScore,negativeRegularScore,negativeScore,positiveScore,score,grade}
In[]:=
CTPstateHeader="state";
In[]:=
StatesRawDataTable=Reverse[StatesRevDataTable[[2;;]]];
In[]:=
Take[StatesRawDataTable,1]
Out[]=
{{20200122,WA,1,,,,,,,,,,,,,,,,,53,0,0,1,1,0,1,0,0,3f9b3067fb6e1b79d174e867e388ae24d90de6e3,0,0,0,0,0,}}
In[]:=
CAcountiesDataURL=dataSourcesTable[[4,3]];
In[]:=
CAcountiesRawData=Import[CAcountiesDataURL];
In[]:=
CAcountiesDataHeader=CAcountiesRawData[[1]]
Out[]=
{County Name,Most Recent Date,Total Count Confirmed,Total Count Deaths,COVID-19 Positive Patients,Suspected COVID-19 Positive Patients,ICU COVID-19 Positive Patients,ICU COVID-19 Suspected Patients}
In[]:=
CHHScountNameHeader="County Name";
In[]:=
CHHSdateHeader="Most Recent Date";
In[]:=
CHHSdeathHeader="Total Count Deaths";
In[]:=
CAcountiesRawDataTable=CAcountiesRawData[[2;;]];
In[]:=
Take[CAcountiesRawDataTable,3]//Grid
Out[]=
Los Angeles | 4/1/2020 | 3502 | 66 | 739 | 1332 | 335 | 220 |
San Bernardino | 4/1/2020 | 245 | 5 | 95 | 196 | 39 | 52 |
Orange | 4/1/2020 | 579 | 11 | 117 | 221 | 50 | 48 |
----- Population data -----
In[]:=
USpopulationsURL="http://tangentvectors.org/USPopulations.csv";
In[]:=
USpopTable=Import[USpopulationsURL];
In[]:=
Take[USpopTable,3]//Grid
Out[]=
Entity | Population |
US | 331818309 |
AK | 731545 |
In[]:=
USpopHash=CreateDataStructure["HashTable"];
In[]:=
Do[USpopHash["Insert",USpopTable[[n,1]]USpopTable[[n,2]]],{n,2,Length[USpopTable]}];
In[]:=
CApopulationsURL="http://tangentvectors.org/CAPopulations.csv";
In[]:=
CApopTable=Import[CApopulationsURL];
In[]:=
Take[CApopTable,3]//Grid
Out[]=
County | Population |
Alameda | 1669301 |
Alpine | 1162 |
In[]:=
CApopHash=CreateDataStructure["HashTable"];
In[]:=
Do[CApopHash["Insert",CApopTable[[n,1]]CApopTable[[n,2]]],{n,2,Length[CApopTable]}];
----- CA phased openings -----
In[]:=
CAPhaseDatesURL="http://tangentvectors.org/CAPhaseDates.csv";
In[]:=
CAPhaseDatesCSVTable=Import[CAPhaseDatesURL];
In[]:=
CAPhaseDatesTable={#[[1]],DateObject[#[[2]]]}&/@CAPhaseDatesCSVTable;
In[]:=
CAPhaseDatesTable//Grid
Out[]=
Phase 1 | |
Phase 2 | |
Phase 3 |
In[]:=
nonPhase3countiesMayURL="http://tangentvectors.org/CANonPhase3CountiesMay.csv";
In[]:=
nonPhase3countiesMayTable=Import[nonPhase3countiesMayURL];
In[]:=
nonPhase3countiesMayList=nonPhase3countiesMayTable[[4,2]]
Out[]=
Alameda, Contra Costa, Imperial, Los Angeles, Marin, Monterey, San Francisco, San Mateo, Santa Clara, Santa Cruz
======= US ANALYSIS =======
======= US ANALYSIS =======
----- establish current data -----
In[]:=
USdateI=Table[If[USdataHeader[[m]]CTPdateHeader,m,Nothing],{m,1,Length[USdataHeader]}][[1]]
DateObject[“string”] prefers “yyyy/mm/dd”
----- compute extrapolations -----
--- goals ---
--- trend data ---
--- linear fit ---
----- make the graph -----
======= US STATES ANALYSIS =======
======= US STATES ANALYSIS =======
----- establish current data -----
Next find the 1st non-zero dates for each state. Start with StatesNullTable
======= CA COUNTIES ANALYSIS =======
======= CA COUNTIES ANALYSIS =======