This function can be used to bootstrap incidence2 objects. Bootstrapping is done by sampling with replacement the original input dates.
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 objects, the bootstrapping is achieved by multinomial sampling of date bins weighted by their relative incidence.
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_incidence(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 0
#> 2 2013-02-27 m date_of_onset 2
#> 3 2013-03-07 m date_of_onset 1
#> 4 2013-03-08 m date_of_onset 0
#> 5 2013-03-09 f date_of_onset 0
#> 6 2013-03-13 f date_of_onset 1
#> 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 2
#> 10 2013-03-20 m date_of_onset 2
#> # ℹ 57 more rows