estimate_Re.Rd
estimate_Re()
takes the number of infections through time
and computes the Re value through time (also known as Rt).
estimate_Re( incidence_data, estimation_method = "EpiEstim sliding window", simplify_output = FALSE, ... )
incidence_data | An object containing incidence data through time. It can either be:
|
---|---|
estimation_method | string. Method used to estimate reproductive number values through time from the reconstructed infection timings. Available options are:
|
simplify_output | boolean. Simplify the output when possible? |
... | Arguments passed on to
|
A list with two elements:
A numeric vector named values
: the result of the computations on the input data.
An integer named index_offset
: the offset, counted in number of time steps,
by which the result is shifted compared to an index_offset
of 0
.
This parameter allows one to keep track of the date of the first value in values
without needing to carry a date
column around.
A positive offset means values
are delayed in the future compared to the reference values.
A negative offset means the opposite.
Note that the index_offset
of the output of the function call
accounts for the (optional) index_offset
of the input.
If index_offset
is 0
and simplify_output = TRUE
,
the index_offset
is dropped and the values
element is returned as a numeric vector.
If output_HPD = TRUE
(additional parameter),
the highest posterior density interval boundaries are output along with the mean Re estimates.
In that case, a list of three lists is returned:
Re_estimate
contains the Re estimates.
Re_highHPD
and Re_lowHPD
contain
the higher and lower boundaries of the HPD interval,
as computed by estimate_R
If, in addition, simplify_output = TRUE
,
then the 3 elements are merged into a single dataframe by merge_outputs()
.
A date column can be added to the dataframe by passing an extra ref_date
argument
(see merge_outputs
for details).
a module output object. Re estimates.
The incidence input should represent infections,
as opposed to representing delayed observations of infections.
If the incidence data represents delayed observations of infections,
one should first reconstruct the incidence of infections using
deconvolve_incidence()
or get_infections_from_incidence()
which wraps around it and includes a smoothing step of the delayed observations.
estimate_Re()
wraps around the estimate_R()
function
of the EpiEstim
package from Cori et al, 2013.
estimate_Re()
allows for two types of Re estimations:
A sliding-window estimation.
For each time step T, the Re(T) value is computed by assuming that Re is constant
for time steps (T-X+1, ..., T-1, T), with X being the sliding window size.
This option is chosen by setting estimation_method = "EpiEstim sliding window"
A piecewise-constant estimation.
Re(t) is computed as being a piecewise-constant function of time.
The length of each step can be a fixed number of time steps.
That number is specified using the interval_length
parameter.
The length of each step can also be irregular.
This can be useful if the boundaries of the steps are meant to coincide with particular events
such as the implementation or cancellation of public health interventions.
The right boundaries of the steps are specified using the interval_ends
parameter.
This option is chosen by setting estimation_method = "EpiEstim piecewise constant"
## Building incidence_data # estimate_Re assumes incidence_data represents infections, not delayed noisy # observations of infections. Thus, we need to first smooth the incidence data # and then perform a deconvolution step. For more details, see the smooth_incidence # and deconvolve_incidence functions. shape_incubation <- 3.2 scale_incubation <- 1.3 delay_incubation <- list(name = "gamma", shape = shape_incubation, scale = scale_incubation) shape_onset_to_report = 2.7 scale_onset_to_report = 1.6 delay_onset_to_report <- list(name="gamma", shape = shape_onset_to_report, scale = scale_onset_to_report) smoothed_incidence <- smooth_incidence(HK_incidence_data$case_incidence) deconvolved_incidence <- deconvolve_incidence( smoothed_incidence, delay = list(delay_incubation, delay_onset_to_report) ) ## Basic usage of estimate_Re Re_estimate_1 <- estimate_Re(incidence_data = deconvolved_incidence) ## Advanced usage of estimate_Re # Incorporating prior knowledge over Re. Here, Re is assumed constant over a time # frame of one week, with a prior mean of 1.25. Re_estimate_2 <- estimate_Re( incidence_data = deconvolved_incidence, estimation_method = 'EpiEstim piecewise constant', interval_length = 7, mean_Re_prior = 1.25 ) # Incorporating prior knowledge over the disease. Here, the mean of the serial # interval is assumed to be 5 days, and the standard deviation is assumed to be # 2.5 days. Re_estimate_3 <- estimate_Re( incidence_data = deconvolved_incidence, mean_serial_interval = 5, std_serial_interval = 2.5 ) # Incorporating prior knowledge over the epidemic. Here, it is assumed that Re # changes values 4 times during the epidemic, so the intervals over which Re is # assumed to be constant are passed as a parameter. last_interval_index <- length(deconvolved_incidence$values) + deconvolved_incidence$index_offset Re_estimate_4 <- estimate_Re( incidence_data = deconvolved_incidence, estimation_method = "EpiEstim piecewise constant", interval_ends = c(50, 75, 100, 160, last_interval_index) ) # Recovering the Re HPD as well. Re_estimate_5 <- estimate_Re( incidence_data = deconvolved_incidence, output_HPD = TRUE )