From 711edaab8249ce061d26eebd826b1a100a157d47 Mon Sep 17 00:00:00 2001 From: Andree Valle Campos Date: Sat, 4 May 2024 02:12:26 +0100 Subject: [PATCH] print summary table (#70) and use it for threshold --- episodes/superspreading-simulate.Rmd | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/episodes/superspreading-simulate.Rmd b/episodes/superspreading-simulate.Rmd index 40590df1..57f1ab5c 100644 --- a/episodes/superspreading-simulate.Rmd +++ b/episodes/superspreading-simulate.Rmd @@ -571,6 +571,8 @@ sim_chains_max <- cases_total = max(cases_cumsum) ) %>% ungroup() + +sim_chains_max ``` Now, we are prepared for using the `{ggplot2}` package: @@ -635,18 +637,13 @@ chains_null <- sim_chains_max %>% Although most introductions of `r initial_cases` index case do not generate secondary cases (N = `r chains_null`) or most outbreaks rapidly become extinct (median duration of `r chains_extinct$extinct_duration_median` and median size of `r chains_extinct$extinct_size_median`), only `r threshhold_summary$chains_theshold` epidemic trajectories among `r threshhold_summary$chains_number` simulations (`r threshhold_summary$chains_percentage`%) can reach to more than 100 infected cases. This finding is particularly remarkable because the reproduction number $R$ is less than 1 (offspring distribution mean of `r mers_offspring[["mean"]]`), but, given an offspring distribution dispersion parameter of `r mers_offspring[["dispersion"]]`, it shows the potential for explosive outbreaks of MERS disease. -For a summary of the total time duration and size of each chain, we can use the `{dplyr}` "combo" of `group_by()` and `summarise()`: +We can count how many chains reached the 100-case threshold using `{dplyr}` functions: -```{r,eval=FALSE} -simulated_chains_day %>% - group_by(chain_id) %>% - summarise( - # duration - day_max = max(day), - # size - cases_total = max(cases_cumsum) - ) %>% - ungroup() +```{r} +# number of chains that reached the 100-case threshold +sim_chains_max %>% + arrange(desc(day_max)) %>% + filter(cases_total > 100) ```