The "covid19.analytics" R package provides live data worldwide from the novel CoronaVirus, known as CoViD-19, as published by the John Hopkins University. This package aslo gives some primary analytical tools to look into the data.

https://www.rdocumentation.org/packages/covid19.analytics/versions/1.0

#######################
####Install Library####
#######################

library(covid19.analytics)

Obtaining Covid information

## Obtain all the records combined for "confirmed", "deaths" and "recovered" cases -- *aggregated* data##

ALLcases<- covid19.data()
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
## ================================================================================ 
## ================================================================================ 
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
View(ALLcases)
## obtain time series data for "confirmed" cases ##

confirmed_cases <- covid19.data(case="ts-confirmed")
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
## --------------------------------------------------------------------------------
View(confirmed_cases)
## Death Count / reads time series data for casualties ##

death_count <- covid19.data(case = "ts-deaths")
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
## --------------------------------------------------------------------------------
View(death_count)

Summary and graphical overview of the covid data for top 5 countries/regions.

## Overview of top 5 regions ##

report.summary(Nentries = 5,
               graphical.output = T)
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
## -------------------------------------------------------------------------------- 
## ################################################################################ 
##   ##### TS-CONFIRMED Cases  -- Data dated:  2020-11-10  ::  2020-11-12 01:00:35 
## ################################################################################ 
##   Number of Countries/Regions reported:  191 
##   Number of Cities/Provinces reported:  82 
##   Unique number of distinct geographical locations combined: 269 
## -------------------------------------------------------------------------------- 
##   Worldwide ts-confirmed  Totals: 51456775 
## -------------------------------------------------------------------------------- 
##   Country.Region Province.State   Totals GlobalPerc LastDayChange    t-2    t-3    t-7  t-14  t-30
## 1             US                10252129      19.92        136325 119944 109780 102946 78258 40562
## 2          India                 8636011      16.78         44281  38073  45903  50210 49881 55342
## 3         Brazil                 5699005      11.08         23973  10917  10554  23976 28629  8429
## 4         France                 1810653       3.52             0  19836 125414  40753 34848 42956
## 5         Russia                 1802762       3.50         20765  21577  20248  19483 15886 13406
## -------------------------------------------------------------------------------- 
##   Global Perc. Average:  0.37 (sd: 1.77) 
##   Global Perc. Average in top  5 :  10.96 (sd: 7.5) 
## -------------------------------------------------------------------------------- 
## ================================================================================

## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
## -------------------------------------------------------------------------------- 
## ################################################################################ 
##   ##### TS-DEATHS Cases  -- Data dated:  2020-11-10  ::  2020-11-12 01:00:36 
## ################################################################################ 
##   Number of Countries/Regions reported:  191 
##   Number of Cities/Provinces reported:  82 
##   Unique number of distinct geographical locations combined: 269 
## -------------------------------------------------------------------------------- 
##   Worldwide ts-deaths  Totals: 1272094 
## -------------------------------------------------------------------------------- 
##   Country.Region Province.State Totals Perc LastDayChange t-2 t-3  t-7 t-14 t-30
## 1             US                239671 2.34          1415 477 462 1104  996  323
## 2         Brazil                162802 2.86           174 231 128  610  510  201
## 3          India                127571 1.48           512 448 490  704  517  706
## 4         Mexico                 95842 9.79           815   0 219  635  495  164
## 5 United Kingdom                 49770 4.03           532 194 156  492  310   50
## -------------------------------------------------------------------------------- 
## -------------------------------------------------------------------------------- 
## ================================================================================

## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
## -------------------------------------------------------------------------------- 
## ################################################################################ 
##   ##### TS-RECOVERED Cases  -- Data dated:  2020-11-10  ::  2020-11-12 01:00:38 
## ################################################################################ 
##   Number of Countries/Regions reported:  191 
##   Number of Cities/Provinces reported:  68 
##   Unique number of distinct geographical locations combined: 256 
## -------------------------------------------------------------------------------- 
##   Worldwide ts-recovered  Totals: 33544236 
## -------------------------------------------------------------------------------- 
##   Country.Region Province.State  Totals LastDayChange   t-2   t-3   t-7  t-14  t-30
## 1          India                8013783         54377 42033 48405 55331 56480 77760
## 2         Brazil                5183970         20744 16054  8531 17465 33044     0
## 3             US                3961873         33028 47354 30026 38397 30474 31651
## 4         Russia                1341868         15300 10640 11321 15182 12067  3785
## 5      Argentina                1081897          8320 10666  9598  8369  9803 11202
## -------------------------------------------------------------------------------- 
## -------------------------------------------------------------------------------- 
## ================================================================================

## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
## ================================================================================ 
## ================================================================================ 
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
## ############################################################################################################################################ 
##   ##### AGGREGATED Data  -- ORDERED BY  CONFIRMED Cases  -- Data dated:  2020-09-16  ::  2020-11-12 01:00:38 
## ############################################################################################################################################ 
##   Number of Countries/Regions reported: 188 
##   Number of Cities/Provinces reported: 559 
##   Unique number of distinct geographical locations combined: 3939 
## -------------------------------------------------------------------------------------------------------------------------------------------- 
##                Location Confirmed Perc.Confirmed Deaths Perc.Deaths Recovered Perc.Recovered Active Perc.Active
## 1    Maharashtra, India   1097856           3.78  30409        2.77    775273          70.62 292174       26.61
## 2     Sao Paulo, Brazil    901271           3.11  32963        3.66    763246          84.69 105062       11.66
## 3          South Africa    651521           2.24  15641        2.40    583126          89.50  52754        8.10
## 4 Andhra Pradesh, India    583925           2.01   5041        0.86    486531          83.32  92353       15.82
## 5             Argentina    577338           1.99  11852        2.05    438883          76.02 126603       21.93
## ============================================================================================================================================
## ############################################################################################################################################ 
##   ##### AGGREGATED Data  -- ORDERED BY  DEATHS Cases  -- Data dated:  2020-09-16  ::  2020-11-12 01:00:38 
## ############################################################################################################################################ 
##   Number of Countries/Regions reported: 188 
##   Number of Cities/Provinces reported: 559 
##   Unique number of distinct geographical locations combined: 3939 
## -------------------------------------------------------------------------------------------------------------------------------------------- 
##                  Location Confirmed Perc.Confirmed Deaths Perc.Deaths Recovered Perc.Recovered Active Perc.Active
## 1 England, United Kingdom    323029           1.11  36996       11.45         0           0.00 286033       88.55
## 2       Sao Paulo, Brazil    901271           3.11  32963        3.66    763246          84.69 105062       11.66
## 3      Maharashtra, India   1097856           3.78  30409        2.77    775273          70.62 292174       26.61
## 4                    Iran    407353           1.40  23453        5.76    349984          85.92  33916        8.33
## 5  Rio de Janeiro, Brazil    244418           0.84  17180        7.03    220651          90.28   6587        2.69
## ============================================================================================================================================
## ############################################################################################################################################ 
##   ##### AGGREGATED Data  -- ORDERED BY  RECOVERED Cases  -- Data dated:  2020-09-16  ::  2020-11-12 01:00:38 
## ############################################################################################################################################ 
##   Number of Countries/Regions reported: 188 
##   Number of Cities/Provinces reported: 559 
##   Unique number of distinct geographical locations combined: 3939 
## -------------------------------------------------------------------------------------------------------------------------------------------- 
##                Location Confirmed Perc.Confirmed Deaths Perc.Deaths Recovered Perc.Recovered Active Perc.Active
## 1    Maharashtra, India   1097856           3.78  30409        2.77    775273          70.62 292174       26.61
## 2     Sao Paulo, Brazil    901271           3.11  32963        3.66    763246          84.69 105062       11.66
## 3          South Africa    651521           2.24  15641        2.40    583126          89.50  52754        8.10
## 4 Andhra Pradesh, India    583925           2.01   5041        0.86    486531          83.32  92353       15.82
## 5     Tamil Nadu, India    514208           1.77   8502        1.65    458900          89.24  46806        9.10
## ============================================================================================================================================
## ############################################################################################################################################ 
##   ##### AGGREGATED Data  -- ORDERED BY  ACTIVE Cases  -- Data dated:  2020-09-16  ::  2020-11-12 01:00:38 
## ############################################################################################################################################ 
##   Number of Countries/Regions reported: 188 
##   Number of Cities/Provinces reported: 559 
##   Unique number of distinct geographical locations combined: 3939 
## -------------------------------------------------------------------------------------------------------------------------------------------- 
##                      Location Confirmed Perc.Confirmed Deaths Perc.Deaths Recovered Perc.Recovered Active Perc.Active
## 1                  Lima, Peru    340912           1.17  13780        4.04         0           0.00 327132       95.96
## 2          Maharashtra, India   1097856           3.78  30409        2.77    775273          70.62 292174       26.61
## 3     England, United Kingdom    323029           1.11  36996       11.45         0           0.00 286033       88.55
## 4 Los Angeles, California, US    255049           0.88   6273        2.46         0           0.00 248776       97.54
## 5     Miami-Dade, Florida, US    164688           0.57   2923        1.77         0           0.00 161765       98.23
## ============================================================================================================================================

##       Confirmed  Deaths  Recovered   Active 
##   Totals 
##       29022050   900783  16849185    NA 
##   Average 
##       7367.87    228.68  4277.53 NA 
##   Standard Deviation 
##       39633.3    1364.62 31226.25    NA 
##   
## 
##  * Statistical estimators computed considering 3939 independent reported entries 
##  
## 
## ******************************************************************************** 
## ********************************  OVERALL SUMMARY******************************** 
## ******************************************************************************** 
##   ****  Time Series Worldwide TOTS **** 
##       ts-confirmed   ts-deaths   ts-recovered 
##       51456775   1272094 33544236 
##              2.47%       65.19% 
##   ****  Time Series Worldwide AVGS **** 
##       ts-confirmed   ts-deaths   ts-recovered 
##       191289.13  4728.97 131032.17 
##              2.47%       68.5% 
##   ****  Time Series Worldwide SDS **** 
##       ts-confirmed   ts-deaths   ts-recovered 
##       912555.23  21097.55    659067.35 
##              2.31%       72.22% 
##   
## 
##  * Statistical estimators computed considering 269/269/256 independent reported entries per case-type 
## ********************************************************************************

Plot total cases across the world

total_ts <- covid19.data(case = "ts-ALL")
## Data being read from JHU/CCSE repository
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## Reading data from https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv
## Data retrieved on 2020-11-12 01:00:40 || Range of dates on data: 2020-01-22--2020-11-10 | Nbr of records: 269
## --------------------------------------------------------------------------------
## Data being read from JHU/CCSE repository
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## Reading data from https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv
## Data retrieved on 2020-11-12 01:00:40 || Range of dates on data: 2020-01-22--2020-11-10 | Nbr of records: 269
## --------------------------------------------------------------------------------
## Data being read from JHU/CCSE repository
## ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## Reading data from https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv
## Data retrieved on 2020-11-12 01:00:40 || Range of dates on data: 2020-01-22--2020-11-10 | Nbr of records: 256
## --------------------------------------------------------------------------------
totals.plt(total_ts)
## Loading required package: plotly
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout

New Zealand

tots.per.location(confirmed_cases,geo.loc = "New Zealand" )
## [1] "NEWZEALAND"
## NEW ZEALAND  --  1988 
## ===============================   running models...=============================== 
##   Linear Regression (lm): 
## 
## Call:
## lm(formula = y.var ~ x.var)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -573.31 -247.96  -47.94  258.20  610.15 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 182.5474    39.0828   4.671 4.58e-06 ***
## x.var         7.1923     0.2297  31.316  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 334.2 on 292 degrees of freedom
## Multiple R-squared:  0.7706, Adjusted R-squared:  0.7698 
## F-statistic: 980.7 on 1 and 292 DF,  p-value: < 2.2e-16
## 
## -------------------------------------------------------------------------------- 
##   Linear Regression (lm): 
## 
## Call:
## lm(formula = y.var ~ x.var)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.3033 -1.4789  0.0082  1.5781  2.8202 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  2.41348    0.21110   11.43   <2e-16 ***
## x.var        0.02405    0.00124   19.39   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.805 on 292 degrees of freedom
## Multiple R-squared:  0.5628, Adjusted R-squared:  0.5613 
## F-statistic: 375.9 on 1 and 292 DF,  p-value: < 2.2e-16
## 
## -------------------------------------------------------------------------------- 
##   GLM using Family [1] "poisson" : 
## 
## Call:
## glm(formula = y.var ~ x.var, family = family)
## 
## Deviance Residuals: 
##     Min       1Q   Median       3Q      Max  
## -34.104  -11.927    0.704   11.714   21.539  
## 
## Coefficients:
##              Estimate Std. Error z value Pr(>|z|)    
## (Intercept) 6.098e+00  4.309e-03  1415.0   <2e-16 ***
## x.var       6.086e-03  2.104e-05   289.3   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for poisson family taken to be 1)
## 
##     Null deviance: 186762  on 293  degrees of freedom
## Residual deviance:  96424  on 292  degrees of freedom
## AIC: 98648
## 
## Number of Fisher Scoring iterations: 5
## 
## --------------------------------------------------------------------------------

Calculation and visualizations of changes and growth rates in New Zealand

growth.rate(confirmed_cases, geo.loc = "New Zealand")
## [1] "NEWZEALAND"
## Processing...  NEW ZEALAND
## Loading required package: pheatmap
## Loading required package: gplots
## 
## Attaching package: 'gplots'
## The following object is masked from 'package:stats':
## 
##     lowess

## $Changes
##       geo.loc 2020-01-23 2020-01-24 2020-01-25 2020-01-26 2020-01-27 2020-01-28
## 1 NEW ZEALAND          0          0          0          0          0          0
##   2020-01-29 2020-01-30 2020-01-31 2020-02-01 2020-02-02 2020-02-03 2020-02-04
## 1          0          0          0          0          0          0          0
##   2020-02-05 2020-02-06 2020-02-07 2020-02-08 2020-02-09 2020-02-10 2020-02-11
## 1          0          0          0          0          0          0          0
##   2020-02-12 2020-02-13 2020-02-14 2020-02-15 2020-02-16 2020-02-17 2020-02-18
## 1          0          0          0          0          0          0          0
##   2020-02-19 2020-02-20 2020-02-21 2020-02-22 2020-02-23 2020-02-24 2020-02-25
## 1          0          0          0          0          0          0          0
##   2020-02-26 2020-02-27 2020-02-28 2020-02-29 2020-03-01 2020-03-02 2020-03-03
## 1          0          0          1          0          0          0          0
##   2020-03-04 2020-03-05 2020-03-06 2020-03-07 2020-03-08 2020-03-09 2020-03-10
## 1          2          0          1          1          0          0          0
##   2020-03-11 2020-03-12 2020-03-13 2020-03-14 2020-03-15 2020-03-16 2020-03-17
## 1          0          0          0          1          2          0          4
##   2020-03-18 2020-03-19 2020-03-20 2020-03-21 2020-03-22 2020-03-23 2020-03-24
## 1          8          8         11         13         50          0         53
##   2020-03-25 2020-03-26 2020-03-27 2020-03-28 2020-03-29 2020-03-30 2020-03-31
## 1         50         78         85         83         63         75         58
##   2020-04-01 2020-04-02 2020-04-03 2020-04-04 2020-04-05 2020-04-06 2020-04-07
## 1         61         89         71         82         89         67         54
##   2020-04-08 2020-04-09 2020-04-10 2020-04-11 2020-04-12 2020-04-13 2020-04-14
## 1         50         29         44         29         18         19         17
##   2020-04-15 2020-04-16 2020-04-17 2020-04-18 2020-04-19 2020-04-20 2020-04-21
## 1         20         15          8         13          9          9          5
##   2020-04-22 2020-04-23 2020-04-24 2020-04-25 2020-04-26 2020-04-27 2020-04-28
## 1          6          5          5          9         -1          3          2
##   2020-04-29 2020-04-30 2020-05-01 2020-05-02 2020-05-03 2020-05-04 2020-05-05
## 1          2          3          6          2          0         -1          2
##   2020-05-06 2020-05-07 2020-05-08 2020-05-09 2020-05-10 2020-05-11 2020-05-12
## 1          1          1          2          2          3          0          0
##   2020-05-13 2020-05-14 2020-05-15 2020-05-16 2020-05-17 2020-05-18 2020-05-19
## 1          0          1          0          1          0          0          4
##   2020-05-20 2020-05-21 2020-05-22 2020-05-23 2020-05-24 2020-05-25 2020-05-26
## 1          0          1          0          0          0          0          0
##   2020-05-27 2020-05-28 2020-05-29 2020-05-30 2020-05-31 2020-06-01 2020-06-02
## 1          0          0          0          0          0          0          0
##   2020-06-03 2020-06-04 2020-06-05 2020-06-06 2020-06-07 2020-06-08 2020-06-09
## 1          0          0          0          0          0          0          0
##   2020-06-10 2020-06-11 2020-06-12 2020-06-13 2020-06-14 2020-06-15 2020-06-16
## 1          0          0          0          0          0          2          0
##   2020-06-17 2020-06-18 2020-06-19 2020-06-20 2020-06-21 2020-06-22 2020-06-23
## 1          1          0          2          2          2          2          1
##   2020-06-24 2020-06-25 2020-06-26 2020-06-27 2020-06-28 2020-06-29 2020-06-30
## 1          3          1          2          4          2          0          0
##   2020-07-01 2020-07-02 2020-07-03 2020-07-04 2020-07-05 2020-07-06 2020-07-07
## 1          2          0          0          3          1          2          1
##   2020-07-08 2020-07-09 2020-07-10 2020-07-11 2020-07-12 2020-07-13 2020-07-14
## 1          3          2          1          1          0          1          2
##   2020-07-15 2020-07-16 2020-07-17 2020-07-18 2020-07-19 2020-07-20 2020-07-21
## 1          1          1          1          3          1          1          0
##   2020-07-22 2020-07-23 2020-07-24 2020-07-25 2020-07-26 2020-07-27 2020-07-28
## 1          0          1          0          0          0          1          2
##   2020-07-29 2020-07-30 2020-07-31 2020-08-01 2020-08-02 2020-08-03 2020-08-04
## 1          1          0          2          3          2          0          2
##   2020-08-05 2020-08-06 2020-08-07 2020-08-08 2020-08-09 2020-08-10 2020-08-11
## 1          0          0          0          0          0          1          0
##   2020-08-12 2020-08-13 2020-08-14 2020-08-15 2020-08-16 2020-08-17 2020-08-18
## 1         19         13          7         13          9         12          6
##   2020-08-19 2020-08-20 2020-08-21 2020-08-22 2020-08-23 2020-08-24 2020-08-25
## 1          5         11          6          3          9          7          5
##   2020-08-26 2020-08-27 2020-08-28 2020-08-29 2020-08-30 2020-08-31 2020-09-01
## 1          7         12         13          2          9         14          5
##   2020-09-02 2020-09-03 2020-09-04 2020-09-05 2020-09-06 2020-09-07 2020-09-08
## 1          2          5          3          5          4          6          6
##   2020-09-09 2020-09-10 2020-09-11 2020-09-12 2020-09-13 2020-09-14 2020-09-15
## 1          4          1          2          2          1          3          1
##   2020-09-16 2020-09-17 2020-09-18 2020-09-19 2020-09-20 2020-09-21 2020-09-22
## 1          7          0          2          4          0          0          9
##   2020-09-23 2020-09-24 2020-09-25 2020-09-26 2020-09-27 2020-09-28 2020-09-29
## 1          3          2          2          2          0          2          1
##   2020-09-30 2020-10-01 2020-10-02 2020-10-03 2020-10-04 2020-10-05 2020-10-06
## 1         12          0          1          5          1          3          3
##   2020-10-07 2020-10-08 2020-10-09 2020-10-10 2020-10-11 2020-10-12 2020-10-13
## 1          3          2          4          1          0          1          2
##   2020-10-14 2020-10-15 2020-10-16 2020-10-17 2020-10-18 2020-10-19 2020-10-20
## 1          2          4          3          3          0          1         25
##   2020-10-21 2020-10-22 2020-10-23 2020-10-24 2020-10-25 2020-10-26 2020-10-27
## 1          2          9         11          1          5          1          2
##   2020-10-28 2020-10-29 2020-10-30 2020-10-31 2020-11-01 2020-11-02 2020-11-03
## 1          6          1          7          2          4          5          3
##   2020-11-04 2020-11-05 2020-11-06 2020-11-07 2020-11-08 2020-11-09 2020-11-10
## 1          2          1          2          6          4          1          1
## 
## $Growth.Rate
##       geo.loc 2020-01-24 2020-01-25 2020-01-26 2020-01-27 2020-01-28 2020-01-29
## 1 NEW ZEALAND        NaN        NaN        NaN        NaN        NaN        NaN
##   2020-01-30 2020-01-31 2020-02-01 2020-02-02 2020-02-03 2020-02-04 2020-02-05
## 1        NaN        NaN        NaN        NaN        NaN        NaN        NaN
##   2020-02-06 2020-02-07 2020-02-08 2020-02-09 2020-02-10 2020-02-11 2020-02-12
## 1        NaN        NaN        NaN        NaN        NaN        NaN        NaN
##   2020-02-13 2020-02-14 2020-02-15 2020-02-16 2020-02-17 2020-02-18 2020-02-19
## 1        NaN        NaN        NaN        NaN        NaN        NaN        NaN
##   2020-02-20 2020-02-21 2020-02-22 2020-02-23 2020-02-24 2020-02-25 2020-02-26
## 1        NaN        NaN        NaN        NaN        NaN        NaN        NaN
##   2020-02-27 2020-02-28 2020-02-29 2020-03-01 2020-03-02 2020-03-03 2020-03-04
## 1        NaN         NA          0        NaN        NaN        NaN         NA
##   2020-03-05 2020-03-06 2020-03-07 2020-03-08 2020-03-09 2020-03-10 2020-03-11
## 1          0         NA          1          0        NaN        NaN        NaN
##   2020-03-12 2020-03-13 2020-03-14 2020-03-15 2020-03-16 2020-03-17 2020-03-18
## 1        NaN        NaN         NA          2          0         NA          2
##   2020-03-19 2020-03-20 2020-03-21 2020-03-22 2020-03-23 2020-03-24 2020-03-25
## 1          1      1.375   1.181818   3.846154          0         NA  0.9433962
##   2020-03-26 2020-03-27 2020-03-28 2020-03-29 2020-03-30 2020-03-31 2020-04-01
## 1       1.56   1.089744  0.9764706  0.7590361   1.190476  0.7733333   1.051724
##   2020-04-02 2020-04-03 2020-04-04 2020-04-05 2020-04-06 2020-04-07 2020-04-08
## 1   1.459016  0.7977528    1.15493   1.085366   0.752809  0.8059701  0.9259259
##   2020-04-09 2020-04-10 2020-04-11 2020-04-12 2020-04-13 2020-04-14 2020-04-15
## 1       0.58   1.517241  0.6590909  0.6206897   1.055556  0.8947368   1.176471
##   2020-04-16 2020-04-17 2020-04-18 2020-04-19 2020-04-20 2020-04-21 2020-04-22
## 1       0.75  0.5333333      1.625  0.6923077          1  0.5555556        1.2
##   2020-04-23 2020-04-24 2020-04-25 2020-04-26 2020-04-27 2020-04-28 2020-04-29
## 1  0.8333333          1        1.8 -0.1111111         -3  0.6666667          1
##   2020-04-30 2020-05-01 2020-05-02 2020-05-03 2020-05-04 2020-05-05 2020-05-06
## 1        1.5          2  0.3333333          0       -Inf         -2        0.5
##   2020-05-07 2020-05-08 2020-05-09 2020-05-10 2020-05-11 2020-05-12 2020-05-13
## 1          1          2          1        1.5          0        NaN        NaN
##   2020-05-14 2020-05-15 2020-05-16 2020-05-17 2020-05-18 2020-05-19 2020-05-20
## 1         NA          0         NA          0        NaN         NA          0
##   2020-05-21 2020-05-22 2020-05-23 2020-05-24 2020-05-25 2020-05-26 2020-05-27
## 1         NA          0        NaN        NaN        NaN        NaN        NaN
##   2020-05-28 2020-05-29 2020-05-30 2020-05-31 2020-06-01 2020-06-02 2020-06-03
## 1        NaN        NaN        NaN        NaN        NaN        NaN        NaN
##   2020-06-04 2020-06-05 2020-06-06 2020-06-07 2020-06-08 2020-06-09 2020-06-10
## 1        NaN        NaN        NaN        NaN        NaN        NaN        NaN
##   2020-06-11 2020-06-12 2020-06-13 2020-06-14 2020-06-15 2020-06-16 2020-06-17
## 1        NaN        NaN        NaN        NaN         NA          0         NA
##   2020-06-18 2020-06-19 2020-06-20 2020-06-21 2020-06-22 2020-06-23 2020-06-24
## 1          0         NA          1          1          1        0.5          3
##   2020-06-25 2020-06-26 2020-06-27 2020-06-28 2020-06-29 2020-06-30 2020-07-01
## 1  0.3333333          2          2        0.5          0        NaN         NA
##   2020-07-02 2020-07-03 2020-07-04 2020-07-05 2020-07-06 2020-07-07 2020-07-08
## 1          0        NaN         NA  0.3333333          2        0.5          3
##   2020-07-09 2020-07-10 2020-07-11 2020-07-12 2020-07-13 2020-07-14 2020-07-15
## 1  0.6666667        0.5          1          0         NA          2        0.5
##   2020-07-16 2020-07-17 2020-07-18 2020-07-19 2020-07-20 2020-07-21 2020-07-22
## 1          1          1          3  0.3333333          1          0        NaN
##   2020-07-23 2020-07-24 2020-07-25 2020-07-26 2020-07-27 2020-07-28 2020-07-29
## 1         NA          0        NaN        NaN         NA          2        0.5
##   2020-07-30 2020-07-31 2020-08-01 2020-08-02 2020-08-03 2020-08-04 2020-08-05
## 1          0         NA        1.5  0.6666667          0         NA          0
##   2020-08-06 2020-08-07 2020-08-08 2020-08-09 2020-08-10 2020-08-11 2020-08-12
## 1        NaN        NaN        NaN        NaN         NA          0         NA
##   2020-08-13 2020-08-14 2020-08-15 2020-08-16 2020-08-17 2020-08-18 2020-08-19
## 1  0.6842105  0.5384615   1.857143  0.6923077   1.333333        0.5  0.8333333
##   2020-08-20 2020-08-21 2020-08-22 2020-08-23 2020-08-24 2020-08-25 2020-08-26
## 1        2.2  0.5454545        0.5          3  0.7777778  0.7142857        1.4
##   2020-08-27 2020-08-28 2020-08-29 2020-08-30 2020-08-31 2020-09-01 2020-09-02
## 1   1.714286   1.083333  0.1538462        4.5   1.555556  0.3571429        0.4
##   2020-09-03 2020-09-04 2020-09-05 2020-09-06 2020-09-07 2020-09-08 2020-09-09
## 1        2.5        0.6   1.666667        0.8        1.5          1  0.6666667
##   2020-09-10 2020-09-11 2020-09-12 2020-09-13 2020-09-14 2020-09-15 2020-09-16
## 1       0.25          2          1        0.5          3  0.3333333          7
##   2020-09-17 2020-09-18 2020-09-19 2020-09-20 2020-09-21 2020-09-22 2020-09-23
## 1          0         NA          2          0        NaN         NA  0.3333333
##   2020-09-24 2020-09-25 2020-09-26 2020-09-27 2020-09-28 2020-09-29 2020-09-30
## 1  0.6666667          1          1          0         NA        0.5         12
##   2020-10-01 2020-10-02 2020-10-03 2020-10-04 2020-10-05 2020-10-06 2020-10-07
## 1          0         NA          5        0.2          3          1          1
##   2020-10-08 2020-10-09 2020-10-10 2020-10-11 2020-10-12 2020-10-13 2020-10-14
## 1  0.6666667          2       0.25          0         NA          2          1
##   2020-10-15 2020-10-16 2020-10-17 2020-10-18 2020-10-19 2020-10-20 2020-10-21
## 1          2       0.75          1          0         NA         25       0.08
##   2020-10-22 2020-10-23 2020-10-24 2020-10-25 2020-10-26 2020-10-27 2020-10-28
## 1        4.5   1.222222 0.09090909          5        0.2          2          3
##   2020-10-29 2020-10-30 2020-10-31 2020-11-01 2020-11-02 2020-11-03 2020-11-04
## 1  0.1666667          7  0.2857143          2       1.25        0.6  0.6666667
##   2020-11-05 2020-11-06 2020-11-07 2020-11-08 2020-11-09 2020-11-10 NA
## 1        0.5          2          3  0.6666667       0.25          1 NA

Simulating the Virus spread in NZ on the basis of time series data for confirmed cases

generate.SIR.model(confirmed_cases,'New Zealand', tot.population=5084300)
## ################################################################################ 
## ################################################################################ 
## [1] "NEWZEALAND"
## Processing...  NEW ZEALAND 
##   [1]    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
##  [16]    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
##  [31]    0    0    0    0    0    0    0    1    1    1    1    1    3    3    4
##  [46]    5    5    5    5    5    5    5    6    8    8   12   20   28   39   52
##  [61]  102  102  155  205  283  368  451  514  589  647  708  797  868  950 1039
##  [76] 1106 1160 1210 1239 1283 1312 1330 1349 1366 1386 1401 1409 1422 1431 1440
##  [91] 1445 1451 1456 1461 1470 1469 1472 1474 1476 1479 1485 1487 1487 1486 1488
## [106] 1489 1490 1492 1494 1497 1497 1497 1497 1498 1498 1499 1499 1499 1503 1503
## [121] 1504 1504 1504 1504 1504 1504 1504 1504 1504 1504 1504 1504 1504 1504 1504
## [136] 1504 1504 1504 1504 1504 1504 1504 1504 1504 1504 1506 1506 1507 1507 1509
## [151] 1511 1513 1515 1516 1519 1520 1522 1526 1528 1528 1528 1530 1530 1530 1533
## [166] 1534 1536 1537 1540 1542 1543 1544 1544 1545 1547 1548 1549 1550 1553 1554
## [181] 1555 1555 1555 1556 1556 1556 1556 1557 1559 1560 1560 1562 1565 1567 1567
## [196] 1569 1569 1569 1569 1569 1569 1570 1570 1589 1602 1609 1622 1631 1643 1649
## [211] 1654 1665 1671 1674 1683 1690 1695 1702 1714 1727 1729 1738 1752 1757 1759
## [226] 1764 1767 1772 1776 1782 1788 1792 1793 1795 1797 1798 1801 1802 1809 1809
## [241] 1811 1815 1815 1815 1824 1827 1829 1831 1833 1833 1835 1836 1848 1848 1849
## [256] 1854 1855 1858 1861 1864 1866 1870 1871 1871 1872 1874 1876 1880 1883 1886
## [271] 1886 1887 1912 1914 1923 1934 1935 1940 1941 1943 1949 1950 1957 1959 1963
## [286] 1968 1971 1973 1974 1976 1982 1986 1987 1988
## [1] 58
##  [1]   28   39   52  102  102  155  205  283  368  451  514  589  647  708  797
## [16]  868  950 1039 1106 1160 1210 1239 1283 1312 1330 1349
## ------------------------  Parameters used to create model ------------------------ 
##      Region: NEW ZEALAND 
##      Time interval to consider: t0=58 - t1= ; tfinal=90 
##          t0: 2020-03-20 -- t1:  
##      Number of days considered for initial guess: 26 
##      Fatality rate: 0.02 
##      Population of the region: 5084300 
## -------------------------------------------------------------------------------- 
## [1] "CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH"
##      beta     gamma 
## 0.5849109 0.4150902 
##   R0 = 1.40911755495443 
##   Max nbr of infected: 238455.14  ( 4.69 %) 
##   Max nbr of casualties, assuming  2% fatality rate: 4769.1 
##   Max reached at day : 63 ==>  2020-05-22 
## ================================================================================

## $Infected
##  [1]   28   39   52  102  102  155  205  283  368  451  514  589  647  708  797
## [16]  868  950 1039 1106 1160 1210 1239 1283 1312 1330 1349
## 
## $model
##    time       S            I            R
## 1     1 5084272     28.00000 0.000000e+00
## 2     2 5084254     33.18245 1.266769e+01
## 3     3 5084233     39.32401 2.768000e+01
## 4     4 5084208     46.60216 4.547083e+01
## 5     5 5084178     55.22718 6.655438e+01
## 6     6 5084143     65.44827 9.153999e+01
## 7     7 5084101     77.56068 1.211497e+02
## 8     8 5084052     91.91420 1.562392e+02
## 9     9 5083993    108.92335 1.978222e+02
## 10   10 5083924    129.07918 2.471002e+02
## 11   11 5083842    152.96343 3.054966e+02
## 12   12 5083744    181.26524 3.746981e+02
## 13   13 5083628    214.80093 4.567030e+02
## 14   14 5083492    254.53734 5.538788e+02
## 15   15 5083329    301.61947 6.690304e+02
## 16   16 5083137    357.40319 8.054803e+02
## 17   17 5082909    423.49374 9.671643e+02
## 18   18 5082639    501.79135 1.158744e+03
## 19   19 5082320    594.54489 1.385740e+03
## 20   20 5081941    704.41520 1.654690e+03
## 21   21 5081492    834.54962 1.973333e+03
## 22   22 5080960    988.66959 2.350832e+03
## 23   23 5080331   1171.17352 2.798031e+03
## 24   24 5079585   1387.25734 3.327760e+03
## 25   25 5078702   1643.05544 3.955195e+03
## 26   26 5077656   1945.80505 4.698283e+03
## 27   27 5076418   2304.03733 5.578234e+03
## 28   28 5074952   2727.79864 6.620109e+03
## 29   29 5073218   3228.90560 7.853492e+03
## 30   30 5071165   3821.23733 9.313294e+03
## 31   31 5068738   4521.06794 1.104067e+04
## 32   32 5065868   5347.44137 1.308409e+04
## 33   33 5062477   6322.58922 1.550058e+04
## 34   34 5058470   7472.38957 1.835713e+04
## 35   35 5053741   8826.86112 2.173231e+04
## 36   36 5048161  10420.68118 2.571811e+04
## 37   37 5041584  12293.70809 3.042196e+04
## 38   38 5033840  14491.47762 3.596901e+04
## 39   39 5024730  17065.62795 4.250455e+04
## 40   40 5014029  20074.18824 5.019664e+04
## 41   41 5001480  23581.64156 5.923875e+04
## 42   42 4986789  27658.64305 6.985243e+04
## 43   43 4969629  32381.24039 8.228972e+04
## 44   44 4949636  37829.40831 9.683508e+04
## 45   45 4926409  44084.67641 1.138066e+05
## 46   46 4899517  51226.60987 1.335560e+05
## 47   47 4868505  59327.90717 1.564667e+05
## 48   48 4832902  68447.92689 1.829499e+05
## 49   49 4792238  78624.56806 2.134372e+05
## 50   50 4746066  89864.62683 2.483698e+05
## 51   51 4693983 102133.05170 2.881836e+05
## 52   52 4635669 115341.91648 3.332891e+05
## 53   53 4570912 129340.38728 3.840478e+05
## 54   54 4499649 143907.39702 4.407440e+05
## 55   55 4421996 158749.02544 5.035552e+05
## 56   56 4338275 173502.53719 5.725224e+05
## 57   57 4249028 187748.68174 6.475236e+05
## 58   58 4155013 201032.48869 7.282546e+05
## 59   59 4057189 212891.78087 8.142196e+05
## 60   60 3956674 222890.66554 9.047354e+05
## 61   61 3854697 230654.07945 9.989493e+05
## 62   62 3752531 235898.60348 1.095871e+06
## 63   63 3651430 238455.13551 1.194415e+06
## 64   64 3552567 238280.24139 1.293453e+06
## 65   65 3456982 235454.95865 1.391864e+06
## 66   66 3365545 230171.94447 1.488583e+06
## 67   67 3278940 222713.62716 1.582647e+06
## 68   68 3197653 213425.05118 1.673222e+06
## 69   69 3121988 202685.29171 1.759627e+06
## 70   70 3052079 190880.78385 1.841340e+06
## 71   71 2987920 178382.93868 1.917997e+06
## 72   72 2929387 165531.31163 1.989381e+06
## 73   73 2876267 152622.59226 2.055410e+06
## 74   74 2828283 139904.94114 2.116112e+06
## 75   75 2785113 127576.75113 2.171610e+06
## 76   76 2746412 115788.72672 2.222099e+06
## 77   77 2711826 104648.18920 2.267826e+06
## 78   78 2681000  94224.65289 2.309075e+06
## 79   79 2653590  84555.91293 2.346154e+06
## 80   80 2629268  75654.09072 2.379378e+06
## 81   81 2607723  67511.27043 2.409065e+06
## 82   82 2588669  60104.51378 2.435526e+06
## 83   83 2571840  53400.15697 2.459060e+06
## 84   84 2556993  47357.37609 2.479950e+06
## 85   85 2543908  41931.06000 2.498461e+06
## 86   86 2532387  37074.06044 2.514839e+06
## 87   87 2522250  32738.90297 2.529311e+06
## 88   88 2513337  28879.04531 2.542084e+06
## 89   89 2505505  25449.76565 2.553345e+06
## 90   90 2498626  22408.75544 2.563265e+06
## 
## $params
## $params$beta
##      beta 
## 0.5849109 
## 
## $params$gamma
##     gamma 
## 0.4150902 
## 
## $params$R0
##       R0 
## 1.409118