Lauren McGough (@unrealmcg) and I have been doing some simple tests to compare Rt methods on synthetic data. We've been running into errors when calling the wallinga_teunis()
function in EpiEstim, of the form values must be length <A,> but FUN(X[[1]]) result is length <B>
.
This only happens when n_sim > 0
. If n_sim == 0
—skipping the CIs—it seems to be fine.
E.g.:
Error in vapply(seq_len(config$n_sim), function(i) draw_one_set_of_ancestries(), :
values must be length 19889,
but FUN(X[[1]]) result is length 19885
Calls: wallinga_teunis -> t -> vapply
Execution halted
That error came from the following code, with inline data (just generated from a stochastic SEIR model):
library(EpiEstim)
incidence <- c(
1, 3, 2, 2, 2, 1, 1, 1, 1, 1, 4, 1, 4, 3, 2, 2, 2, 3, 7, 8, 3, 0, 1, 0, 3, 3, 3, 2, 1, 1, 3, 1, 3, 2, 0, 0, 3, 2, 0, 1, 2, 0, 2, 2, 1, 1, 2, 1, 2, 2, 1, 1, 2, 3, 5, 5, 5, 3, 4, 5, 3, 6, 2, 3, 10, 8, 7, 7, 11, 5, 7, 11, 7, 4, 12, 10, 9, 13, 10, 12, 9, 5, 8, 9, 6, 8, 11, 9, 12, 12, 7, 12, 9, 15, 10, 8, 13, 13, 19, 8, 5, 14, 15, 10, 15, 12, 17, 14, 13, 13, 14, 16, 16, 14, 11, 13, 19, 21, 15, 15, 20, 14, 11, 23, 12, 20, 21, 18, 18, 19, 18, 20, 20, 17, 18, 31, 28, 13, 29, 20, 24, 31, 25, 29, 23, 33, 24, 27, 30, 26, 26, 24, 25, 21, 28, 41, 31, 32, 47, 29, 37, 36, 35, 35, 35, 46, 41, 37, 38, 28, 41, 35, 35, 38, 20, 31, 38, 42, 35, 31, 42, 39, 47, 30, 57, 33, 40, 29, 28, 41, 34, 33, 42, 48, 32, 38, 33, 46, 45, 41, 42, 46, 42, 39, 52, 43, 46, 44, 33, 45, 56, 36, 54, 51, 52, 45, 51, 57, 55, 59, 60, 45, 46, 56, 37, 49, 58, 38, 55, 47, 60, 51, 41, 51, 36, 63, 35, 43, 57, 60, 43, 60, 60, 51, 44, 51, 64, 65, 75, 68, 65, 66, 62, 69, 57, 67, 67, 69, 68, 78, 60, 72, 64, 66, 61, 67, 55, 71, 82, 60, 78, 77, 70, 76, 64, 63, 62, 58, 75, 80, 71, 80, 67, 57, 67, 63, 81, 77, 77, 72, 74, 69, 64, 83, 66, 77, 73, 62, 64, 82, 72, 72, 58, 56, 66, 86, 68, 70, 63, 71, 60, 61, 57, 54, 54, 60, 58, 60, 62, 68, 46, 70, 75, 59, 73, 58, 67, 50, 66, 59, 69, 68, 63, 76, 62, 62, 58, 66, 60, 75, 60, 78, 63, 53, 70, 66, 71, 46, 61, 66, 72, 75, 83, 64, 73, 64, 55, 88, 63, 66, 67, 66, 78, 62, 71, 70, 77, 65, 45, 76, 73, 72, 53, 50, 68, 65, 66, 44, 52, 59, 77, 52, 66, 61, 66, 64, 68, 59, 64, 51, 46, 57, 61, 52, 44, 58, 48, 40, 48, 55, 62, 42, 50, 53, 39, 53, 50, 49, 53, 49, 43, 44, 49, 44, 43, 42, 39, 37, 37, 34, 41, 50, 46, 30, 43, 45, 35, 27, 37, 45, 32, 46, 26, 26, 32, 27, 34, 34, 23, 33, 36, 28, 36, 33, 32, 29, 38, 31, 30, 30, 38, 27, 34, 38, 34, 19, 27, 35, 32, 28, 36, 26, 25, 33, 23, 26, 28, 20, 27, 24, 25, 20, 28, 21, 20, 26, 24, 19, 16, 21, 22, 17, 23, 22, 17, 24, 30, 17, 16, 18, 16, 15, 17, 18, 16, 14, 18, 21, 18, 14, 19, 17, 17, 10, 19, 19, 14, 13, 15, 9, 9, 10, 13, 10, 9, 13, 8, 10, 14, 9, 9, 10, 5, 17, 14, 10, 14, 14, 5, 15, 12, 9, 11, 18, 12, 11, 12, 14, 13, 13, 10, 10, 17, 15, 7, 13, 11, 8, 7, 9, 9, 7, 9, 6, 10, 14, 10, 7, 3, 5, 11, 9, 4, 7, 5, 5, 7, 5, 9, 8, 6, 3, 4, 8, 6, 6, 8, 5, 5, 5, 6, 8, 4, 3, 7, 8, 7, 3, 5, 7, 7, 4, 2, 4, 7, 1, 2, 3, 3, 5, 4, 3, 2, 4, 5, 1, 3, 1, 3, 1, 3, 3, 4, 2, 6, 0, 2, 6, 7, 4, 4, 4, 2, 0, 6, 0, 1, 2, 3, 0, 1, 2, 5, 3, 5, 3, 1, 1, 3, 1, 3, 1, 4, 2, 4, 3, 2, 2, 3, 3, 1, 1, 3, 6, 3, 2, 1, 2, 3, 4, 3, 2, 0, 2, 4, 3, 4, 0, 5, 2, 1, 1, 4, 1, 1, 2, 2, 5, 2, 1, 1, 4, 1, 3, 3, 4, 3, 5, 3, 3, 5, 4, 2, 0, 2, 3, 5, 3, 2, 7, 1, 1, 2, 1, 2, 1, 1, 3, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 2, 0, 0, 0, 0, 0, 1, 0, 3, 0, 1, 0, 0, 0, 0, 2, 1, 1, 1, 0, 0, 2, 2, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 3, 1, 3, 1, 1, 1, 2, 0, 3, 1, 0, 2, 1, 1, 0, 0, 2, 0, 1, 1, 0, 0, 2, 1, 0, 2, 1, 0, 0, 0, 0, 2, 1, 1, 0, 0, 1, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0
)
n_t <- length(incidence)
mean_serial_int <- 1/(1.1 / 5) + 3
std_serial_int <- mean_serial_int
window_size <- 11
t_start <- seq(2, n_t - 20)
t_end <- t_start + window_size - 1
wt_result <- wallinga_teunis(
incidence, method="parametric_si",
config = list(
t_start = t_start,
t_end = t_end,
mean_si = mean_serial_int,
std_si = std_serial_int,
n_sim = 10
)
)
bug