convolve_delays.Rd
Take a list of delay distributions and return their convolution.
The convolution of a delay A -> B and a delay B -> C corresponds to the
delay distribution of A -> C.
Delays are assumed to happen in the same chronological order as the order
they are given in in the delays
list.
convolve_delays(delays, n_report_time_steps = NULL, ...)
delays | List of delays, with flexible structure.
Each delay in the
|
---|---|
n_report_time_steps | integer. Length of incidence time series. Use only when providing empirical delay data. |
... | Arguments passed on to
|
a discretized delay distribution vector or matrix. A vector is returned when input delay distributions are constant through time: either they are vectors already or in the form of a list-specified distribution. A matrix is returned when at least one of the delays has a delay distribution that can change through time. This is the case with empirical delay data or if any of the input is already a delay distribution matrix.
This function is flexible in the type of delay inputs it can handle.
Each delay in the delays
list can be one of:
a list representing a distribution object
a discretized delay distribution vector
a discretized delay distribution matrix
a dataframe containing empirical delay data
see get_matrix_from_empirical_delay_distr
for details on the format
expected for the empirical delay data.
## Convolving the delay between infection and onset of symptoms with the delay # between onset of symptoms and case report to obtain the final delay between # infection and case report. Using the resulting delay distribution to recover # the original infection events smoothed_incidence <- smooth_incidence(HK_incidence_data$case_incidence) 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) total_delay_1 <- convolve_delays(list(delay_incubation, delay_onset_to_report)) deconvolved_incidence <- deconvolve_incidence( incidence_data = smoothed_incidence, delay = total_delay_1 ) ## Convolving multiple delays # In this example it is assumed that the delay between infection and case report # is composed of three delays; the delay between infection and symptom onset, # the delay between symptom onset and case testing shape_incubation = 3.2 scale_incubation = 1.3 delay_incubation <- list(name="gamma", shape = shape_incubation, scale = scale_incubation) delay_onset_to_test_taken <- list(name = "norm", mean = 5, sd = 2) delay_test_to_report <- list(name="norm", mean = 2, sd = 0.5) total_delay_2 <- convolve_delays(list(delay_incubation, delay_onset_to_test_taken, delay_test_to_report)) ## Convolving delays of multiple types # Defining the incubation period as a probability vector, and the delay between # symptom onset and case observation as a delay matrix delay_incubation <- c(0.01, 0.1, 0.15, 0.18, 0.17, 0.14, 0.11, 0.07, 0.035, 0.020, 0.015) delay_matrix <- get_matrix_from_empirical_delay_distr( HK_delay_data, n_report_time_steps = 50 ) total_delay_3 <- convolve_delays(list(delay_incubation, delay_matrix))