Peak estimation

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")
bootstrap(x)
#> # incidence:  67 x 4
#> # count vars: date_of_onset
#> # groups:     gender
#>    date_index gender count_variable count
#>  * <date>     <fct>  <chr>          <int>
#>  1 2013-02-19 m      date_of_onset      0
#>  2 2013-02-27 m      date_of_onset      0
#>  3 2013-03-07 m      date_of_onset      2
#>  4 2013-03-08 m      date_of_onset      2
#>  5 2013-03-09 f      date_of_onset      0
#>  6 2013-03-13 f      date_of_onset      3
#>  7 2013-03-17 m      date_of_onset      1
#>  8 2013-03-19 f      date_of_onset      1
#>  9 2013-03-20 f      date_of_onset      0
#> 10 2013-03-20 m      date_of_onset      1
#> # ℹ 57 more rows

find_peak()

dat <- fluH7N9_china_2013
x <- incidence(dat, date_index = "date_of_onset", groups = "gender")

# peaks across each group
find_peak(x)
#> # incidence:  2 x 4
#> # count vars: date_of_onset
#> # groups:     gender
#>   date_index gender count_variable count
#>   <date>     <fct>  <chr>          <int>
#> 1 2013-04-11 f      date_of_onset      3
#> 2 2013-04-03 m      date_of_onset      6

# peak without groupings
find_peak(regroup(x))
#> # incidence:  1 x 3
#> # count vars: date_of_onset
#>   date_index count_variable count
#>   <date>     <chr>          <int>
#> 1 2013-04-03 date_of_onset      7

estimate_peak()

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

  • the total number of event is known (no uncertainty on total incidence);
  • dates with no events (zero incidence) will never be in bootstrapped datasets; and
  • the reporting is assumed to be constant over time, i.e. every case is equally likely to be reported.
dat <- fluH7N9_china_2013
x <- incidence(dat, date_index = "date_of_onset", groups = "province")

# regrouping for overall peak (we suspend progress bar for markdown)
estimate_peak(regroup(x), progress = FALSE)
#> # A data frame: 1 × 7
#>   count_variable observed_peak observed_count bootstrap_peaks lower_ci  
#>   <chr>          <date>                 <int> <list>          <date>    
#> 1 date_of_onset  2013-04-03                 7 <df [100 × 1]>  2013-03-29
#> # ℹ 2 more variables: median <date>, upper_ci <date>

# across provinces
estimate_peak(x, progress = FALSE)
#> # A data frame: 13 × 8
#>    province  count_variable observed_peak observed_count bootstrap_peaks
#>    <fct>     <chr>          <date>                 <int> <list>         
#>  1 Anhui     date_of_onset  2013-03-09                 1 <df [100 × 1]> 
#>  2 Beijing   date_of_onset  2013-04-11                 1 <df [100 × 1]> 
#>  3 Fujian    date_of_onset  2013-04-17                 1 <df [100 × 1]> 
#>  4 Guangdong date_of_onset  2013-07-27                 1 <df [100 × 1]> 
#>  5 Hebei     date_of_onset  2013-07-10                 1 <df [100 × 1]> 
#>  6 Henan     date_of_onset  2013-04-06                 1 <df [100 × 1]> 
#>  7 Hunan     date_of_onset  2013-04-14                 1 <df [100 × 1]> 
#>  8 Jiangsu   date_of_onset  2013-03-19                 2 <df [100 × 1]> 
#>  9 Jiangxi   date_of_onset  2013-04-15                 1 <df [100 × 1]> 
#> 10 Shandong  date_of_onset  2013-04-16                 1 <df [100 × 1]> 
#> 11 Shanghai  date_of_onset  2013-04-01                 4 <df [100 × 1]> 
#> 12 Taiwan    date_of_onset  2013-04-12                 1 <df [100 × 1]> 
#> 13 Zhejiang  date_of_onset  2013-04-06                 5 <df [100 × 1]> 
#> # ℹ 3 more variables: lower_ci <date>, median <date>, upper_ci <date>