diff --git a/R/get.R b/R/get.R index bf233076c..e376b55e6 100644 --- a/R/get.R +++ b/R/get.R @@ -310,6 +310,11 @@ get_regions_with_most_reports <- function(reported_cases, ##' @param generation_time Generation time as specified using `dist_spec` ##' @return An integer seeding time ##' @author Sebastian Funk +##' @examples +##' gt1 <- dist_spec(mean = 5, sd = 1, max = 15) +##' gt2 <- dist_spec(mean = 10, sd = 2, max = 10) +##' delays <- dist_spec(mean = 5, sd = 1, max = 15) +##' get_seeding_time(delays, gt1 + gt2) get_seeding_time <- function(delays, generation_time) { # Estimate the mean delay ----------------------------------------------- seeding_time <- sum(mean(delays)) @@ -318,10 +323,11 @@ get_seeding_time <- function(delays, generation_time) { } else { seeding_time <- as.integer(seeding_time) } - ## make sure we have at least gt_max seeding time + ## make sure we have at least (length of total gt pmf - 1) seeding time seeding_time <- max( seeding_time, - sum(generation_time$max) + sum(generation_time$np_pmf_max) + sum(generation_time$max) + sum(generation_time$np_pmf_max) - + length(generation_time$max) - length(generation_time$np_pmf_max) ) return(seeding_time) } diff --git a/man/get_seeding_time.Rd b/man/get_seeding_time.Rd index 77c7f51b6..53a9dca4f 100644 --- a/man/get_seeding_time.Rd +++ b/man/get_seeding_time.Rd @@ -18,6 +18,12 @@ An integer seeding time The seeding time is set to the mean of the specified delays, constrained to be at least the maximum generation time } +\examples{ +gt1 <- dist_spec(mean = 5, sd = 1, max = 15) +gt2 <- dist_spec(mean = 10, sd = 2, max = 10) +delays <- dist_spec(mean = 5, sd = 1, max = 15) +get_seeding_time(delays, gt1 + gt2) +} \author{ Sebastian Funk }