This function can be used to bootstrap incidence2::incidence objects. Bootstrapping is done by sampling with replacement the original input dates. See details for more information on how this is implemented.

bootstrap(x, randomise_groups = FALSE)

Arguments

x

An incidence2::incidence object.

randomise_groups

A logical indicating whether groups should be randomised as well in the resampling procedure; respective group sizes will be preserved, but this can be used to remove any group-specific temporal dynamics. If FALSE (default), data are resampled within groups.

Value

An incidence2 object.

Details

As original data are not stored in incidence2::incidence objects, the bootstrapping is achieved by multinomial sampling of date bins weighted by their relative incidence.

See also

find_peak() to use estimate peak date using bootstrap

Author

Thibaut Jombart, Tim Taylor

Examples

if (requireNamespace("outbreaks", quietly = TRUE)) { data(fluH7N9_china_2013, package = "outbreaks") i <- incidence2::incidence(fluH7N9_china_2013, date_index = date_of_onset) bootstrap(i) bootstrap(i, randomise_groups = TRUE) }
#> 10 missing observations were removed.
#> An incidence object: 46 x 2 #> date range: [2013-02-19] to [2013-07-27] #> cases: 126 #> interval: 1 day #> #> date_index count #> <date> <int> #> 1 2013-02-19 2 #> 2 2013-02-27 2 #> 3 2013-03-07 4 #> 4 2013-03-08 3 #> 5 2013-03-09 1 #> 6 2013-03-13 1 #> 7 2013-03-17 0 #> 8 2013-03-19 1 #> 9 2013-03-20 2 #> 10 2013-03-21 2 #> # … with 36 more rows