Skip to contents

This function can be used to bootstrap [incidence2] objects. Bootstrapping is done by sampling with replacement the original input dates.

Usage

bootstrap(x, randomise_groups = FALSE)

Arguments

x

An [incidence2] object.

randomise_groups

[bool]

Should groups 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.

Author

Thibaut Jombart, Tim Taylor

Examples

if (requireNamespace("outbreaks", quietly = TRUE)) {
    data(fluH7N9_china_2013, package = "outbreaks")
    i <- incidence(
        fluH7N9_china_2013,
        date_index = "date_of_onset",
        groups = "gender"
   )
   bootstrap(i)
}
#> # 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      1
#>  2 2013-02-27 m      date_of_onset      1
#>  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      0
#>  7 2013-03-17 m      date_of_onset      0
#>  8 2013-03-19 f      date_of_onset      3
#>  9 2013-03-20 f      date_of_onset      4
#> 10 2013-03-20 m      date_of_onset      1
#> # … with 57 more rows