From 5a53e3a4addec72f81f556adc6a6cc411cfef8c2 Mon Sep 17 00:00:00 2001 From: Hugo Gruson <10783929+Bisaloo@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:14:00 +0100 Subject: [PATCH 1/2] Get EpiEstim chunk to work with SI passed as epidist --- .../skeleton/rmdchunks/EpiEstim.Rmd | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/inst/rmarkdown/templates/transmissibility/skeleton/rmdchunks/EpiEstim.Rmd b/inst/rmarkdown/templates/transmissibility/skeleton/rmdchunks/EpiEstim.Rmd index 65551c2f..ba8855b2 100644 --- a/inst/rmarkdown/templates/transmissibility/skeleton/rmdchunks/EpiEstim.Rmd +++ b/inst/rmarkdown/templates/transmissibility/skeleton/rmdchunks/EpiEstim.Rmd @@ -16,13 +16,12 @@ library(EpiEstim) # Function to process a distrcrete object and output `si_discr` argument for # EpiEstim::make_config -wrap_si <- function(x) { - stopifnot(inherits(x, "distcrete")) - max_x <- x$q(0.999) - x <- si$d(seq_len(max_x)) - x[1] <- 0 - x <- x / sum(x) - x +wrap_si <- function(si) { + domain <- seq(1L, to = si$prob_dist$qf(0.999), by = 1L) + pmf <- si$prob_dist$d(domain) + pmf[1] <- 0 + pmf <- pmf / sum(pmf) + pmf } From 90bf4bff433a6ba95c45b018a417dce6d3e24223 Mon Sep 17 00:00:00 2001 From: Hugo Gruson <10783929+Bisaloo@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:14:15 +0100 Subject: [PATCH 2/2] Get i2extras to work with SI passed as epidist --- .../templates/transmissibility/skeleton/rmdchunks/i2extras.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/rmarkdown/templates/transmissibility/skeleton/rmdchunks/i2extras.Rmd b/inst/rmarkdown/templates/transmissibility/skeleton/rmdchunks/i2extras.Rmd index 44cd846e..b03fdc07 100644 --- a/inst/rmarkdown/templates/transmissibility/skeleton/rmdchunks/i2extras.Rmd +++ b/inst/rmarkdown/templates/transmissibility/skeleton/rmdchunks/i2extras.Rmd @@ -141,7 +141,7 @@ This section contains: ```{r } res_R_wl <- last_trends %>% - mutate(R = map(model, epitrix::lm2R0_sample, w = si, 500)) %>% + mutate(R = map(model, epitrix::lm2R0_sample, w = si$prob_dist$d(si_x))) %>% dplyr::select({{ group_var }}, R) %>% unnest(R)