(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 12.1' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 1876735, 37483] NotebookOptionsPosition[ 1835721, 36864] NotebookOutlinePosition[ 1836218, 36883] CellTagsIndexPosition[ 1836175, 36880] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell["\<\ Epidemiological Models for COVID-19. Application to Spain prediction\ \>", "Title", CellChangeTimes->{{3.7923123501743193`*^9, 3.7923123715733337`*^9}, { 3.7939485054610243`*^9, 3.7939485294186106`*^9}, {3.7939759871373577`*^9, 3.7939759950123854`*^9}, {3.7943846683092504`*^9, 3.794384672873835*^9}, { 3.7946445980521994`*^9, 3.7946445984164343`*^9}, {3.7948861508535614`*^9, 3.7948861513614645`*^9}, {3.795059663421817*^9, 3.795059663923224*^9}, { 3.7953205608936973`*^9, 3.7953205861383047`*^9}},ExpressionUUID->"eaf95af9-27df-4816-aa31-\ 76f05f0b15c0"], Cell["\<\ Guillermo S\[AAcute]nchez, Juan M. Rodr\[IAcute]guez D\[IAcute]az, Jes\ \[UAcute]s L. Fidalgo . \ \>", "Author", CellChangeTimes->{{3.792876117360289*^9, 3.7928761526216288`*^9}, { 3.792919958645753*^9, 3.792919958797267*^9}, {3.7939485776022797`*^9, 3.7939486111938515`*^9}, {3.7940339238550396`*^9, 3.7940339351948404`*^9}, {3.7940342329216456`*^9, 3.7940342738675404`*^9}, {3.794384702041641*^9, 3.7943847027082567`*^9}, { 3.794472091745128*^9, 3.794472092195923*^9}, {3.794554906450611*^9, 3.794554912169262*^9}, {3.794644583709612*^9, 3.7946445898023*^9}, { 3.7946550914850793`*^9, 3.7946550920883875`*^9}, {3.7948005478938274`*^9, 3.7948005635351243`*^9}, {3.794804315879011*^9, 3.794804320162406*^9}, { 3.7948079190351734`*^9, 3.7948079193161435`*^9}, {3.794834954799553*^9, 3.7948349622473316`*^9}, {3.7948841599063187`*^9, 3.7948841710329075`*^9}, {3.794888464972209*^9, 3.794888468566042*^9}, { 3.794891027742714*^9, 3.794891035122764*^9}, {3.794892084676155*^9, 3.7948920867909036`*^9}, {3.7948959473695292`*^9, 3.794895950620632*^9}, { 3.7949012320985775`*^9, 3.7949012373172207`*^9}, {3.794920288652337*^9, 3.7949202956658115`*^9}, {3.7949268628702745`*^9, 3.794926868012559*^9}, { 3.7949766345093403`*^9, 3.794976639370721*^9}, {3.7950597200521145`*^9, 3.7950597209645433`*^9}, {3.795151850993823*^9, 3.7951518523910885`*^9}, { 3.7952331498142624`*^9, 3.795233150268075*^9}, {3.7953157541535063`*^9, 3.7953157546254063`*^9}, {3.7953205113046117`*^9, 3.7953205567766623`*^9}, 3.7953211755601563`*^9},ExpressionUUID->"92597376-7ce2-47eb-8add-\ 11ff8bccf552"], Cell[TextData[ButtonBox["http://diarium.usal.es/guillermo/mathematica/\ modelizacion-covid-19/", BaseStyle->"Hyperlink", ButtonData->{ URL["http://diarium.usal.es/guillermo/mathematica/modelizacion-covid-19/"], None}, ButtonNote-> "http://diarium.usal.es/guillermo/mathematica/modelizacion-covid-19/"]], \ "Text", CellChangeTimes->{{3.795321241516058*^9, 3.795321262271841*^9}},ExpressionUUID->"490c8d54-8bae-40d2-ad55-\ 372b85131e5d"], Cell["Updated :", "Item", CellChangeTimes->{{3.795321177936613*^9, 3.7953211985316315`*^9}},ExpressionUUID->"954471e2-c574-4923-b2b7-\ ff96854c8110"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"DateObject", "[", "]"}]], "Input", CellChangeTimes->{{3.7949764667842984`*^9, 3.7949764710511503`*^9}, { 3.7949765597871113`*^9, 3.7949765774950953`*^9}, 3.7949766106710825`*^9}, CellLabel->"In[40]:=",ExpressionUUID->"8ee74037-186c-4e50-9e9c-39319f89fc27"], Cell[BoxData[ TemplateBox[{ RowBox[{"\"Wed 8 Apr 2020 09:20:35\"", StyleBox[ RowBox[{"\"GMT+\"", "\[InvisibleSpace]", StyleBox["2.`", NumberMarks -> False, StripOnInput -> False]}], FontColor -> GrayLevel[0.5]]}], RowBox[{"DateObject", "[", RowBox[{ RowBox[{"{", RowBox[{ "2020", ",", "4", ",", "8", ",", "9", ",", "20", ",", "35.1696967`9.298743516716677"}], "}"}], ",", "\"Instant\"", ",", "\"Gregorian\"", ",", "2.`"}], "]"}]}, "DateObject", Editable->False]], "Output", CellChangeTimes->{3.794976615828722*^9, 3.7949859110603485`*^9, 3.7950104141173487`*^9, 3.7950597057769604`*^9, 3.7950874073274527`*^9, 3.7951486015440493`*^9, 3.7951518405672674`*^9, 3.795154240492998*^9, 3.795157195820448*^9, 3.7951591913609457`*^9, 3.795233154749442*^9, 3.79526069313813*^9, 3.7953157580682545`*^9, 3.795319235215669*^9}, CellLabel->"Out[40]=",ExpressionUUID->"92b12661-7742-4dc9-8df0-c5bf5f80da1a"] }, Open ]], Cell[CellGroupData[{ Cell["Introducci\[OAcute]n", "Section", CellChangeTimes->{{3.792312404508266*^9, 3.792312406580225*^9}, { 3.7953204355209646`*^9, 3.795320436308607*^9}, {3.7953207485918417`*^9, 3.7953207494926004`*^9}},ExpressionUUID->"8b75c487-07b1-48e9-b3f3-\ ffb602fa4631"], Cell[TextData[{ "Este documento sirve de base para la realizaci\[OAcute]n de predicciones \ realizadas por el DOE USAL como contribuci\[OAcute]n a ", ButtonBox["http://matematicas.uclm.es/cemat/covid19/", BaseStyle->"Hyperlink", ButtonData->{ URL["http://matematicas.uclm.es/cemat/covid19/"], None}, ButtonNote->"http://matematicas.uclm.es/cemat/covid19/"] }], "Text", CellChangeTimes->{{3.794033456336549*^9, 3.794033500712623*^9}, { 3.794033584189886*^9, 3.7940336956341977`*^9}, {3.794384689585354*^9, 3.79438469209039*^9}, {3.7943848114737253`*^9, 3.7943848427056885`*^9}, { 3.7945549930443225`*^9, 3.7945549962633495`*^9}, {3.795320445150815*^9, 3.7953205052070713`*^9}, {3.7953206161313457`*^9, 3.7953206436641455`*^9}},ExpressionUUID->"080fa5f7-0b1c-4a4c-a368-\ 5bd62c3c0c2c"], Cell[BoxData[ RowBox[{ RowBox[{"SetDirectory", "@", RowBox[{"NotebookDirectory", "[", "]"}]}], ";"}]], "Input", InitializationCell->True, CellChangeTimes->{{3.793138151449808*^9, 3.793138214424975*^9}, { 3.7944039194158115`*^9, 3.7944039199556775`*^9}}, CellLabel->"In[1]:=",ExpressionUUID->"5b363478-0b32-4bbb-8b70-327ce7ecc93a"], Cell["Nosotros utilizamos Mathematica", "Text", CellChangeTimes->{{3.795320674869462*^9, 3.795320728679598*^9}},ExpressionUUID->"938dbb3d-4926-415f-b34a-\ 7a4638866abc"], Cell[TextData[{ "Recursos sobre COVID-29 con Mathematica: ", ButtonBox["https://community.wolfram.com/groups/-/m/t/1872608", BaseStyle->"Hyperlink", ButtonData->{ URL["https://community.wolfram.com/groups/-/m/t/1872608"], None}, ButtonNote->"https://community.wolfram.com/groups/-/m/t/1872608"] }], "Item", CellChangeTimes->{{3.79447194128531*^9, 3.794471975507897*^9}, { 3.794472053225839*^9, 3.7944720876383085`*^9}, {3.794975863128545*^9, 3.7949759319491076`*^9}},ExpressionUUID->"e3b93ec8-9373-48b4-b7c2-\ 0d865ff9d5ab"] }, Open ]], Cell[CellGroupData[{ Cell["COVID en el Mundo", "Section", CellChangeTimes->{{3.7949175404617224`*^9, 3.794917556776309*^9}},ExpressionUUID->"3d785454-0c47-4edf-ba3f-\ 79c15bdd1bd6"], Cell[TextData[{ "The Johns Hopkins University data are available from the Wolfram Data \ Repository, and are described at ", ButtonBox["https://www.wolframcloud.com/obj/resourcesystem/published/\ DataRepository/resources/Epidemic-Data-for-Novel-Coronavirus-COVID-19", BaseStyle->"Hyperlink", ButtonData->{ URL["https://www.wolframcloud.com/obj/resourcesystem/published/\ DataRepository/resources/Epidemic-Data-for-Novel-Coronavirus-COVID-19"], None}, ButtonNote-> "https://www.wolframcloud.com/obj/resourcesystem/published/DataRepository/\ resources/Epidemic-Data-for-Novel-Coronavirus-COVID-19"] }], "Item", CellChangeTimes->{{3.791749231190363*^9, 3.791749242238349*^9}, { 3.792343271028222*^9, 3.7923432718217573`*^9}, {3.792604448206852*^9, 3.792604480013967*^9}, {3.792604523129162*^9, 3.7926045346356907`*^9}, { 3.7926045651303596`*^9, 3.7926045721388693`*^9}},ExpressionUUID->"15198c46-b371-4b50-8a64-\ f4bfcfdae97d"], Cell[BoxData[ RowBox[{ RowBox[{"covid19Data", "=", RowBox[{ "ResourceData", "[", "\"\\"", "]"}]}], ";"}]], "Input", CellChangeTimes->{{3.7926007046019697`*^9, 3.7926007151812553`*^9}, 3.794917648856044*^9}, CellLabel->"In[53]:=",ExpressionUUID->"ed40dc68-99cd-45a6-9ed3-b764da523a6d"], Cell[TextData[{ "The function ", Cell[BoxData[ FormBox[ StyleBox["fitDataWDR", "Code"], TraditionalForm]],ExpressionUUID-> "b9bc3779-91ea-45ca-a2da-1d483099dfc7"], "provides convenient access to the data for modeling" }], "Item", CellChangeTimes->{{3.7923434309490223`*^9, 3.79234345243746*^9}, { 3.79268572414809*^9, 3.792685735532597*^9}, {3.792686193649024*^9, 3.792686193649066*^9}, {3.792876365872123*^9, 3.792876380006578*^9}, { 3.7928764934120293`*^9, 3.792876493413371*^9}, 3.7949179081230946`*^9},ExpressionUUID->"894237f7-48e5-48f0-87f4-\ e466b472a629"], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"?", "fitDataWDR"}]], "Input", CellChangeTimes->{{3.7926857087366133`*^9, 3.792685709574087*^9}, 3.7926861952252607`*^9}, CellLabel->"In[54]:=",ExpressionUUID->"22b5a605-c416-407c-bed8-82883548b3f5"], Cell[BoxData[ InterpretationBox[ StyleBox[ FrameBox[ DynamicModuleBox[{System`InformationDump`open$$ = False, System`InformationDump`mouseOver$$ = False}, PaneSelectorBox[{True-> TagBox[GridBox[{ { ItemBox[ PaneBox[ StyleBox["\<\" Symbol\"\>", "InformationTitleText", StripOnInput->False, BaseStyle -> None], FrameMargins->{{4, 0}, {-1, 1}}], BaseStyle->"InformationTitleBackground", StripOnInput->False], ItemBox["\<\"\"\>", BaseStyle->"InformationTitleBackground", StripOnInput->False]}, { ItemBox[ PaneBox[ StyleBox["\<\"fitDataWDR[locale, startDate] gives data for \ infected, recovered, and dead relative to the given date for the onset of \ infection for the given locale, either an administrative division or a \ country. For reference, cases were first reported on 31 Dec 2019.\"\>", "InformationUsageText", StripOnInput->False, LineSpacing->{1.5, 1.5, 3.}], FrameMargins->{{10, 10}, {8, 10}}], BaseStyle->"InformationUsageSubtitleBackground", StripOnInput->False], ItemBox["\<\"\"\>", BaseStyle->"InformationUsageSubtitleBackground", StripOnInput->False]}, { PaneBox[GridBox[{ { DynamicModuleBox[{System`InformationDump`open$$ = { False, False, False, False, False, False, False, False, False, False, False, False}}, StyleBox[GridBox[{ { TagBox[ TooltipBox[ StyleBox["\<\" Definitions\"\>", "InformationRowLabel", StripOnInput->False], "\"Definitions\"", TooltipStyle->"TextStyling"], Annotation[#, "Definitions", "Tooltip"]& ], GridBox[{ { RowBox[{ RowBox[{"fitDataWDR", "[", RowBox[{ RowBox[{"locale", ":", RowBox[{ RowBox[{"Entity", "[", RowBox[{"\<\"AdministrativeDivision\"\>", ",", "_"}], "]"}], "|", RowBox[{"Entity", "[", RowBox[{"\<\"Country\"\>", ",", "_"}], "]"}]}]}], ",", "date0_", ",", RowBox[{"opts", ":", RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", RowBox[{"Module", "[", RowBox[{ RowBox[{"{", RowBox[{ "covid19Data", ",", "confirmed", ",", "recovered", ",", "dead", ",", "correctionQ", ",", "dateRange"}], "}"}], ",", RowBox[{ RowBox[{"covid19Data", "=", RowBox[{ "ResourceData", "[", "\<\"Epidemic Data for Novel Coronavirus \ COVID-19\"\>", "]"}]}], ";", RowBox[{"Switch", "[", RowBox[{"locale", ",", "\[IndentingNewLine]", RowBox[{"Entity", "[", RowBox[{"\<\"AdministrativeDivision\"\>", ",", "_"}], "]"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{"!", RowBox[{"MemberQ", "[", RowBox[{ RowBox[{"covid19Data", "[", RowBox[{"All", ",", "\<\"AdministrativeDivision\"\>"}], "]"}], ",", "locale"}], "]"}]}], ",", RowBox[{ RowBox[{"Message", "[", RowBox[{ StyleBox[ RowBox[{"fitDataWDR", "::", "locnf"}], "MessageName"], ",", "locale"}], "]"}], ";", RowBox[{"Return", "[", "$Failed", "]"}]}]}], "]"}], ",", "\[IndentingNewLine]", RowBox[{"Entity", "[", RowBox[{"\<\"Country\"\>", ",", "_"}], "]"}], ",", RowBox[{"If", "[", RowBox[{ RowBox[{"!", RowBox[{"MemberQ", "[", RowBox[{ RowBox[{"covid19Data", "[", RowBox[{"All", ",", "\<\"Country\"\>"}], "]"}], ",", "locale"}], "]"}]}], ",", RowBox[{ RowBox[{"Message", "[", RowBox[{ StyleBox[ RowBox[{"fitDataWDR", "::", "locnf"}], "MessageName"], ",", "locale"}], "]"}], ";", RowBox[{"Return", "[", "$Failed", "]"}]}]}], "]"}]}], "]"}], ";", RowBox[{"correctionQ", "=", RowBox[{ "OptionValue", "[", "\<\"makeCorrectionForHubei\"\>", "]"}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"MatchQ", "[", RowBox[{"correctionQ", ",", RowBox[{"Except", "[", RowBox[{"True", "|", "False"}], "]"}]}], "]"}], ",", RowBox[{ RowBox[{"Message", "[", RowBox[{ StyleBox[ RowBox[{"fitDataWDR", "::", "opttf"}], "MessageName"], ",", "\<\"makeCorrectionForHubei\"\>", ",", "correctionQ"}], "]"}], ";", RowBox[{"Return", "[", "$Failed", "]"}]}]}], "]"}], ";", RowBox[{"dateRange", "=", RowBox[{"OptionValue", "[", "\<\"dateRange\"\>", "]"}]}], ";", RowBox[{"dateRange", "=", RowBox[{"Switch", "[", RowBox[{ "dateRange", ",", "\[IndentingNewLine]", "All", ",", RowBox[{ RowBox[{"covid19Data", "\[LeftDoubleBracket]", RowBox[{"1", ",", "\<\"ConfirmedCases\"\>"}], "\[RightDoubleBracket]"}], "/@", RowBox[{"{", RowBox[{"\<\"FirstDate\"\>", ",", "\<\"LastDate\"\>"}], "}"}]}], ",", "\[IndentingNewLine]", RowBox[{"{", RowBox[{"_", ",", "_"}], "}"}], ",", RowBox[{ RowBox[{"dateRange", "=", RowBox[{ RowBox[{"(", RowBox[{ RowBox[{"Quiet", "[", RowBox[{"DateObject", "[", RowBox[{"#1", ",", "\<\"Instant\"\>"}], "]"}], "]"}], "&"}], ")"}], "/@", RowBox[{"(", RowBox[{"dateRange", "//.", "\[VeryThinSpace]", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"All", ",", "b_"}], "}"}], "\[RuleDelayed]", RowBox[{"{", RowBox[{ RowBox[{ RowBox[{"covid19Data", "\[LeftDoubleBracket]", RowBox[{"1", ",", "\<\"ConfirmedCases\"\>"}], "\[RightDoubleBracket]"}], "[", "\<\"FirstDate\"\>", "]"}], ",", "b"}], "}"}]}], ",", RowBox[{ RowBox[{"{", RowBox[{"a_", ",", "All"}], "}"}], "\[RuleDelayed]", RowBox[{"{", RowBox[{"a", ",", RowBox[{ RowBox[{"covid19Data", "\[LeftDoubleBracket]", RowBox[{"1", ",", "\<\"ConfirmedCases\"\>"}], "\[RightDoubleBracket]"}], "[", "\<\"LastDate\"\>", "]"}]}], "}"}]}]}], "}"}]}], ")"}]}]}], ";", RowBox[{"If", "[", RowBox[{ RowBox[{"MatchQ", "[", RowBox[{"dateRange", ",", RowBox[{"{", RowBox[{ RowBox[{"DateObject", "[", RowBox[{ RowBox[{"{", "__", "}"}], ",", "_String", ",", "_String", ",", "_Real"}], "]"}], ",", RowBox[{"DateObject", "[", RowBox[{ RowBox[{"{", "__", "}"}], ",", "_String", ",", "_String", ",", "_Real"}], "]"}]}], "}"}]}], "]"}], ",", "dateRange", ",", RowBox[{ RowBox[{"Message", "[", RowBox[{ StyleBox[ RowBox[{"fitDataWDR", "::", "optvg"}], "MessageName"], ",", "\<\"dateRange\"\>", ",", RowBox[{"OptionValue", "[", "\<\"dateRange\"\>", "]"}], ",", "\<\"All or a list of two dates\"\>"}], "]"}], ";", RowBox[{"Return", "[", "$Failed", "]"}]}]}], "]"}]}], ",", "\[IndentingNewLine]", "_", ",", RowBox[{ RowBox[{"Message", "[", RowBox[{ StyleBox[ RowBox[{"fitDataWDR", "::", "optvg"}], "MessageName"], ",", "\<\"dateRange\"\>", ",", RowBox[{"OptionValue", "[", "\<\"dateRange\"\>", "]"}], ",", "\<\"All or a list of two dates\"\>"}], "]"}], ";", RowBox[{"Return", "[", "$Failed", "]"}]}]}], "]"}]}], ";", RowBox[{"Switch", "[", RowBox[{"locale", ",", "\[IndentingNewLine]", RowBox[{"Entity", "[", RowBox[{"\<\"AdministrativeDivision\"\>", ",", "_"}], "]"}], ",", RowBox[{ RowBox[{"confirmed", "=", RowBox[{"covid19Data", "[", RowBox[{ RowBox[{"SelectFirst", "[", RowBox[{ RowBox[{"#AdministrativeDivision", "\[Equal]", "locale"}], "&"}], "]"}], ",", "\<\"ConfirmedCases\"\>"}], "]"}]}], ";", RowBox[{"recovered", "=", RowBox[{"covid19Data", "[", RowBox[{ RowBox[{"SelectFirst", "[", RowBox[{ RowBox[{"#AdministrativeDivision", "\[Equal]", "locale"}], "&"}], "]"}], ",", "\<\"RecoveredCases\"\>"}], "]"}]}], ";", RowBox[{"dead", "=", RowBox[{"covid19Data", "[", RowBox[{ RowBox[{"SelectFirst", "[", RowBox[{ RowBox[{"#AdministrativeDivision", "\[Equal]", "locale"}], "&"}], "]"}], ",", "\<\"Deaths\"\>"}], "]"}]}]}], ",", "\[IndentingNewLine]", RowBox[{"Entity", "[", RowBox[{"\<\"Country\"\>", ",", "_"}], "]"}], ",", RowBox[{ RowBox[{"confirmed", "=", RowBox[{"Plus", "@@", RowBox[{"Normal", "[", RowBox[{"covid19Data", "[", RowBox[{ RowBox[{"Select", "[", RowBox[{ RowBox[{"#Country", "\[Equal]", "locale"}], "&"}], "]"}], ",", "\<\"ConfirmedCases\"\>"}], "]"}], "]"}]}]}], ";", RowBox[{"recovered", "=", RowBox[{"Plus", "@@", RowBox[{"Normal", "[", RowBox[{"covid19Data", "[", RowBox[{ RowBox[{"Select", "[", RowBox[{ RowBox[{"#Country", "\[Equal]", "locale"}], "&"}], "]"}], ",", "\<\"RecoveredCases\"\>"}], "]"}], "]"}]}]}], ";", RowBox[{"dead", "=", RowBox[{"Plus", "@@", RowBox[{"Normal", "[", RowBox[{"covid19Data", "[", RowBox[{ RowBox[{"Select", "[", RowBox[{ RowBox[{"#Country", "\[Equal]", "locale"}], "&"}], "]"}], ",", "\<\"Deaths\"\>"}], "]"}], "]"}]}]}]}]}], "]"}], ";", RowBox[{"confirmed", "=", RowBox[{"If", "[", RowBox[{ RowBox[{"correctionQ", "&&", RowBox[{"MatchQ", "[", RowBox[{"locale", ",", RowBox[{ TemplateBox[{"\"Hubei, China\"", RowBox[{"Entity", "[", RowBox[{"\"AdministrativeDivision\"", ",", RowBox[{"{", RowBox[{"\"Hubei\"", ",", "\"China\""}], "}"}]}], "]"}], "\"Entity[\\\"AdministrativeDivision\\\", {\\\"Hubei\\\", \ \\\"China\\\"}]\"", "\"administrative division\""}, "Entity"], "|", TemplateBox[{"\"China\"", RowBox[{"Entity", "[", RowBox[{"\"Country\"", ",", "\"China\""}], "]"}], "\"Entity[\\\"Country\\\", \\\"China\\\"]\"", "\"country\""}, "Entity"]}]}], "]"}]}], ",", RowBox[{"TimeSeries", "[", RowBox[{"Apply", "[", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{"#1", ",", RowBox[{"If", "[", RowBox[{ RowBox[{"#1", "\[GreaterEqual]", RowBox[{"DateObject", "[", RowBox[{"\<\"13 Feb 2020\"\>", ",", "\<\"Instant\"\>"}], "]"}]}], ",", RowBox[{"#2", "-", "13332"}], ",", "#2"}], "]"}]}], "}"}], "&"}], ",", RowBox[{"Normal", "[", "confirmed", "]"}], ",", RowBox[{"{", "1", "}"}]}], "]"}], "]"}], ",", "confirmed"}], "]"}]}], ";", RowBox[{"confirmed", "=", RowBox[{"TimeSeriesWindow", "[", RowBox[{"confirmed", ",", "dateRange"}], "]"}]}], ";", RowBox[{"recovered", "=", RowBox[{"TimeSeriesWindow", "[", RowBox[{"recovered", ",", "dateRange"}], "]"}]}], ";", RowBox[{"dead", "=", RowBox[{"TimeSeriesWindow", "[", RowBox[{"dead", ",", "dateRange"}], "]"}]}], ";", RowBox[{"Map", "[", RowBox[{ RowBox[{ RowBox[{"{", RowBox[{ RowBox[{"QuantityMagnitude", "[", RowBox[{"DateDifference", "[", RowBox[{"date0", ",", RowBox[{"First", "[", "#1", "]"}], ",", "\<\"Day\"\>"}], "]"}], "]"}], ",", RowBox[{"Last", "[", "#1", "]"}]}], "}"}], "&"}], ",", RowBox[{"Normal", "/@", RowBox[{"{", RowBox[{ RowBox[{"confirmed", "-", RowBox[{"(", RowBox[{"recovered", "+", "dead"}], ")"}]}], ",", "recovered", ",", "dead"}], "}"}]}], ",", RowBox[{"{", "2", "}"}]}], "]"}]}]}], "]"}]}]} }, DefaultBaseStyle->"Column", GridBoxAlignment->{"Columns" -> {{Left}}}, GridBoxItemSize->{ "Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}]}, { TagBox[ TooltipBox[ StyleBox["\<\" Options\"\>", "InformationRowLabel", StripOnInput->False], "\"Options\"", TooltipStyle->"TextStyling"], Annotation[#, "Options", "Tooltip"]& ], RowBox[{"{", RowBox[{ RowBox[{"\<\"makeCorrectionForHubei\"\>", "\[Rule]", "False"}], ",", RowBox[{"\<\"dateRange\"\>", "\[Rule]", "All"}]}], "}"}]}, { TagBox[ TooltipBox[ StyleBox["\<\" Full Name\"\>", "InformationRowLabel", StripOnInput->False], "\"FullName\"", TooltipStyle->"TextStyling"], Annotation[#, "FullName", "Tooltip"]& ], "\<\"Global`fitDataWDR\"\>"} }, AutoDelete->False, GridBoxAlignment->{"Columns" -> {Right, Left}}, GridBoxDividers->None, GridBoxItemSize->{"Columns" -> {Automatic, Automatic}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "Rows" -> { Offset[0.2], { Offset[0.8]}, Offset[0.2]}}], "DialogStyle", StripOnInput->False], DynamicModuleValues:>{}]} }, DefaultBaseStyle->"Column", GridBoxAlignment->{"Columns" -> {{Left}}}, GridBoxDividers->{"Columns" -> {{False}}, "Rows" -> {{False}}}, GridBoxItemSize->{ "Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}, GridBoxSpacings->{"Columns" -> { Offset[0.27999999999999997`], { Offset[0.5599999999999999]}, Offset[0.27999999999999997`]}, "Rows" -> { Offset[0.2], { Offset[3.6]}, Offset[0.2]}}], FrameMargins->6], ""}, { ItemBox[ TagBox[ ButtonBox[ PaneSelectorBox[{False-> DynamicBox[FEPrivate`FrontEndResource[ "FEBitmaps", "UpPointerOpener"]], True-> DynamicBox[FEPrivate`FrontEndResource[ "FEBitmaps", "UpPointerOpenerHot"]]}, Dynamic[ System`InformationDump`mouseOver$$]], Alignment->Left, Appearance->{"Default" -> None}, ButtonFunction:>FEPrivate`Set[ System`InformationDump`open$$, False], Evaluator->Automatic, FrameMargins->{{9, 0}, {0, 0}}, ImageMargins->0, ImageSize->Full, Method->"Preemptive"], EventHandlerTag[{ "MouseEntered" :> FEPrivate`Set[System`InformationDump`mouseOver$$, True], "MouseExited" :> FEPrivate`Set[System`InformationDump`mouseOver$$, False], Method -> "Preemptive", PassEventsDown -> Automatic, PassEventsUp -> True}]], BaseStyle->"InformationTitleBackground", StripOnInput->False], "\[SpanFromLeft]"} }, AutoDelete->False, FrameStyle->Directive[ GrayLevel[0.8], Thickness[Tiny]], GridBoxAlignment->{"Columns" -> {Left, Right}, "Rows" -> {{Center}}}, GridBoxDividers->{ "Columns" -> {{None}}, "Rows" -> {False, {True}, False}}, GridBoxItemSize->{ "Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}], "Grid"], False-> TagBox[GridBox[{ { ItemBox[ PaneBox[ StyleBox["\<\" Symbol\"\>", "InformationTitleText", StripOnInput->False], FrameMargins->{{4, 0}, {-1, 1}}], BaseStyle->"InformationTitleBackground", StripOnInput->False], ItemBox["\<\"\"\>", BaseStyle->"InformationTitleBackground", StripOnInput->False]}, { ItemBox[ PaneBox[ StyleBox["\<\"fitDataWDR[locale, startDate] gives data for \ infected, recovered, and dead relative to the given date for the onset of \ infection for the given locale, either an administrative division or a \ country. For reference, cases were first reported on 31 Dec 2019.\"\>", "InformationUsageText", StripOnInput->False, LineSpacing->{1.5, 1.5, 3.}], FrameMargins->{{10, 10}, {8, 10}}], BaseStyle->"InformationUsageSubtitleBackground", StripOnInput->False], ItemBox["\<\"\"\>", BaseStyle->"InformationUsageSubtitleBackground", StripOnInput->False]}, { ItemBox[ TagBox[ ButtonBox[ PaneSelectorBox[{False-> DynamicBox[FEPrivate`FrontEndResource[ "FEBitmaps", "DownPointerOpener"], ImageSizeCache->{14., {4., 10.}}], True-> DynamicBox[FEPrivate`FrontEndResource[ "FEBitmaps", "DownPointerOpenerHot"], ImageSizeCache->{14., {4., 10.}}]}, Dynamic[ System`InformationDump`mouseOver$$]], Alignment->Left, Appearance->{"Default" -> None}, ButtonFunction:>FEPrivate`Set[ System`InformationDump`open$$, True], Evaluator->Automatic, FrameMargins->{{9, 0}, {0, 0}}, ImageMargins->0, ImageSize->Full, Method->"Preemptive"], EventHandlerTag[{ "MouseEntered" :> FEPrivate`Set[System`InformationDump`mouseOver$$, True], "MouseExited" :> FEPrivate`Set[System`InformationDump`mouseOver$$, False], Method -> "Preemptive", PassEventsDown -> Automatic, PassEventsUp -> True}]], BaseStyle->"InformationTitleBackground", StripOnInput->False], "\[SpanFromLeft]"} }, AutoDelete->False, FrameStyle->Directive[ GrayLevel[0.8], Thickness[Tiny]], GridBoxAlignment->{"Columns" -> {Left, Right}, "Rows" -> {{Center}}}, GridBoxDividers->{ "Columns" -> {{None}}, "Rows" -> {False, {True}, False}}, GridBoxItemSize->{ "Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}], "Grid"]}, Dynamic[System`InformationDump`open$$], BaselinePosition->Baseline, FrameMargins->0, ImageSize->Automatic], DynamicModuleValues:>{}], BaseStyle->"InformationGridFrame", StripOnInput->False], "InformationGridPlain", StripOnInput->False], InformationData[ Association[ "ObjectType" -> "Symbol", "Usage" -> "fitDataWDR[locale, startDate] gives data for infected, recovered, and \ dead relative to the given date for the onset of infection for the given \ locale, either an administrative division or a country. For reference, cases \ were first reported on 31 Dec 2019.", "Documentation" -> None, "OwnValues" -> None, "UpValues" -> None, "DownValues" -> Information`InformationValueForm[ DownValues, $CellContext`fitDataWDR, {$CellContext`fitDataWDR[ Pattern[$CellContext`locale, Alternatives[ Entity["AdministrativeDivision", Blank[]], Entity["Country", Blank[]]]], Pattern[$CellContext`date0, Blank[]], Pattern[$CellContext`opts, OptionsPattern[]]] :> Module[{$CellContext`covid19Data, $CellContext`confirmed, \ $CellContext`recovered, $CellContext`dead, $CellContext`correctionQ, \ $CellContext`dateRange}, $CellContext`covid19Data = ResourceData["Epidemic Data for Novel Coronavirus COVID-19"]; Switch[$CellContext`locale, Entity["AdministrativeDivision", Blank[]], If[ Not[ MemberQ[ $CellContext`covid19Data[ All, "AdministrativeDivision"], $CellContext`locale]], Message[ MessageName[$CellContext`fitDataWDR, "locnf"], $CellContext`locale]; Return[$Failed]], Entity["Country", Blank[]], If[ Not[ MemberQ[ $CellContext`covid19Data[All, "Country"], $CellContext`locale]], Message[ MessageName[$CellContext`fitDataWDR, "locnf"], $CellContext`locale]; Return[$Failed]]]; $CellContext`correctionQ = OptionValue["makeCorrectionForHubei"]; If[ MatchQ[$CellContext`correctionQ, Except[ Alternatives[True, False]]], Message[ MessageName[$CellContext`fitDataWDR, "opttf"], "makeCorrectionForHubei", $CellContext`correctionQ]; Return[$Failed]]; $CellContext`dateRange = OptionValue["dateRange"]; $CellContext`dateRange = Switch[$CellContext`dateRange, All, Map[ Part[$CellContext`covid19Data, 1, "ConfirmedCases"], { "FirstDate", "LastDate"}], { Blank[], Blank[]}, $CellContext`dateRange = Map[Quiet[ DateObject[#, "Instant"]]& , ReplaceRepeated[$CellContext`dateRange, {{All, Pattern[$CellContext`b, Blank[]]} :> { Part[$CellContext`covid19Data, 1, "ConfirmedCases"][ "FirstDate"], $CellContext`b}, { Pattern[$CellContext`a, Blank[]], All} :> {$CellContext`a, Part[$CellContext`covid19Data, 1, "ConfirmedCases"][ "LastDate"]}}]]; If[ MatchQ[$CellContext`dateRange, { DateObject[{ BlankSequence[]}, Blank[String], Blank[String], Blank[Real]], DateObject[{ BlankSequence[]}, Blank[String], Blank[String], Blank[Real]]}], $CellContext`dateRange, Message[ MessageName[$CellContext`fitDataWDR, "optvg"], "dateRange", OptionValue["dateRange"], "All or a list of two dates"]; Return[$Failed]], Blank[], Message[ MessageName[$CellContext`fitDataWDR, "optvg"], "dateRange", OptionValue["dateRange"], "All or a list of two dates"]; Return[$Failed]]; Switch[$CellContext`locale, Entity["AdministrativeDivision", Blank[]], $CellContext`confirmed = $CellContext`covid19Data[ SelectFirst[ Slot["AdministrativeDivision"] == $CellContext`locale& ], "ConfirmedCases"]; $CellContext`recovered = \ $CellContext`covid19Data[ SelectFirst[ Slot["AdministrativeDivision"] == $CellContext`locale& ], "RecoveredCases"]; $CellContext`dead = $CellContext`covid19Data[ SelectFirst[ Slot["AdministrativeDivision"] == $CellContext`locale& ], "Deaths"], Entity["Country", Blank[]], $CellContext`confirmed = Apply[Plus, Normal[ $CellContext`covid19Data[ Select[Slot["Country"] == $CellContext`locale& ], "ConfirmedCases"]]]; $CellContext`recovered = Apply[Plus, Normal[ $CellContext`covid19Data[ Select[Slot["Country"] == $CellContext`locale& ], "RecoveredCases"]]]; $CellContext`dead = Apply[Plus, Normal[ $CellContext`covid19Data[ Select[Slot["Country"] == $CellContext`locale& ], "Deaths"]]]]; $CellContext`confirmed = If[ And[$CellContext`correctionQ, MatchQ[$CellContext`locale, Alternatives[ Entity["AdministrativeDivision", {"Hubei", "China"}], Entity["Country", "China"]]]], TimeSeries[ Apply[{#, If[# >= DateObject["13 Feb 2020", "Instant"], #2 - 13332, #2]}& , Normal[$CellContext`confirmed], { 1}]], $CellContext`confirmed]; $CellContext`confirmed = TimeSeriesWindow[$CellContext`confirmed, $CellContext`dateRange]; \ $CellContext`recovered = TimeSeriesWindow[$CellContext`recovered, $CellContext`dateRange]; \ $CellContext`dead = TimeSeriesWindow[$CellContext`dead, $CellContext`dateRange]; Map[{ QuantityMagnitude[ DateDifference[$CellContext`date0, First[#], "Day"]], Last[#]}& , Map[ Normal, {$CellContext`confirmed - ($CellContext`recovered + \ $CellContext`dead), $CellContext`recovered, $CellContext`dead}], {2}]]}], "SubValues" -> None, "DefaultValues" -> None, "NValues" -> None, "FormatValues" -> None, "Options" -> {"makeCorrectionForHubei" -> False, "dateRange" -> All}, "Attributes" -> {}, "FullName" -> "Global`fitDataWDR"], False]]], "Output", CellChangeTimes->{3.792685710709119*^9, 3.7926863640763817`*^9, 3.793782039540737*^9, 3.794741364514184*^9, 3.7949176962577667`*^9, 3.7949178831804295`*^9, 3.7949182500726223`*^9, 3.794920899452104*^9, 3.794975126412793*^9, 3.794977649867279*^9, 3.7950125457946157`*^9, 3.795059714160144*^9, 3.795146764762809*^9, 3.795152034865063*^9, 3.795153629333542*^9, 3.795157198929838*^9, 3.795230686715813*^9, 3.7953154364470162`*^9}, CellLabel->"Out[54]=",ExpressionUUID->"93a6b267-34d5-46e4-98ca-e0f92b1a7a2c"] }, Open ]], Cell[CellGroupData[{ Cell[BoxData[ RowBox[{"ListLogPlot", "[", RowBox[{ RowBox[{"fitDataWDR", "[", RowBox[{ NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "Spain", Typeset`boxes$$ = TemplateBox[{"\"Spain\"", RowBox[{"Entity", "[", RowBox[{"\"Country\"", ",", "\"Spain\""}], "]"}], "\"Entity[\\\"Country\\\", \\\"Spain\\\"]\"", "\"country\""}, "Entity"], Typeset`allassumptions$$ = {}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1, 2}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 1.1092868`7.496588838612159, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{167., {10.5, 22.5}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True], ",", "\"\<1 March 2020\>\""}], "]"}], ",", RowBox[{"PlotLabel", "\[Rule]", "\"\\""}], ",", RowBox[{"FrameLabel", "\[Rule]", RowBox[{"{", RowBox[{"\"\