[R] How to use R0 package?

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Fri May 22 12:16:35 CEST 2020


Hello,
I am trying ot get the R0 from the incidence data from China for the
COVID-19. I set the following:
```
library("R0")
x1 <- c(259,   457,   688,   769,  1771,  1459,  1737,  1981,  2099,  2589,
 2825,  3235,  3884,  3694,  3143,
        3385,  2652,  2973,  2467,  2015, 14108,  5090,  2641,  2008,
 2048,  1888,  1749,   391,   889,  823,
        648,   214,   508,   406,   433,   327,   427,   573,   202,   125,
  119,   139,   143,    99,    44,
        40,    19,    24,    15,     8,    11,    20,     0,    16,    13,
   13,    34,    39,    46,    39,
        78,    47,    67,    55,    54,    45,     0,    79,    36,    35,
   31,    19,    30,    39,    32,
        0,    63,    42,    46,    99,   108,    89,    46,    46,    26,
325,    27,    16,    12,    11,
        30,    10,     6,    12,    11,     3,     6,    22,     4,    12,
    1,     3,     3,     1,     2,
        2,     1,     1,    14,    17,     1,     7,     3,     4,     8,
  6,     7)
d1 = c("2020-01-23", "2020-01-24", "2020-01-25", "2020-01-26",
"2020-01-27", "2020-01-28", "2020-01-29",
       "2020-01-30", "2020-01-31", "2020-02-01", "2020-02-02",
"2020-02-03", "2020-02-04", "2020-02-05",
       "2020-02-06", "2020-02-07", "2020-02-08", "2020-02-09",
"2020-02-10", "2020-02-11", "2020-02-12",
       "2020-02-13", "2020-02-14", "2020-02-15", "2020-02-16",
"2020-02-17", "2020-02-18", "2020-02-19",
       "2020-02-20", "2020-02-21", "2020-02-22", "2020-02-23",
"2020-02-24", "2020-02-25", "2020-02-26",
       "2020-02-27", "2020-02-28", "2020-02-29", "2020-03-01",
"2020-03-02", "2020-03-03", "2020-03-04",
       "2020-03-05", "2020-03-06", "2020-03-07", "2020-03-08",
"2020-03-09", "2020-03-10", "2020-03-11",
       "2020-03-12", "2020-03-13", "2020-03-14", "2020-03-15",
"2020-03-16", "2020-03-17", "2020-03-18",
       "2020-03-19", "2020-03-20", "2020-03-21", "2020-03-22",
"2020-03-23", "2020-03-24", "2020-03-25",
       "2020-03-26", "2020-03-27", "2020-03-28", "2020-03-29",
"2020-03-30", "2020-03-31", "2020-04-01",
       "2020-04-02", "2020-04-03", "2020-04-04", "2020-04-05",
"2020-04-06", "2020-04-07", "2020-04-08",
       "2020-04-09", "2020-04-10", "2020-04-11", "2020-04-12",
"2020-04-13", "2020-04-14", "2020-04-15",
       "2020-04-16", "2020-04-17", "2020-04-18", "2020-04-19",
"2020-04-20", "2020-04-21", "2020-04-22",
       "2020-04-23", "2020-04-24", "2020-04-25", "2020-04-26", "2020-04-27"
,"2020-04-28", "2020-04-29",
       "2020-04-30", "2020-05-01", "2020-05-02", "2020-05-03",
"2020-05-04", "2020-05-05", "2020-05-06",
       "2020-05-07", "2020-05-08", "2020-05-09", "2020-05-10",
"2020-05-11", "2020-05-12", "2020-05-13",
       "2020-05-14", "2020-05-15", "2020-05-16", "2020-05-17", "2020-05-18")
names(x1) <- d1
pop = 1438443864
Ts_mean = 5.16
Ts_sd   = 1.49
N=10000
TODAY = Sys.Date()
mGT = generation.time("gamma", c(Ts_mean, Ts_sd))
R0 = estimate.R(x1, t=d1, GT=mGT, begin=as.Date(d1[1]), end=TODAY,
                methods="EG",pop.size=pop, nsim=N)
```
but when I run I get:
```
Error in if (end.nb <= begin.nb) stop("'begin' and 'end' are not
consistent.") :
  argument is of length zero
> as.Date(d1[1])
[1] "2020-01-23"
> TODAY
[1] "2020-05-22"
> str(TODAY)
 Date[1:1], format: "2020-05-22"
> str(as.Date(d1[1]))
 Date[1:1], format: "2020-01-23"
```
Since I provided both start and end in the same format, I don't understand
the error.
Any tips?
Thank you
-- 
Best regards,
Luigi

	[[alternative HTML version deleted]]



More information about the R-help mailing list