Peak estimation

Tim Taylor

library(outbreaks)
library(incidence2)
library(i2extras) 

Bootstrapping and finding peaks

We provide functions to return the peak of the incidence data (grouped or ungrouped), bootstrap from the incidence data, and estimate confidence intervals around a peak.

bootstrap()

dat <- fluH7N9_china_2013
x <- incidence(dat, date_index = date_of_onset, groups = gender)
#> 10 missing observations were removed.
bootstrap(x)
#> An incidence2 object: 51 x 3
#> [126 cases from days 2013-02-27 to 2013-07-10]
#> [interval: 1 day]
#> [cumulative: FALSE]
#> 
#>    date       gender count
#>    <date>     <fct>  <int>
#>  1 2013-02-27 m          1
#>  2 2013-03-07 m          1
#>  3 2013-03-09 f          1
#>  4 2013-03-13 f          1
#>  5 2013-03-19 f          2
#>  6 2013-03-20 f          1
#>  7 2013-03-21 m          1
#>  8 2013-03-22 f          1
#>  9 2013-03-25 m          3
#> 10 2013-03-27 f          3
#> # … with 41 more rows

find_peak()

dat <- fluH7N9_china_2013
x <- incidence(dat, date_index = date_of_onset, groups = gender)
#> 10 missing observations were removed.

# peaks across each group
x %>% find_peak(regroup = FALSE)
#> # A tibble: 2 x 3
#>   date       gender count
#>   <date>     <fct>  <int>
#> 1 2013-04-11 f          3
#> 2 2013-04-03 m          6

# peak without groupings
x %>% find_peak()
#> `.` is stratified by groups
#> regrouping groups before finding peaks
#> An incidence2 object: 1 x 2
#> [7 cases from days 2013-04-03 to 2013-04-03]
#> [interval: 1 day]
#> [cumulative: FALSE]
#> 
#>   date       count
#>   <date>     <int>
#> 1 2013-04-03     7

estimate_peak()

Note that the bootstrapping approach used for estimating the peak time makes the following assumptions:

dat <- fluH7N9_china_2013
x <- incidence(dat, date_index = date_of_onset, groups = province)
#> 10 missing observations were removed.

# regrouping for overall peak
x %>% regroup() %>% estimate_peak()
#> ================================================================================
#> # A tibble: 1 x 6
#>   date       observed_count estimated_date lower_ci   upper_ci   peaks          
#>   <date>              <int> <date>         <date>     <date>     <list>         
#> 1 2013-04-03              7 2013-04-06     2013-03-29 2013-04-14 <tibble [100 ×…

# across provinces and with progress bar suppressed
x %>% estimate_peak(progress = FALSE)
#> # A tibble: 13 x 7
#>    province date       observed_count estimated_date lower_ci   upper_ci   peaks
#>    <chr>    <date>              <int> <date>         <date>     <date>     <lis>
#>  1 Anhui    2013-03-09              1 2013-03-26     2013-03-09 2013-04-14 <tib…
#>  2 Beijing  2013-04-11              1 2013-04-22     2013-04-11 2013-05-21 <tib…
#>  3 Fujian   2013-04-17              1 2013-04-20     2013-04-17 2013-04-29 <tib…
#>  4 Guangdo… 2013-07-27              1 2013-07-27     2013-07-27 2013-07-27 <tib…
#>  5 Hebei    2013-07-10              1 2013-07-10     2013-07-10 2013-07-10 <tib…
#>  6 Henan    2013-04-06              1 2013-04-09     2013-04-06 2013-04-17 <tib…
#>  7 Hunan    2013-04-14              1 2013-04-15     2013-04-14 2013-04-23 <tib…
#>  8 Jiangsu  2013-03-19              2 2013-03-26     2013-03-08 2013-04-17 <tib…
#>  9 Jiangxi  2013-04-15              1 2013-04-19     2013-04-15 2013-05-03 <tib…
#> 10 Shandong 2013-04-16              1 2013-04-19     2013-04-16 2013-04-27 <tib…
#> 11 Shanghai 2013-04-01              4 2013-03-30     2013-02-27 2013-04-04 <tib…
#> 12 Taiwan   2013-04-12              1 2013-04-12     2013-04-12 2013-04-12 <tib…
#> 13 Zhejiang 2013-04-06              5 2013-04-08     2013-03-31 2013-04-14 <tib…