--- title: "Peak estimation" author: "Tim Taylor" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Peak estimation} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.align = "center", fig.width = 7, fig.height = 5 ) ``` ```{r} 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()` ```{r bootstrap} dat <- fluH7N9_china_2013 x <- incidence(dat, date_index = "date_of_onset", groups = "gender") bootstrap(x) ``` ## `find_peak()` ```{r findpeak} dat <- fluH7N9_china_2013 x <- incidence(dat, date_index = "date_of_onset", groups = "gender") # peaks across each group find_peak(x) # peak without groupings find_peak(regroup(x)) ``` ## `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. ```{r estimatepeak} 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) # across provinces estimate_peak(x, progress = FALSE) ```