[R] How to use pakcage R0

Luigi Marongiu m@rong|u@|u|g| @end|ng |rom gm@||@com
Tue May 5 13:07:10 CEST 2020


Dear all,
I have been trying to use the package R0
https://www.rdocumentation.org/packages/R0/versions/1.2-6/topics/estimate.R but
the manual is not so rich of words.
The example given is based on the named vector Germany.1918
```
> library("R0")
> data(Germany.1918)
> Germany.1918
1918-09-29 1918-09-30 1918-10-01 1918-10-02 1918-10-03 1918-10-04
1918-10-05
        10          4          4         19          6         13
28
1918-10-06 1918-10-07 1918-10-08 1918-10-09 1918-10-10 1918-10-11
1918-10-12
        23         35         27         42         51         43
78
1918-10-13 1918-10-14 1918-10-15 1918-10-16 1918-10-17 1918-10-18
1918-10-19
        86         80        109        126        126        159
 190
[...]
```

Then it creates a gamma function and applied the estimate.R function:
```
mGT<-generation.time("gamma", c(3, 1.5))
estR0<-estimate.R(Germany.1918, mGT, begin=1, end=27, methods=c("EG", "ML",
"TD", "AR", "SB"),
                  pop.size=100000, nsim=100)
```

I tried with a similar approach for the current epidemics in China:
```
> china_vect
23/01/20 24/01/20 25/01/20 26/01/20 27/01/20 28/01/20 29/01/20 30/01/20
31/01/20
     259      457      688      769     1771     1459     1737     1981
2099
> mGT = generation.time("gamma", c(3, 1.5))   # create distribution
> estR0 = estimate.R(china_vect, mGT, begin=1, end=length(china_vect),
                  methods="EG",
                  pop.size=pop_ch, nsim=100)
Error in integrity.checks(epid, t, GT, begin, end, date.first.obs,
time.step,  :
  If both 'begin'= 1  and 'end'= 103  are provided, they must be of the
same class (dates, character strings or integers).
```
So I gave the value 103 directly (why it did not accept length, is the
first question?) and it worked:
> estR0 = estimate.R(china_vect, mGT, begin=1, end=103,
+                   methods="EG",
+                   pop.size=pop_ch, nsim=100)
Waiting for profiling to be done...
> estR0
Reproduction number estimate using  Exponential Growth  method.
R :  0.3359444[ 0.3209695 , 0.3510899 ]
```
I tried another endpoint, 27 as in the example:
```
> estR0 = estimate.R(china_vect, mGT, begin=1, end=27,
+                   methods="EG",
+                   pop.size=pop_ch, nsim=100)
Waiting for profiling to be done...
Error: no valid set of coefficients has been found: please supply starting
values
In addition: There were 11 warnings (use warnings() to see them)
> warnings()
Warning messages:
1: glm.fit: algorithm did not converge
2: glm.fit: fitted rates numerically 0 occurred
3: glm.fit: fitted rates numerically 0 occurred
4: glm.fit: fitted rates numerically 0 occurred
5: glm.fit: fitted rates numerically 0 occurred
6: glm.fit: fitted rates numerically 0 occurred
7: glm.fit: fitted rates numerically 0 occurred
8: glm.fit: fitted rates numerically 0 occurred
9: glm.fit: fitted rates numerically 0 occurred
10: glm.fit: fitted rates numerically 0 occurred
11: glm.fit: fitted rates numerically 0 occurred
```
Why these errors?
Is there a better tutorial on how to apply this function?
Thank you

	[[alternative HTML version deleted]]



More information about the R-help mailing list