estimate_peak: Estimate the peak date of an incidence curve using bootstrap

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/estimate_peak.R

Description

This function can be used to estimate the peak of an epidemic curve stored as incidence, using bootstrap. See bootstrap for more information on the resampling.

Usage

1
estimate_peak(x, n = 100, alpha = 0.05)

Arguments

x

An incidence object.

n

The number of bootstrap datasets to be generated; defaults to 100.

alpha

The type 1 error chosen for the confidence interval; defaults to 0.05.

Details

Input dates are resampled with replacement to form bootstrapped datasets; the peak is reported for each, resulting in a distribution of peak times. When there are ties for peak incidence, only the first date is reported.

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

Value

A list containing the following items:

Author(s)

Thibaut Jombart thibautjombart@gmail.com, with inputs on caveats from Michael Höhle.

See Also

bootstrap for the bootstrapping underlying this approach and find_peak to find the peak in a single incidence object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
if (require(outbreaks) && require(ggplot2)) { withAutoprint({
  i <- incidence(fluH7N9_china_2013$date_of_onset)
  i
  plot(i)

  ## one simple bootstrap
  x <- bootstrap(i)
  x
  plot(x)

  ## find 95% CI for peak time using bootstrap
  peak_data <- estimate_peak(i)
  peak_data
  summary(peak_data$peaks)

  ## show confidence interval
  plot(i) + geom_vline(xintercept = peak_data$ci, col = "red", lty = 2)

  ## show the distribution of bootstrapped peaks
  df <- data.frame(peak = peak_data$peaks)
  plot(i) + geom_density(data = df,
                         aes(x = peak, y = 10 * ..scaled..),
                         alpha = .2, fill = "red", color = "red")

})}

incidence documentation built on Nov. 8, 2020, 4:30 p.m.