diff --git a/404.html b/404.html index 41fcba57..0cdfc7d2 100644 --- a/404.html +++ b/404.html @@ -34,7 +34,7 @@ epichains - 0.1.1 + 0.1.1.9000 diff --git a/LICENSE-text.html b/LICENSE-text.html index 2e0401d0..d8f129f6 100644 --- a/LICENSE-text.html +++ b/LICENSE-text.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 diff --git a/LICENSE.html b/LICENSE.html index fffeb1b5..5c5f32da 100644 --- a/LICENSE.html +++ b/LICENSE.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ MIT License - Source: LICENSE.md + Source: LICENSE.md diff --git a/articles/branching_process_literature.html b/articles/branching_process_literature.html index 07b41593..f2a1863e 100644 --- a/articles/branching_process_literature.html +++ b/articles/branching_process_literature.html @@ -33,7 +33,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -90,7 +90,7 @@ Literature on branching process applications - Source: vignettes/branching_process_literature.Rmd + Source: vignettes/branching_process_literature.Rmd branching_process_literature.Rmd diff --git a/articles/design-principles.html b/articles/design-principles.html index 941dfd8e..00230c87 100644 --- a/articles/design-principles.html +++ b/articles/design-principles.html @@ -33,7 +33,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -92,7 +92,7 @@ An R package for simulating, handling, and analysing transmission chains in R - Source: vignettes/design-principles.Rmd + Source: vignettes/design-principles.Rmd design-principles.Rmd diff --git a/articles/epichains.html b/articles/epichains.html index 750f8aa5..1607a6f4 100644 --- a/articles/epichains.html +++ b/articles/epichains.html @@ -33,7 +33,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -93,7 +93,7 @@ James M. Azam and Sebastian Funk - Source: vignettes/epichains.Rmd + Source: vignettes/epichains.Rmd epichains.Rmd diff --git a/articles/index.html b/articles/index.html index d5d0d7ef..0435db2e 100644 --- a/articles/index.html +++ b/articles/index.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 diff --git a/articles/interventions.html b/articles/interventions.html index 09f27eb8..1573fec3 100644 --- a/articles/interventions.html +++ b/articles/interventions.html @@ -33,7 +33,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -92,7 +92,7 @@ Sebastian Funk and James M. Azam - Source: vignettes/interventions.Rmd + Source: vignettes/interventions.Rmd interventions.Rmd diff --git a/articles/projecting_incidence.html b/articles/projecting_incidence.html index 182affff..5c362be0 100644 --- a/articles/projecting_incidence.html +++ b/articles/projecting_incidence.html @@ -33,7 +33,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -92,7 +92,7 @@ James Azam, Sebastian Funk - Source: vignettes/projecting_incidence.Rmd + Source: vignettes/projecting_incidence.Rmd projecting_incidence.Rmd diff --git a/articles/theoretical_background.html b/articles/theoretical_background.html index 8fae316e..4b90cf3f 100644 --- a/articles/theoretical_background.html +++ b/articles/theoretical_background.html @@ -33,7 +33,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -92,7 +92,7 @@ Sebastian Funk and James Azam - Source: vignettes/theoretical_background.Rmd + Source: vignettes/theoretical_background.Rmd theoretical_background.Rmd diff --git a/authors.html b/authors.html index 18e114cf..b0cc2032 100644 --- a/authors.html +++ b/authors.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -96,18 +96,18 @@ Authors Citation - Source: DESCRIPTION + Source: DESCRIPTION Azam J, Funk S, Finger F (2024). epichains: Simulating and Analysing Transmission Chain Statistics Using Branching Process Models. -R package version 0.1.1, +R package version 0.1.1.9000, https://epiverse-trace.github.io/epichains/, https://github.com/epiverse-trace/epichains. @Manual{, title = {epichains: Simulating and Analysing Transmission Chain Statistics Using Branching Process Models}, author = {James M. Azam and Sebastian Funk and Flavio Finger}, year = {2024}, - note = {R package version 0.1.1, + note = {R package version 0.1.1.9000, https://epiverse-trace.github.io/epichains/}, url = {https://github.com/epiverse-trace/epichains}, } diff --git a/index.html b/index.html index 47af9025..9a924c6e 100644 --- a/index.html +++ b/index.html @@ -36,7 +36,7 @@ epichains - 0.1.1 + 0.1.1.9000 diff --git a/news/index.html b/news/index.html index 47c34f83..5d166629 100644 --- a/news/index.html +++ b/news/index.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,9 +55,12 @@ Changelog - Source: NEWS.md + Source: NEWS.md + +epichains (development version) + epichains 0.1.1CRAN release: 2024-10-14 This is the first CRAN release of epichains. diff --git a/pkgdown.yml b/pkgdown.yml index a387c37f..10fd30b5 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -8,7 +8,7 @@ articles: interventions: interventions.html projecting_incidence: projecting_incidence.html theoretical_background: theoretical_background.html -last_built: 2024-10-17T11:07Z +last_built: 2024-10-17T11:51Z urls: reference: https://epiverse-trace.github.io/epichains/reference article: https://epiverse-trace.github.io/epichains/articles diff --git a/reference/aggregate.epichains.html b/reference/aggregate.epichains.html index b7deaea3..4d5e5ebd 100644 --- a/reference/aggregate.epichains.html +++ b/reference/aggregate.epichains.html @@ -17,7 +17,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -59,7 +59,7 @@ Aggregate cases in <epichains> objects by "generation" or "time", if present - Source: R/epichains.R + Source: R/epichains.R aggregate.epichains.Rd diff --git a/reference/covid19_sa.html b/reference/covid19_sa.html index 452024d8..c0ea63f5 100644 --- a/reference/covid19_sa.html +++ b/reference/covid19_sa.html @@ -17,7 +17,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -59,7 +59,7 @@ COVID-19 Data Repository for South Africa - Source: R/covid19_sa.R + Source: R/covid19_sa.R covid19_sa.Rd diff --git a/reference/dborel.html b/reference/dborel.html index d99c9417..7b660d91 100644 --- a/reference/dborel.html +++ b/reference/dborel.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Density of the Borel distribution - Source: R/borel.R + Source: R/borel.R dborel.Rd diff --git a/reference/dot-adjust_next_gen.html b/reference/dot-adjust_next_gen.html index 3663a360..899a3ad1 100644 --- a/reference/dot-adjust_next_gen.html +++ b/reference/dot-adjust_next_gen.html @@ -17,7 +17,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -59,7 +59,7 @@ Adjust new offspring if it exceeds the susceptible population size - Source: R/helpers.R + Source: R/helpers.R dot-adjust_next_gen.Rd diff --git a/reference/dot-check_generation_time_valid.html b/reference/dot-check_generation_time_valid.html index d2ab8fea..553ab9fb 100644 --- a/reference/dot-check_generation_time_valid.html +++ b/reference/dot-check_generation_time_valid.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Check if the generation_time argument is specified as a function - Source: R/checks.R + Source: R/checks.R dot-check_generation_time_valid.Rd diff --git a/reference/dot-check_offspring_func_valid.html b/reference/dot-check_offspring_func_valid.html index 8b26032f..8c71df59 100644 --- a/reference/dot-check_offspring_func_valid.html +++ b/reference/dot-check_offspring_func_valid.html @@ -15,7 +15,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -57,7 +57,7 @@ Check if constructed random number generator for offspring exists and has an n argument. - Source: R/checks.R + Source: R/checks.R dot-check_offspring_func_valid.Rd diff --git a/reference/dot-check_sim_args.html b/reference/dot-check_sim_args.html index b1d63c42..14d4e9ea 100644 --- a/reference/dot-check_sim_args.html +++ b/reference/dot-check_sim_args.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Check inputs to simulate_chains() and simulate_summary() - Source: R/checks.R + Source: R/checks.R dot-check_sim_args.Rd diff --git a/reference/dot-check_statistic_args.html b/reference/dot-check_statistic_args.html index 94f6b326..557e6496 100644 --- a/reference/dot-check_statistic_args.html +++ b/reference/dot-check_statistic_args.html @@ -17,7 +17,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -59,7 +59,7 @@ Check that the statistic and stat_threshold arguments are valid - Source: R/checks.R + Source: R/checks.R dot-check_statistic_args.Rd diff --git a/reference/dot-check_time_args.html b/reference/dot-check_time_args.html index dba3cce9..2f5e757c 100644 --- a/reference/dot-check_time_args.html +++ b/reference/dot-check_time_args.html @@ -19,7 +19,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -61,7 +61,7 @@ Check inputs that control time events - Source: R/checks.R + Source: R/checks.R dot-check_time_args.Rd diff --git a/reference/dot-complementary_logprob.html b/reference/dot-complementary_logprob.html index 5b910cac..e5c096f4 100644 --- a/reference/dot-complementary_logprob.html +++ b/reference/dot-complementary_logprob.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Calculates the complementary log-probability - Source: R/utils.R + Source: R/utils.R dot-complementary_logprob.Rd diff --git a/reference/dot-epichains.html b/reference/dot-epichains.html index b3368e2e..b6b5367a 100644 --- a/reference/dot-epichains.html +++ b/reference/dot-epichains.html @@ -33,7 +33,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -75,7 +75,7 @@ Create an <epichains> object - Source: R/epichains.R + Source: R/epichains.R dot-epichains.Rd diff --git a/reference/dot-epichains_summary.html b/reference/dot-epichains_summary.html index e28bd6b2..de647117 100644 --- a/reference/dot-epichains_summary.html +++ b/reference/dot-epichains_summary.html @@ -19,7 +19,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -61,7 +61,7 @@ Create an <epichains_summary> object - Source: R/epichains.R + Source: R/epichains.R dot-epichains_summary.Rd diff --git a/reference/dot-gborel_size_ll.html b/reference/dot-gborel_size_ll.html index 578cd1cf..809838a0 100644 --- a/reference/dot-gborel_size_ll.html +++ b/reference/dot-gborel_size_ll.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Log-likelihood of the size of chains with gamma-Borel offspring distribution - Source: R/stat_likelihoods.R + Source: R/stat_likelihoods.R dot-gborel_size_ll.Rd diff --git a/reference/dot-geom_length_ll.html b/reference/dot-geom_length_ll.html index caf20436..1a250768 100644 --- a/reference/dot-geom_length_ll.html +++ b/reference/dot-geom_length_ll.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Log-likelihood of the length of chains with geometric offspring distribution - Source: R/stat_likelihoods.R + Source: R/stat_likelihoods.R dot-geom_length_ll.Rd diff --git a/reference/dot-get_statistic_func.html b/reference/dot-get_statistic_func.html index 28fdefe4..fc67f4b2 100644 --- a/reference/dot-get_statistic_func.html +++ b/reference/dot-get_statistic_func.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Return a function for calculating chain statistics - Source: R/helpers.R + Source: R/helpers.R dot-get_statistic_func.Rd diff --git a/reference/dot-get_susceptible_offspring.html b/reference/dot-get_susceptible_offspring.html index bf0f8bcf..63ab7c41 100644 --- a/reference/dot-get_susceptible_offspring.html +++ b/reference/dot-get_susceptible_offspring.html @@ -19,7 +19,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -61,7 +61,7 @@ Sample the number of susceptible offspring from all possible offspring - Source: R/helpers.R + Source: R/helpers.R dot-get_susceptible_offspring.Rd diff --git a/reference/dot-init_susc_pop.html b/reference/dot-init_susc_pop.html index 7350dab2..3075f8a1 100644 --- a/reference/dot-init_susc_pop.html +++ b/reference/dot-init_susc_pop.html @@ -21,7 +21,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -63,7 +63,7 @@ Adjust next generation vector to match susceptible population size - Source: R/helpers.R + Source: R/helpers.R dot-init_susc_pop.Rd diff --git a/reference/dot-is_epichains.html b/reference/dot-is_epichains.html index 05077f17..a12fa917 100644 --- a/reference/dot-is_epichains.html +++ b/reference/dot-is_epichains.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Test if x is an epichains object - Source: R/epichains.R + Source: R/epichains.R dot-is_epichains.Rd diff --git a/reference/dot-is_epichains_summary.html b/reference/dot-is_epichains_summary.html index b58c5a2d..9999c272 100644 --- a/reference/dot-is_epichains_summary.html +++ b/reference/dot-is_epichains_summary.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Test if x is an epichains_summary object - Source: R/epichains.R + Source: R/epichains.R dot-is_epichains_summary.Rd diff --git a/reference/dot-nbinom_size_ll.html b/reference/dot-nbinom_size_ll.html index 06248466..d85d53cc 100644 --- a/reference/dot-nbinom_size_ll.html +++ b/reference/dot-nbinom_size_ll.html @@ -15,7 +15,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -57,7 +57,7 @@ Log-likelihood of the size of chains with Negative-Binomial offspring distribution - Source: R/stat_likelihoods.R + Source: R/stat_likelihoods.R dot-nbinom_size_ll.Rd diff --git a/reference/dot-new_epichains.html b/reference/dot-new_epichains.html index 3b1a7525..f0ae0fba 100644 --- a/reference/dot-new_epichains.html +++ b/reference/dot-new_epichains.html @@ -25,7 +25,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -67,7 +67,7 @@ Construct an <epichains> object - Source: R/epichains.R + Source: R/epichains.R dot-new_epichains.Rd diff --git a/reference/dot-new_epichains_summary.html b/reference/dot-new_epichains_summary.html index 37c28aa5..695d2705 100644 --- a/reference/dot-new_epichains_summary.html +++ b/reference/dot-new_epichains_summary.html @@ -27,7 +27,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -69,7 +69,7 @@ Construct a <epichains_summary> object - Source: R/epichains.R + Source: R/epichains.R dot-new_epichains_summary.Rd diff --git a/reference/dot-offspring_ll.html b/reference/dot-offspring_ll.html index a3c4ba60..a9d4b473 100644 --- a/reference/dot-offspring_ll.html +++ b/reference/dot-offspring_ll.html @@ -17,7 +17,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -59,7 +59,7 @@ Log-likelihood of the summary (size/length) of chains with generic offspring distribution - Source: R/stat_likelihoods.R + Source: R/stat_likelihoods.R dot-offspring_ll.Rd diff --git a/reference/dot-pois_length_ll.html b/reference/dot-pois_length_ll.html index 160c2fc6..f2ffb01f 100644 --- a/reference/dot-pois_length_ll.html +++ b/reference/dot-pois_length_ll.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Log-likelihood of the length of chains with Poisson offspring distribution - Source: R/stat_likelihoods.R + Source: R/stat_likelihoods.R dot-pois_length_ll.Rd diff --git a/reference/dot-pois_size_ll.html b/reference/dot-pois_size_ll.html index 681bbaa7..bf05817e 100644 --- a/reference/dot-pois_size_ll.html +++ b/reference/dot-pois_size_ll.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Log-likelihood of the size of chains with Poisson offspring distribution - Source: R/stat_likelihoods.R + Source: R/stat_likelihoods.R dot-pois_size_ll.Rd diff --git a/reference/dot-rbinom_size.html b/reference/dot-rbinom_size.html index eca2043f..bbdb33d5 100644 --- a/reference/dot-rbinom_size.html +++ b/reference/dot-rbinom_size.html @@ -15,7 +15,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -57,7 +57,7 @@ Samples size (the number of trials) of a binomial distribution - Source: R/utils.R + Source: R/utils.R dot-rbinom_size.Rd diff --git a/reference/dot-rgen_length.html b/reference/dot-rgen_length.html index 2a8a3922..24924ae1 100644 --- a/reference/dot-rgen_length.html +++ b/reference/dot-rgen_length.html @@ -17,7 +17,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -59,7 +59,7 @@ Samples chain lengths with given observation probabilities - Source: R/utils.R + Source: R/utils.R dot-rgen_length.Rd diff --git a/reference/dot-sample_possible_offspring.html b/reference/dot-sample_possible_offspring.html index bf171338..1f3a9cbe 100644 --- a/reference/dot-sample_possible_offspring.html +++ b/reference/dot-sample_possible_offspring.html @@ -19,7 +19,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -61,7 +61,7 @@ Sample all possible offspring for the next generation - Source: R/helpers.R + Source: R/helpers.R dot-sample_possible_offspring.Rd diff --git a/reference/dot-update_chain_stat.html b/reference/dot-update_chain_stat.html index d48b58e9..d60e484c 100644 --- a/reference/dot-update_chain_stat.html +++ b/reference/dot-update_chain_stat.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Determine and update the chain statistic being tracked - Source: R/helpers.R + Source: R/helpers.R dot-update_chain_stat.Rd diff --git a/reference/dot-validate_epichains.html b/reference/dot-validate_epichains.html index ede87532..3a8b6da5 100644 --- a/reference/dot-validate_epichains.html +++ b/reference/dot-validate_epichains.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Validate an <epichains> object - Source: R/epichains.R + Source: R/epichains.R dot-validate_epichains.Rd diff --git a/reference/dot-validate_epichains_summary.html b/reference/dot-validate_epichains_summary.html index 2b2e7c18..0cccab53 100644 --- a/reference/dot-validate_epichains_summary.html +++ b/reference/dot-validate_epichains_summary.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Validate an <epichains_summary> object - Source: R/epichains.R + Source: R/epichains.R dot-validate_epichains_summary.Rd diff --git a/reference/epichains-package.html b/reference/epichains-package.html index f0eef180..878fb51e 100644 --- a/reference/epichains-package.html +++ b/reference/epichains-package.html @@ -15,7 +15,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -57,7 +57,7 @@ epichains: Simulating and Analysing Transmission Chain Statistics Using Branching Process Models - Source: R/epichains-package.R + Source: R/epichains-package.R epichains-package.Rd diff --git a/reference/head.epichains.html b/reference/head.epichains.html index 6ff64378..c458801c 100644 --- a/reference/head.epichains.html +++ b/reference/head.epichains.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ head and tail method for <epichains> class - Source: R/epichains.R + Source: R/epichains.R head.epichains.Rd diff --git a/reference/index.html b/reference/index.html index 81e7379e..afbcac99 100644 --- a/reference/index.html +++ b/reference/index.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 diff --git a/reference/likelihood.html b/reference/likelihood.html index 435f541b..27194bc4 100644 --- a/reference/likelihood.html +++ b/reference/likelihood.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Estimate the log-likelihood/likelihood for observed branching processes - Source: R/likelihood.R + Source: R/likelihood.R likelihood.Rd diff --git a/reference/print.epichains.html b/reference/print.epichains.html index b1814cde..b8339879 100644 --- a/reference/print.epichains.html +++ b/reference/print.epichains.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Print an <epichains> object - Source: R/epichains.R + Source: R/epichains.R print.epichains.Rd diff --git a/reference/print.epichains_summary.html b/reference/print.epichains_summary.html index 8a652b05..7a767103 100644 --- a/reference/print.epichains_summary.html +++ b/reference/print.epichains_summary.html @@ -23,7 +23,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -65,7 +65,7 @@ Print an <epichains_summary> object - Source: R/epichains.R + Source: R/epichains.R print.epichains_summary.Rd diff --git a/reference/rborel.html b/reference/rborel.html index 6074e313..30b5cade 100644 --- a/reference/rborel.html +++ b/reference/rborel.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Generate random numbers from the Borel distribution - Source: R/borel.R + Source: R/borel.R rborel.Rd diff --git a/reference/rgborel.html b/reference/rgborel.html index f8f1d0e7..ca365ab5 100644 --- a/reference/rgborel.html +++ b/reference/rgborel.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Generate random numbers from a Gamma-Borel mixture distribution - Source: R/borel.R + Source: R/borel.R rgborel.Rd diff --git a/reference/simulate_chain_stats.html b/reference/simulate_chain_stats.html index e8390961..695a90fc 100644 --- a/reference/simulate_chain_stats.html +++ b/reference/simulate_chain_stats.html @@ -31,7 +31,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -73,7 +73,7 @@ Simulate a vector of transmission chains statistics (sizes/lengths) - Source: R/simulate.R + Source: R/simulate.R simulate_chain_stats.Rd diff --git a/reference/simulate_chains.html b/reference/simulate_chains.html index fa82c973..b3cacc8d 100644 --- a/reference/simulate_chains.html +++ b/reference/simulate_chains.html @@ -31,7 +31,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -73,7 +73,7 @@ Simulate transmission chains - Source: R/simulate.R + Source: R/simulate.R simulate_chains.Rd diff --git a/reference/summary.epichains.html b/reference/summary.epichains.html index 6786606b..aea995ff 100644 --- a/reference/summary.epichains.html +++ b/reference/summary.epichains.html @@ -17,7 +17,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -59,7 +59,7 @@ Summary method for <epichains> class - Source: R/epichains.R + Source: R/epichains.R summary.epichains.Rd diff --git a/reference/summary.epichains_summary.html b/reference/summary.epichains_summary.html index 77def6b0..2b487ce0 100644 --- a/reference/summary.epichains_summary.html +++ b/reference/summary.epichains_summary.html @@ -13,7 +13,7 @@ epichains - 0.1.1 + 0.1.1.9000 @@ -55,7 +55,7 @@ Summary method for <epichains_summary> class - Source: R/epichains.R + Source: R/epichains.R summary.epichains_summary.Rd diff --git a/search.json b/search.json index df9d619e..b1c17de5 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://epiverse-trace.github.io/epichains/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 epichains authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/epichains/articles/design-principles.html","id":"scope","dir":"Articles","previous_headings":"","what":"Scope","title":"Design Principles for {epichains}","text":"{epichains} aims facilitate: Simulation transmission chains using branching processes methods, Handling transmission chains using objected-orientated design, Analytical/closed-form likelihoods take form __ll>, example, gborel_size_ll() pois_length_ll(). Numerical likelihood simulation using offspring_ll(). Additionally, package provides mixture probability distributions generating offspring distributions, example, rborel().","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/epichains/articles/design-principles.html","id":"simulation-functions","dir":"Articles","previous_headings":"Design decisions","what":"Simulation functions","title":"Design Principles for {epichains}","text":"Simulation branching processes achieved simulate_chains() simulate_chain_stats(). details underlying methods, see theory vignette. simulations stochastic, meaning one set inputs can produce varied results. models can also use explore scenario analyses varying inputs. Often, cases need one run model /one set parameter values, inputs outputs stored separate data structures. However, approach can limiting performing scenario analyses, user manually manipulate two objects reshaping joining operations. potential lead errors loss information. Hence, simulate_chains() simulate_chain_stats() return objects dedicated classes respectively store input parameters output simulation single object. class extends , using columns store information simulated transmission chains parameter values attributes. chosen tabular structure allows us store information rows columns, widely used data structure R. Similarly, class superclass (extension) R’s class stores parameter values attributes. object contains information whole outbreak, key summaries easily deduced quick glance object. Hence, class dedicated format()/print() method print simulated transmission chains manner similar , accompanied extra summary information including number chains simulated, number generations reached, number infectors created. summaries useful quickly assessing output simulation. Importantly, class summary() method returns object. design decision taken allow easy coercion object obtained simulate_chains() summaries object otherwise attainable separate run simulate_chain_stats() parameter values passed simulate_chains(). Lastly, objects aggregate() method aggregates simulated outbreak cases “generation” “time”. syntactic sugar dplyr::group_by() dplyr::summarise() style aggregation added benefit taking dplyr dependency achieve goal. summary, object following structure: chain () infector () infectee () generation (), optionally, time (), generation_time specified n_chains, statistic, stat_threshold, offspring_dist, track_pop (pop finite, .e., specified).","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/design-principles.html","id":"likelihood-estimation","dir":"Articles","previous_headings":"Design decisions","what":"likelihood estimation","title":"Design Principles for {epichains}","text":"Likelihoods estimated using likelihood() function. function designed flexible two inputs: data can supplied vector chain summaries, object, object, offspring distribution can supplied function, allowing user use custom offspring distributions. likelihood() uses either analytical numerical methods estimate likelihood observing input chain summaries. analytical methods closed-form likelihoods take form .__ll(), example, .gborel_size_ll() .pois_length_ll() shipped package. user supplies offspring distribution statistic solution exists, internally, used. , simulations used estimate likelihood. numerical likelihood simulation achieved using .offspring_ll(), internal wrapper around simulate_chain_stats(). output type likelihood() depends combination arguments individual, obs_prob, nsim_obs summarised table :","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/design-principles.html","id":"naming-and-documentation-style","dir":"Articles","previous_headings":"","what":"Naming and documentation style","title":"Design Principles for {epichains}","text":"package uses following naming conventions: Functions arguments named using snake_case, example, simulate_chains(). Internal functions prefixed period, example, .offspring_ll(). visual cue technical implications. documentation: Classes objects enclosed angle brackets, example, . Packages enclosed curly braces, example, epichains. function arguments defined sentence case punctuated (especially full stops). Function titles imperative form. Functions referred function_name()","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/design-principles.html","id":"dependencies","dir":"Articles","previous_headings":"","what":"Dependencies","title":"Design Principles for {epichains}","text":"checkmate: exports many test_*(), check_*() assert_*() functions available CRAN.","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/design-principles.html","id":"development-journey","dir":"Articles","previous_headings":"","what":"Development journey","title":"Design Principles for {epichains}","text":"{epichains} successor bpmodels package, retired release {epichains} v0.1.0. {epichains} born need refactor {bpmodels}, led name change subsequent changes design required significant disruptive changes {bpmodels}. {epichains} major refactoring {bpmodels} provide simulation function accounts susceptible depletion population immunity without restrictions offspring distributions, better function long form documentation, object-oriented approach simulating handling transmission chains R. Future plans include simulation contacts infectors, incorporation network effects, object-oriented approach estimating chain size length likelihoods, interoperability {epiparameter} package ease setting various epidemiological delays.","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"use-case","dir":"Articles","previous_headings":"Transmission chains likelihoods","what":"Use case","title":"Getting started with epichains","text":"Suppose observed number transmission chains, arising separate index case. likely transmission properties (reproduction number /superspreading coefficient) generated chains (assuming parameters across chains)? first step answering question calculate likelihood observing observed chain summaries given transmission properties. likelihood() function comes . returned estimate can used infer transmission properties using estimation frameworks maximum likelihood Bayesian inference. epichains provide estimation frameworks.","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"what-we-have","dir":"Articles","previous_headings":"Transmission chains likelihoods","what":"What we have","title":"Getting started with epichains","text":"Data observed transmission chains summaries (sizes lengths).","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"what-we-assume","dir":"Articles","previous_headings":"Transmission chains likelihoods","what":"What we assume","title":"Getting started with epichains","text":"offspring distribution governs number secondary cases produced case. Parameters offspring distribution (example, mean overdispersion using negative binomial; can interpreted reproduction number superspreading coefficient, respectively) (optional) observation process/probability generates observed chain summaries. (optional) threshold chain summaries considered large consistent reproduction number R<1R<1 (e.g., NN cases TT generations total).","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"likelihood","dir":"Articles","previous_headings":"Transmission chains likelihoods","what":"likelihood()","title":"Getting started with epichains","text":"function calculates likelihood/loglikelihood observing vector outbreak summaries obtained transmission chains. “Outbreak summaries” refer transmission chain sizes lengths/durations. likelihood() requires vector chain summaries (sizes lengths), chains, corresponding statistic use, statistic, offspring distribution, offspring_dist associated parameters. offspring_dist specified R function used generate random numbers, .e. rpois Poisson, rnbinom negative binomial, custom function. default, result log-likelihood log = FALSE, likelihoods returned (See ?likelihood details). understand likelihood() works see section likelihood() works. Let’s look following example estimate log-likelihood observing chain_sizes.","code":"set.seed(121) # example of observed chain sizes # randomly generate 20 chains of size between 1 to 10 chain_sizes <- sample(1:10, 20, replace = TRUE) chain_sizes #> [1] 4 7 4 9 1 3 7 5 1 8 10 2 1 2 4 5 10 6 8 7 # estimate loglikelihood of the observed chain sizes for given lambda likelihood_eg <- likelihood( chains = chain_sizes, statistic = \"size\", offspring_dist = rpois, nsim_obs = 100, lambda = 0.5 ) # Print the estimate likelihood_eg #> [1] -67.82879"},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"joint-and-individual-log-likelihoods","dir":"Articles","previous_headings":"Transmission chains likelihoods","what":"Joint and individual log-likelihoods","title":"Getting started with epichains","text":"likelihood(), default, returns joint log-likelihood, given sum log-likelihoods observed chain. instead individual log-likelihoods desired (example calculating Watanabe–Akaike information criterion values, individual argument must set TRUE. return likelihoods instead, set log = FALSE.","code":"set.seed(121) # example of observed chain sizes # randomly generate 20 chains of size between 1 to 10 chain_sizes <- sample(1:10, 20, replace = TRUE) chain_sizes #> [1] 4 7 4 9 1 3 7 5 1 8 10 2 1 2 4 5 10 6 8 7 # estimate loglikelihood of the observed chain sizes likelihood_ind_eg <- likelihood( chains = chain_sizes, statistic = \"size\", offspring_dist = rpois, nsim_obs = 100, lambda = 0.5, individual = TRUE ) # Print the estimate likelihood_ind_eg #> [[1]] #> [1] -3.098612 -4.508584 -3.098612 -5.269208 -0.500000 -2.480829 -4.508584 #> [8] -3.622329 -0.500000 -4.900542 -5.619471 -1.693147 -0.500000 -1.693147 #> [15] -3.098612 -3.622329 -5.619471 -4.086190 -4.900542 -4.508584"},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"observation-probability","dir":"Articles","previous_headings":"Transmission chains likelihoods","what":"Observation probability","title":"Getting started with epichains","text":"likelihood() uses argument obs_prob model observation probability. default, assumes perfect observation, obs_prob = 1 (See ?likelihood), meaning transmission events observed recorded data. observations imperfect, obs_prob must less 1. case imperfect observation, “true” chain sizes lengths simulated nsim_obs times, likelihood calculated simulations. example, probability observing case obs_prob = 0.30, use returns 10 likelihood values (nsim_obs = 10), can averaged come overall likelihood estimate.","code":"set.seed(121) # example of observed chain sizes; randomly generate 20 chains of size 1 to 10 chain_sizes <- sample(1:10, 20, replace = TRUE) # get their likelihood liks <- likelihood( chains = chain_sizes, statistic = \"size\", offspring_dist = rpois, obs_prob = 0.3, lambda = 0.5, nsim_obs = 10 ) liks #> [1] -183.8670 -162.1382 -166.6720 -170.1077 -152.9557 -157.9814 -166.0587 #> [8] -174.8488 -156.4197 -160.0229"},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"how-likelihood-works","dir":"Articles","previous_headings":"Transmission chains likelihoods","what":"How likelihood() works","title":"Getting started with epichains","text":"likelihood() first checks analytical solution likelihood exists given offspring distribution chain statistic specified. ’s none, simulations used estimate likelihoods. epichains package includes closed-form (analytical) solutions calculating likelihoods associated certain summaries transmission chains (“size” “length”) specific offspring distributions. size distributions, package provides Poisson, negative binomial, gamma-borel mixture. provide gamma-Borel size likelihood, Borel distribution needed. However, base R provide distribution natively like poisson gamma, epichains provides density random generator. length distribution, ’s Poisson geometric distributions. can used likelihood() based specified offspring_dist statistic. analytical solution exist, internal simulation function, .offspring_ll() employed. uses simulations approximate probability distributions (using linear approximation cumulative distribution unobserved sizes/lengths). simulation used, extra argument nsim_offspring must passed likelihood() specify number simulations used approximation. Approximate values likelihood vary every call simulation (simulations used estimation vary), may worth calling likelihood() multiple times case see error may introduce. example, let’s look example chain_sizes observed want calculate likelihood drawn binomial distribution probability prob = 0.9.","code":"set.seed(121) # example of observed chain sizes; randomly generate 20 chains of size 1 to 10 chain_sizes <- sample(1:10, 20, replace = TRUE) # get their likelihood liks <- likelihood( chains = chain_sizes, offspring_dist = rbinom, statistic = \"size\", size = 1, prob = 0.9, nsim_offspring = 250 ) liks #> [1] -56.76805"},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"transmission-chain-simulation","dir":"Articles","previous_headings":"","what":"Transmission chain simulation","title":"Getting started with epichains","text":"two simulation functions, herein referred collectively simulate_*() functions can help us achieve .","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"use-case-1","dir":"Articles","previous_headings":"Transmission chain simulation","what":"Use case","title":"Getting started with epichains","text":"want simulate scenario number chains produced separate index case. want simulate chains transmission result cases, given specific offspring distribution reproduction number.","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"what-we-have-1","dir":"Articles","previous_headings":"Transmission chain simulation","what":"What we have","title":"Getting started with epichains","text":"initial number cases seed outbreak.","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"what-we-assume-1","dir":"Articles","previous_headings":"Transmission chain simulation","what":"What we assume","title":"Getting started with epichains","text":"offspring distribution governs number secondary cases produced case. Parameters offspring distribution (example, mean overdispersion using negative binomial; can interpreted reproduction number superspreading coefficient, respectively) (optional) threshold chain summaries considered large consistent reproduction number R<1R<1 (e.g., NN cases TT generations total). (optional) generation time distribution governs time successive cases.","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"simulate_chains","dir":"Articles","previous_headings":"Transmission chain simulation","what":"simulate_chains()","title":"Getting started with epichains","text":"simulate_chains() simulates outbreak given number infections offspring distribution. default, assumes population infinite pre-existing immunity. function tracks returns information infectors (ancestors), infectees, generation infection, time, generation time function specified. Let’s look example simulate transmission tree 1010 index cases. assume poisson offspring distribution mean, lambda=0.9\\text{lambda} = 0.9, generation time 33 days: default, simulate_chains() assumes infinite population can account susceptible depletion finite pop specified. Pre-existing immunity levels can also specified, applied pop simulation initialised. quick example simulate outbreak population size 10001000 1010 index cases 10/10/% pre-existing immunity. assume individuals poisson offspring distribution mean, lambda=1\\text{lambda} = 1, fixed generation time 33:","code":"set.seed(32) # Define generation time generation_time_fn <- function(n) { gt <- rep(3, n) return(gt) } sim_chains <- simulate_chains( n_chains = 10, statistic = \"size\", offspring_dist = rpois, stat_threshold = 10, generation_time = generation_time_fn, lambda = 0.9 ) head(sim_chains) #> chain infector infectee generation time #> 11 1 1 2 2 3 #> 12 2 1 2 2 3 #> 13 3 1 2 2 3 #> 14 3 1 3 2 3 #> 15 4 1 2 2 3 #> 16 6 1 2 2 3 set.seed(32) # Define generation time generation_time_fn <- function(n) { gt <- rep(3, n) return(gt) } sim_chains_with_pop <- simulate_chains( pop = 1000, n_chains = 10, percent_immune = 0.1, offspring_dist = rpois, statistic = \"size\", lambda = 1, generation_time = generation_time_fn ) head(sim_chains_with_pop) #> chain infector infectee generation time #> 11 1 1 2 2 3 #> 12 2 1 2 2 3 #> 13 3 1 2 2 3 #> 14 3 1 3 2 3 #> 15 4 1 2 2 3 #> 16 6 1 2 2 3"},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"simulate_chain_stats","dir":"Articles","previous_headings":"Transmission chain simulation","what":"simulate_chain_stats()","title":"Getting started with epichains","text":"simulate_chain_stats() performant version simulate_chains() track information infector infectee. returns eventual size length/duration transmission chain. function especially useful calculating numerical likelihoods likelihood(). example simulate previous examples without intervention, returning size 1010 chains. assumes Poisson offspring distribution distribution mean 0.90.9.","code":"set.seed(123) simulate_chain_stats_eg <- simulate_chain_stats( n_chains = 10, statistic = \"size\", offspring_dist = rpois, stat_threshold = 10, lambda = 0.9 ) # Print the results simulate_chain_stats_eg #> `epichains_summary` object #> #> [1] 1 Inf 4 4 Inf 1 2 Inf 5 3 #> #> Simulated sizes: #> #> Max: >=10 #> Min: 1"},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"s3-methods","dir":"Articles","previous_headings":"","what":"S3 Methods","title":"Getting started with epichains","text":"Let’s subset one chains biggest size sim_chains object created . Now, can plot chain using epicontacts package. Aggregated objects can also plotted using base R ggplot2 little data manipulation. end--end example simulation aggregation plotting.","code":"# Get the biggest chain longest_chain <- sim_chains[sim_chains$chain == which.max( unname(table(sim_chains$chain)) ), ] # Convert to data.frame to view the whole data as.data.frame(longest_chain) #> chain infector infectee generation time #> 6 6 NA 1 1 0 #> 16 6 1 2 2 3 #> 17 6 1 3 2 3 #> 18 6 1 4 2 3 #> 27 6 2 5 3 6 #> 28 6 3 6 3 6 #> 29 6 3 7 3 6 #> 30 6 4 8 3 6 #> 42 6 5 9 4 9 #> 43 6 6 10 4 9 #> 44 6 7 11 4 9 #> 45 6 8 12 4 9 # Create an `` object epc <- make_epicontacts( linelist = longest_chain, contacts = longest_chain, id = \"infectee\", from = \"infector\", to = \"infectee\", directed = TRUE ) # Plot the chain plot(epc) # Run simulation with simulate_chains() set.seed(32) # Define generation time generation_time_fn <- function(n) { gt <- rep(3, n) return(gt) } sim_chains <- simulate_chains( n_chains = 10, statistic = \"size\", offspring_dist = rpois, stat_threshold = 1000, generation_time = generation_time_fn, lambda = 2 ) # Aggregate cases over time sim_chains_aggreg <- aggregate(sim_chains, by = \"time\") # Plot cases over time plot( sim_chains_aggreg, type = \"b\", col = \"red\", lwd = 2, xlab = \"Time\", ylab = \"Cases\" )"},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"summarising","dir":"Articles","previous_headings":"S3 Methods","what":"Summarising","title":"Getting started with epichains","text":"can run summary() object returned simulate_chains() obtain chain summaries per index case. summary output simulate_chain_stats() inputs used. simulate_chain_stats() performant version simulate_chains(), hence, can use instead, interested summary simulated chains without details infection tree. ::: can confirm two outputs using base::setequal(), checks two objects equal returns TRUE/FALSE.","code":"set.seed(32) # Define generation time generation_time_fn <- function(n) { gt <- rep(3, n) return(gt) } sim_chains <- simulate_chains( n_chains = 10, statistic = \"size\", offspring_dist = rpois, stat_threshold = 10, generation_time = generation_time_fn, lambda = 0.9 ) summary(sim_chains) #> `epichains_summary` object #> #> [1] Inf 2 Inf 2 1 Inf 3 Inf 9 1 #> #> Simulated sizes: #> #> Max: >=10 #> Min: 1 # Example with simulate_chain_stats() set.seed(32) simulate_chain_stats_eg <- simulate_chain_stats( n_chains = 10, statistic = \"size\", offspring_dist = rpois, stat_threshold = 10, lambda = 0.9 ) # Get summaries summary(simulate_chain_stats_eg) #> $n_chains #> [1] 10 #> #> $max_stat #> [1] Inf #> #> $min_stat #> [1] 1 setequal( # summary of output from simulate_chains() summary(sim_chains), # results from simulate_chain_stats() simulate_chain_stats_eg ) #> [1] TRUE"},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"aggregating","dir":"Articles","previous_headings":"S3 Methods","what":"Aggregating","title":"Getting started with epichains","text":"can aggregate objects returned simulate_chains() columns “cases” either “generation” “time”, depending value . aggregate “time”, must specified generation time distribution (generation_time) simulation step.","code":"# Example with simulate_chains() set.seed(32) # Define generation time generation_time_fn <- function(n) { gt <- rep(3, n) return(gt) } sim_chains <- simulate_chains( n_chains = 10, statistic = \"size\", offspring_dist = rpois, stat_threshold = 10, generation_time = generation_time_fn, lambda = 0.9 ) aggregate(sim_chains, by = \"time\") #> time cases #> 1 0 10 #> 2 3 12 #> 3 6 14 #> 4 9 17 #> 5 12 3 #> 6 15 4 #> 7 18 3"},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"plotting","dir":"Articles","previous_headings":"S3 Methods","what":"Plotting","title":"Getting started with epichains","text":"can plot individual chains object using {epicontacts} package. , first need create object using epicontacts::make_epicontacts() function, requires linelist contacts data.frame (See ?epicontacts::make_epicontacts()).","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/epichains.html","id":"some-notes-about-interoperability-between-epicontacts-and-epichains-objects","dir":"Articles","previous_headings":"S3 Methods","what":"Some notes about interoperability between and objects","title":"Getting started with epichains","text":"epicontacts::make_epicontacts() function work: linelist contacts data.frames must column named “id” uniquely identifies case. linelist contacts objects can . object contains multiple independent chains unique infectee ids, work box make_epicontacts() unless use subset chain. now, select visualise individual chains object. future versions package, make interaction seamless providing user-friendly functionality convert object way allows us plot chains .","code":""},{"path":[]},{"path":"https://epiverse-trace.github.io/epichains/articles/interventions.html","id":"reducing-the-strength-of-transmission","dir":"Articles","previous_headings":"","what":"Reducing the strength of transmission","title":"Modelling disease control interventions","text":"Following (Lloyd-Smith et al. 2005) consider two ways disease control interventions can reduce reproduction number: population-wide individual-specific control.","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/interventions.html","id":"population-wide-control","dir":"Articles","previous_headings":"Reducing the strength of transmission","what":"Population-wide control","title":"Modelling disease control interventions","text":"population-level control mean intervention reduces mean number offspring (.e. reproduction number) fixed proportion. example, reduce R 25% population level scale mu parameter 1.2 0.9:","code":"sims <- simulate_chain_stats( n_chains = 200, offspring_dist = rnbinom, stat_threshold = 99, mu = 0.9, size = 0.5, statistic = \"size\" ) sims[is.infinite(sims)] <- 100 # Replace infections > 99 with 100 for plotting. ggplot(data.frame(x = sims), aes(x = x)) + geom_histogram(breaks = seq(0, 100, by = 5), closed = \"left\") + scale_x_continuous( breaks = c(0, 25, 50, 75, 100), labels = c(0, 25, 50, 75, \">99\") ) + theme_bw()"},{"path":"https://epiverse-trace.github.io/epichains/articles/interventions.html","id":"individual-level-control-","dir":"Articles","previous_headings":"Reducing the strength of transmission","what":"Individual-level control.","title":"Modelling disease control interventions","text":"simulating population-level control now apply reduction (25%) instead assuming mean reduced apply 25% individuals transmit , whereas remaining 75% generate offspring uncontrolled case. , can longer use standard negative binomial distribution comes R. Instead, define random generator modified negative binomial distribution includes individual-level control control argument indicating level individual-level control (0: control; 1: full control): defined , can generate simulations :","code":"rnbinom_ind <- function(n, ..., control = 0) { ## initialise number of offspring to 0 offspring <- rep(0L, n) ## for each individual, decide whether they transmit further transmits <- rbinom(n = n, prob = 1 - control, size = 1) ## check if anyone transmits further if (any(transmits == 1L)) { ## for those that transmit, sample from negative binomial with given ## parameters offspring[which(transmits == 1L)] <- rnbinom(n = n, ...) } return(offspring) } sims <- simulate_chain_stats( n_chains = 200, offspring_dist = rnbinom_ind, stat_threshold = 99, mu = 1.2, size = 0.5, control = 0.25, statistic = \"size\" ) sims[is.infinite(sims)] <- 100 # Replace infections > 99 with 100 for plotting. ggplot(data.frame(x = sims), aes(x = x)) + geom_histogram(breaks = seq(0, 100, by = 5), closed = \"left\") + scale_x_continuous( breaks = c(0, 25, 50, 75, 100), labels = c(0, 25, 50, 75, \">99\") ) + theme_bw()"},{"path":"https://epiverse-trace.github.io/epichains/articles/interventions.html","id":"preventing-superspreading-events","dir":"Articles","previous_headings":"","what":"Preventing superspreading events","title":"Modelling disease control interventions","text":"Another way controlling disease prevent individuals spreading large number others, example preventing mass gatherings , generally, settings superspreading events can occur. can model truncating offspring distribution certain size. can done, example, using truncdist R package. use define truncated negative binomial offspring distribution: use simulate chains situation maximum secondary cases infected person can generate 10. can likened disease control strategy gatherings limited 10 people.","code":"rnbinom_truncated <- function(n, ..., max = Inf) { return(rtrunc(n = n, spec = \"nbinom\", b = max, ...)) } sims <- simulate_chain_stats( n_chains = 200, offspring_dist = rnbinom_truncated, stat_threshold = 99, mu = 1.2, size = 0.5, max = 10, statistic = \"size\" ) sims[is.infinite(sims)] <- 100 # Replace infections > 99 with 100 for plotting. ggplot(data.frame(x = sims), aes(x = x)) + geom_histogram(breaks = seq(0, 100, by = 5), closed = \"left\") + scale_x_continuous( breaks = c(0, 25, 50, 75, 100), labels = c(0, 25, 50, 75, \">99\") ) + theme_bw()"},{"path":"https://epiverse-trace.github.io/epichains/articles/interventions.html","id":"truncating-the-generation-interval","dir":"Articles","previous_headings":"","what":"Truncating the generation interval","title":"Modelling disease control interventions","text":"Lastly, consider situation generation interval shortened. model explicitly instead consider effect offspring distribution. example, generation interval gamma distribution shape = 25 rate = 5 (corresponding mean 5 standard deviation 1), stop transmission normally occur 6 days infection, can calculate proportion transmissions prevented words, prevent 16% infections example. value control can used examples study effect outbreak sizes.","code":"control <- 1 - pgamma(6, shape = 25, rate = 5) signif(control, 2) #> [1] 0.16"},{"path":[]},{"path":"https://epiverse-trace.github.io/epichains/articles/projecting_incidence.html","id":"overview","dir":"Articles","previous_headings":"","what":"Overview","title":"Projecting infectious disease incidence: a COVID-19 example","text":"Branching processes can used project stochastic infectious disease trends time provided can characterize distribution times successive cases (serial interval), distribution secondary cases produced single individual (offspring distribution). simulations can achieved epichains simulate_chains() function Pearson et al. (2020), Abbott et al. (2020) illustrate application COVID-19. purpose vignette use early data COVID-19 South Africa (Marivate Combrink 2020) illustrate epichains can used project outbreak. Let’s load required packages","code":"library(\"epichains\") library(\"dplyr\") library(\"ggplot2\") library(\"lubridate\")"},{"path":"https://epiverse-trace.github.io/epichains/articles/projecting_incidence.html","id":"data","dir":"Articles","previous_headings":"","what":"Data","title":"Projecting infectious disease incidence: a COVID-19 example","text":"Included epichains cleaned time series first 15 days COVID-19 outbreak South Africa. can loaded memory follows: use first 55 observations demonstration. assume cases subset imported infect . Let us subset view aspect data.","code":"data(\"covid19_sa\", package = \"epichains\") seed_cases <- covid19_sa[1:5, ] head(seed_cases) #> # A tibble: 5 × 2 #> date cases #> #> 1 2020-03-05 1 #> 2 2020-03-07 1 #> 3 2020-03-08 1 #> 4 2020-03-09 4 #> 5 2020-03-11 6"},{"path":"https://epiverse-trace.github.io/epichains/articles/projecting_incidence.html","id":"setting-up-the-inputs","dir":"Articles","previous_headings":"","what":"Setting up the inputs","title":"Projecting infectious disease incidence: a COVID-19 example","text":"now proceed set simulate_chains() simulations.","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/projecting_incidence.html","id":"onset-times","dir":"Articles","previous_headings":"Setting up the inputs","what":"Onset times","title":"Projecting infectious disease incidence: a COVID-19 example","text":"simulate_chains() requires vector seeding times, t0, chain/individual/simulation. get , use observation date index case reference find difference observed dates reference. Using vector start times time series, create corresponding seeding time individual, ’ll call t0.","code":"days_since_index <- as.integer(seed_cases$date - min(seed_cases$date)) days_since_index #> [1] 0 2 3 4 6 t0 <- rep(days_since_index, seed_cases$cases) t0 #> [1] 0 2 3 4 4 4 4 6 6 6 6 6 6"},{"path":"https://epiverse-trace.github.io/epichains/articles/projecting_incidence.html","id":"generation-time","dir":"Articles","previous_headings":"Setting up the inputs","what":"Generation time","title":"Projecting infectious disease incidence: a COVID-19 example","text":"epidemiology, generation time (also called generation interval) duration successive infectious events chain transmission. Similarly, serial interval duration observed symptom onset times successive cases transmission chain. generation interval often hard observe exact times infection hard measure hence, serial interval often used instead. , use serial interval interpret simulated case data represent symptom onset. example, assume based COVID-19 literature serial interval, S, log-normal distributed parameters, μ=4.7\\mu = 4.7 σ=2.9\\sigma = 2.9(Pearson et al. 2020). log-normal distribution commonly used epidemiology characterise quantities serial interval large variance can positive-valued (Nishiura 2007; Limpert, Stahel, Abbt 2001). Note distribution described way, means μ\\mu σ\\sigma expected value standard deviation natural logarithm serial interval. Hence, order sample “back-transformed” measured serial interval expectation/mean, E[S]E[S] standard deviation, SD[S]SD [S], can use following parametrisation: E[S]=ln(μ2(μ2+σ2)SD[S]=ln(1+σ2μ2)\\begin{align} E[S] &= \\ln \\left( \\dfrac{\\mu^2}{(\\sqrt{\\mu^2 + \\sigma^2}} \\right) \\\\ SD [S] &= \\sqrt {\\ln \\left(1 + \\dfrac{\\sigma^2}{\\mu^2} \\right)} \\end{align} See “log-normal_distribution” Wikipedia detailed explanation parametrisation. now set generation time function appropriate inputs. adopt R’s random lognormal distribution generator (rlnorm()) takes meanlog sdlog arguments, define parametrisation log_mean() log_sd() respectively wrap generation_time_fn() function. Moreover, generation_time_fn() takes one argument n required epichains (See ?epichains::simulate_chains), passed rlnorm() first argument determine number observations sample (See ?rlnorm).","code":"mu <- 4.7 sgma <- 2.9 log_mean <- log((mu^2) / (sqrt(sgma^2 + mu^2))) # log mean log_sd <- sqrt(log(1 + (sgma / mu)^2)) # log sd #' serial interval function generation_time <- function(n) { gt <- rlnorm(n, meanlog = log_mean, sdlog = log_sd) return(gt) }"},{"path":"https://epiverse-trace.github.io/epichains/articles/projecting_incidence.html","id":"offspring-distribution","dir":"Articles","previous_headings":"Setting up the inputs","what":"Offspring distribution","title":"Projecting infectious disease incidence: a COVID-19 example","text":"Let us now set offspring distribution, distribution drives mechanism behind individual cases infect cases. appropriate way model offspring distribution capture population-level transmissibility (R0R0) individual-level heterogeneity transmission (“superspreading”). negative binomial distribution commonly used case (Lloyd-Smith et al. 2005). example, assume offspring distribution characterised negative binomial mu=2.5mu = 2.5(Abbott et al. 2020) size=0.58size = 0.58(Wang et al. 2020). parameterization, mumu represents R0R_0, defined average number cases produced single individual entirely susceptible population. parameter sizesize represents superspreading, , degree heterogeneity transmission single individuals.","code":"mu <- 2.5 size <- 0.58"},{"path":"https://epiverse-trace.github.io/epichains/articles/projecting_incidence.html","id":"simulation-controls","dir":"Articles","previous_headings":"Setting up the inputs","what":"Simulation controls","title":"Projecting infectious disease incidence: a COVID-19 example","text":"example, simulate outbreaks end 2121 days last date observations seed_cases dataset. simulate_chains() stochastic, meaning results different every time run set parameters. , therefore, run simulations 100100 times aggregate results. Let us specify . Lastly, since, specified R0>1R0 > 1, means epidemic potentially grow without end. Hence, must specify end point simulations. simulate_chains() provides stat_threshold argument purpose. stat_threshold, simulation cut . value specified, assumes value infinity. , assume maximum chain size 10001000.","code":"#' Date to end simulation projection_window <- 21 tf <- max(days_since_index) + projection_window tf #> [1] 27 #' Number of simulations sim_rep <- 100 #' Maximum chain size allowed stat_threshold <- 1000"},{"path":"https://epiverse-trace.github.io/epichains/articles/projecting_incidence.html","id":"modelling-assumptions","dir":"Articles","previous_headings":"","what":"Modelling assumptions","title":"Projecting infectious disease incidence: a COVID-19 example","text":"exercise makes following simplifying assumptions: cases observed. Cases observed exactly time infection. reporting delay. Reporting rate constant course epidemic. interventions implemented. Population homogeneous well-mixed. summarise whole set far, going simulate chain 100 times, projecting cases 21 days first 6 days, assuming outbreak size exceeds 1000 cases.","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/projecting_incidence.html","id":"running-the-simulations","dir":"Articles","previous_headings":"","what":"Running the simulations","title":"Projecting infectious disease incidence: a COVID-19 example","text":"use function lapply() run simulations bind rows dplyr::bind_rows(). Let us view first rows simulation results.","code":"set.seed(1234) sim_chain_sizes <- lapply( seq_len(sim_rep), function(sim) { simulate_chains( n_chains = length(t0), offspring_dist = rnbinom, mu = mu, size = size, statistic = \"size\", stat_threshold = stat_threshold, generation_time = generation_time, t0 = t0, tf = tf ) %>% mutate(sim = sim) } ) sim_output <- bind_rows(sim_chain_sizes) head(sim_output) #> chain infector infectee generation time sim #> 14 3 1 2 2 8.123133 1 #> 15 3 1 3 2 6.842933 1 #> 16 3 1 4 2 7.260639 1 #> 17 3 1 5 2 11.244838 1 #> 18 7 1 2 2 7.022334 1 #> 19 7 1 3 2 12.182368 1"},{"path":"https://epiverse-trace.github.io/epichains/articles/projecting_incidence.html","id":"post-processing","dir":"Articles","previous_headings":"","what":"Post-processing","title":"Projecting infectious disease incidence: a COVID-19 example","text":"Now, summarise simulation results. want plot individual simulated daily time series show median cases per day aggregated simulations. First, create daily time series per simulation aggregating number cases per day simulation. Next, add date column results simulation set. use date first case observed data reference start date. Now aggregate simulations day evaluate median daily cases across simulations.","code":"# Daily number of cases for each simulation incidence_ts <- sim_output %>% mutate(day = ceiling(time)) %>% count(sim, day, name = \"cases\") %>% as_tibble() head(incidence_ts) #> # A tibble: 6 × 3 #> sim day cases #> #> 1 1 0 1 #> 2 1 2 1 #> 3 1 3 1 #> 4 1 4 4 #> 5 1 6 6 #> 6 1 7 1 # Get start date from the observed data index_date <- min(seed_cases$date) index_date #> [1] \"2020-03-05\" # Add a dates column to each simulation result incidence_ts_by_date <- incidence_ts %>% group_by(sim) %>% mutate(date = index_date + days(seq(0, n() - 1))) %>% ungroup() head(incidence_ts_by_date) #> # A tibble: 6 × 4 #> sim day cases date #> #> 1 1 0 1 2020-03-05 #> 2 1 2 1 2020-03-06 #> 3 1 3 1 2020-03-07 #> 4 1 4 4 2020-03-08 #> 5 1 6 6 2020-03-09 #> 6 1 7 1 2020-03-10 # Median daily number of cases aggregated across all simulations median_daily_cases <- incidence_ts_by_date %>% group_by(date) %>% summarise(median_cases = median(cases)) %>% ungroup() %>% arrange(date) head(median_daily_cases) #> # A tibble: 6 × 2 #> date median_cases #> #> 1 2020-03-05 1 #> 2 2020-03-06 1 #> 3 2020-03-07 1 #> 4 2020-03-08 4 #> 5 2020-03-09 5 #> 6 2020-03-10 8"},{"path":"https://epiverse-trace.github.io/epichains/articles/projecting_incidence.html","id":"visualization","dir":"Articles","previous_headings":"","what":"Visualization","title":"Projecting infectious disease incidence: a COVID-19 example","text":"now plot individual simulation results alongside median aggregated results. COVID-19 incidence South Africa projected two week window 2020. light gray lines represent individual simulations, red line represents median daily cases across simulations, black connected dots represent observed data, dashed vertical line marks beginning projection.","code":"# since all simulations may end at a different date, we will find the minimum # final date for all simulations for the purposes of visualisation. final_date <- incidence_ts_by_date %>% group_by(sim) %>% summarise(final_date = max(date), .groups = \"drop\") %>% summarise(min_final_date = min(final_date)) %>% pull(min_final_date) incidence_ts_by_date <- incidence_ts_by_date %>% filter(date <= final_date) median_daily_cases <- median_daily_cases %>% filter(date <= final_date) ggplot(data = incidence_ts_by_date) + geom_line( aes( x = date, y = cases, group = sim ), color = \"grey\", linewidth = 0.2, alpha = 0.25 ) + geom_line( data = median_daily_cases, aes( x = date, y = median_cases ), color = \"tomato3\", linewidth = 1.8 ) + geom_point( data = covid19_sa, aes( x = date, y = cases ), color = \"black\", size = 1.75, shape = 21 ) + geom_line( data = covid19_sa, aes( x = date, y = cases ), color = \"black\", linewidth = 1 ) + scale_x_continuous( breaks = seq( min(incidence_ts_by_date$date), max(incidence_ts_by_date$date), 5 ), labels = seq( min(incidence_ts_by_date$date), max(incidence_ts_by_date$date), 5 ) ) + scale_y_continuous( breaks = seq( 0, max(incidence_ts_by_date$cases), 30 ), labels = seq( 0, max(incidence_ts_by_date$cases), 30 ) ) + geom_vline( mapping = aes(xintercept = max(seed_cases$date)), linetype = \"dashed\" ) + labs(x = \"Date\", y = \"Daily cases\")"},{"path":[]},{"path":"https://epiverse-trace.github.io/epichains/articles/theoretical_background.html","id":"branching-processes","dir":"Articles","previous_headings":"","what":"Branching processes","title":"Theoretical background for epichains","text":"Branching processes class models used model growth populations. assume member population produces number offspring, ZZ, random variable probability mass function p(Z=z|θ)p(Z = z | \\theta), called offspring distribution. use long history epidemiology, population interpreted pathogen, offspring new hosts infects (Farrington, Kanaan, Gay 2003). call infected individuals cases methods applied contexts branching processes used.","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/theoretical_background.html","id":"simulation","dir":"Articles","previous_headings":"","what":"Simulation","title":"Theoretical background for epichains","text":"simulate branching process, start single case proceed discrete steps generations, drawing offspring distribution p(Z=z|θ)p(Z=z | \\theta) generate new cases case. Given infector ii infectee jj, can additionally assign distribution times TT approximates infection event occurred. define TT random variable distribution f(T=t;θ)f(T = t; \\theta) can assign case jj time tjt_{j} , case jj affected case ii given f(tj−ti|θ)f(t_{j} - t_{} | \\theta). identify timing cases time symptom onset serial interval, depending case definitions another interval.","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/theoretical_background.html","id":"summary-statistics","dir":"Articles","previous_headings":"Simulation","what":"Summary statistics","title":"Theoretical background for epichains","text":"Branching process simulations end gone extinct, , offspring produced, stopping criterion. summarise simulations, either study size length resulting chain cases. size SS chain number cases occurred course simulation including initial case S≥1S \\geq 1. length LL chain number generations simulated including initial case L≥1L \\geq 1.","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/theoretical_background.html","id":"inference","dir":"Articles","previous_headings":"","what":"Inference","title":"Theoretical background for epichains","text":"characterising chains cases size length can conduct inference learn underlying parameters θ\\theta observation chain sizes chain lengths (Blumberg Lloyd-Smith 2013). general possible subcritical branching processes, .e. ones mean number offspring less 1, otherwise branching process grow forever. However, can expand theory supercritical branching processes, .e. ones mean number offspring greater 1, defining cut chain size length beyond treat chain infinite size length, respectively.","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/theoretical_background.html","id":"size-and-length-distributions-for-some-offspring-distributions","dir":"Articles","previous_headings":"Inference","what":"Size and length distributions for some offspring distributions","title":"Theoretical background for epichains","text":"show equations size length distributions offspring distributions can derived analytically: Poisson, negative binomial, geometric, gamma-Borel mixture.","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/theoretical_background.html","id":"negative-binomial-and-special-cases","dir":"Articles","previous_headings":"Inference > Size and length distributions for some offspring distributions","what":"Negative binomial and special cases","title":"Theoretical background for epichains","text":"offspring distribution Poisson distribution, can interpret rate parameter λ\\lambda basic reproduction number R0R_{0} pathogen. general case offspring definition can overdispersed leading superspreading can use negative binomial offspring distribution mean μ\\mu overdispersion kkBlumberg Lloyd-Smith (2013). case, mean parameter μ\\mu interpreted basic reproduction number R0R_0 pathogen. negative binomial distribution arises Poisson-gamma mixture thus branching process negative binomial distributed offspring can interpreted one Poisson distributed offspring basic reproduction number R0R_0 varies according gamma distribution. amount variation R0R_0 interpreted individual-level variation transmission representing overdispersion superspreading, degree happens given overdispersion parameter kk.","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/theoretical_background.html","id":"size-distributions","dir":"Articles","previous_headings":"Inference > Size and length distributions for some offspring distributions > Negative binomial and special cases","what":"Size distributions","title":"Theoretical background for epichains","text":"probability pp chain size SS given R0R_0 kk branching process negative binomial offspring distribution given Eq. 9 Blumberg Lloyd-Smith (2013) p(S|R0,k)=Γ(kS+S−1)Γ(kS)Γ(S+1)(R0k)S−1(1+R0k)kS+S−1 p(S|R_0, k) = \\frac{\\Gamma(kS + S - 1)}{\\Gamma(kS)\\Gamma(S + 1)} \\frac{\\left(\\frac{R_0}{k}\\right)^{S - 1}}{\\left( 1 + \\frac{R_0}{k} \\right)^{kS + S - 1}} Γ\\Gamma gamma function. order estimate SS given R0R_0 kk can define likelihood function L(S)=p(S|R0,k)L(S) = p(S|R_0, k). corresponding log-likelihood LL(S)=logΓ(kS+S−1)−(logΓ(kS)+logΓ(S−1))+(S−1)logR0k−(SR0+(S−1))log(1+R0k)\\begin{align} \\mathrm{LL}(S) = &\\log\\Gamma(kS + S - 1) - \\left(\\log\\Gamma(kS) + \\log\\Gamma(S - 1) \\right) \\\\ & + (S-1) \\log \\frac{R_0}{k} - (SR_0 + (S - 1)) \\log \\left(1 + \\frac{R_0}{k}\\right) \\end{align} log-likelihood Poisson distributed offspring follows kk tends infinity (corresponding Eq. 2.2 Farrington, Kanaan, Gay (2003)) LL(S)=(S−1)logR0−SR0+(S−2)logS−logΓ(S) \\mathrm{LL}(S) = (S - 1) \\log R_0 - S R_0 + (S - 2) \\log S - \\log\\Gamma(S) cases point estimate basic reproduction number R0̂\\hat{R_0} related mean chain size S‾\\bar{S} R0̂=1−1S‾ \\hat{R_0} = 1 - \\frac{1}{\\bar{S}}","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/theoretical_background.html","id":"length-distributions","dir":"Articles","previous_headings":"Inference > Size and length distributions for some offspring distributions > Negative binomial and special cases","what":"Length distributions","title":"Theoretical background for epichains","text":"cumulative mass function F(L)F(L) observing chain length LL offspring Poisson distributed given Eq. (2.5) Farrington, Kanaan, Gay (2003) (called “outbreak duration”): F(L)=e−R0EL(eR0e−R0) F(L) = e^{-R_0} E_L \\left( e^{R_0 e^{-R_0} } \\right) EL(x)E_L(x) iterated exponential function, E0(x)=1E_0(x) = 1, EL+1(x)=xEL(x)E_{L + 1}(x) = x^{E_L(x)}. geometric distributed offspring (corresponding negative Binomial k=1k=1) function given F(L)=1−R0L+11−R0L−2 F(L) = \\frac{ 1- R_0^{L + 1} } {1 - R_0^{L - 2}} cases f(L)f(L) denotes cumulative mass functions therefore probability observing chain length LL therefore f(L)−f(L−1)f(L) - f(L - 1).","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/theoretical_background.html","id":"gamma-borel-mixture","dir":"Articles","previous_headings":"Inference > Size and length distributions for some offspring distributions","what":"Gamma-Borel mixture","title":"Theoretical background for epichains","text":"probability distribution outbreak sizes branching process Poisson offspring distribution (Eq. 2.2 Farrington, Kanaan, Gay (2003)) special case Borel-Tanner distribution starting 1 individual. alternative negative binomial offspring distribution represents Poisson-gamma mixture Borel-gamma mixture. represent situations variation individual level chain level, .e. transmission chains homogeneous heterogeneity chains. case, can shown resulting log-likelihood chain sizes LL(S)=logΓ(k+S−1)−(logΓ(k)+logΓ(S+1))+(S−1)logS−klog(S+R0k)\\begin{align} \\mathrm{LL}(S) = &\\log\\Gamma(k + S - 1) - \\left(\\log\\Gamma(k) + \\log\\Gamma(S + 1) \\right) \\\\ & + (S-1) \\log S - k \\log \\left(S + \\frac{R_0}{k}\\right) \\end{align}","code":""},{"path":"https://epiverse-trace.github.io/epichains/articles/theoretical_background.html","id":"numerical-approximations-of-chain-size-and-length-distributions","dir":"Articles","previous_headings":"Inference","what":"Numerical approximations of chain size and length distributions","title":"Theoretical background for epichains","text":"analytic likelihoods available numerical approximation used derive distributions. order , simulation functionality used generate nn simulated chains value cumulative mass function P(S|θ)P(S|\\theta) observed SS approximated empirical cumulative distribution function: P(S|θ)≈∑i𝟏(xi<=S) P(S|\\theta) \\approx \\sum_i \\mathbf{1}(x_i <= S) 𝟏\\mathbf{1} indicator function xix_i -th observed chain size (length, interest LL). order improve approximation linear approximation applied values empirical distribution function (expense normalisation 1). (unnormalised) probability observing SS given p(S|θ)=P(S|θ)−P(S−1|θ) p(S|\\theta) = P(S|\\theta) - P(S - 1|\\theta) equivalent relationship used LL.","code":""},{"path":"https://epiverse-trace.github.io/epichains/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"James M. Azam. Author, maintainer, copyright holder. Sebastian Funk. Author, copyright holder. Flavio Finger. Author. Zhian N. Kamvar. Contributor. Hugo Gruson. Contributor, reviewer. Karim Mané. Reviewer. Pratik Gupte. Reviewer. Joshua W. Lambert. Reviewer.","code":""},{"path":"https://epiverse-trace.github.io/epichains/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Azam J, Funk S, Finger F (2024). epichains: Simulating Analysing Transmission Chain Statistics Using Branching Process Models. R package version 0.1.1, https://epiverse-trace.github.io/epichains/, https://github.com/epiverse-trace/epichains.","code":"@Manual{, title = {epichains: Simulating and Analysing Transmission Chain Statistics Using Branching Process Models}, author = {James M. Azam and Sebastian Funk and Flavio Finger}, year = {2024}, note = {R package version 0.1.1, https://epiverse-trace.github.io/epichains/}, url = {https://github.com/epiverse-trace/epichains}, }"},{"path":"https://epiverse-trace.github.io/epichains/index.html","id":"epichains-methods-for-simulating-and-analysing-the-size-and-length-of-transmission-chains-from-branching-process-models-","dir":"","previous_headings":"","what":"Simulating and Analysing Transmission Chain Statistics Using Branching Process Models","title":"Simulating and Analysing Transmission Chain Statistics Using Branching Process Models","text":"epichains R package simulate, analyse, visualize size length branching processes given offspring distribution. models often used infectious disease epidemiology, chains represent chains transmission, offspring distribution represents distribution secondary infections caused infected individual. epichains re-implements bpmodels providing bespoke functions data structures allow easy manipulation interoperability Epiverse-TRACE packages, example, superspreading epiparameter, potentially existing packages handling transmission chains, example, epicontacts. epichains developed Centre Mathematical Modelling Infectious Diseases London School Hygiene Tropical Medicine part Epiverse Initiative.","code":""},{"path":"https://epiverse-trace.github.io/epichains/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Simulating and Analysing Transmission Chain Statistics Using Branching Process Models","text":"Install released version package: latest development version epichains package can installed via fails, try using pak R package via options fail, please file issue full log error messages. example issue reporting installation failure. help us improve installation process. load package, use","code":"install.packages(\"epichains\") # check whether {remotes} is installed if (!require(\"remotes\")) install.packages(\"remotes\") remotes::install_github(\"epiverse-trace/epichains\") # check whether {pak} is installed if (!require(\"pak\")) install.packages(\"pak\") pak::pak(\"epiverse-trace/epichains\") library(\"epichains\")"},{"path":"https://epiverse-trace.github.io/epichains/index.html","id":"quick-start","dir":"","previous_headings":"","what":"Quick start","title":"Simulating and Analysing Transmission Chain Statistics Using Branching Process Models","text":"epichains provides three main functions: simulate_chains(): simulates transmission chains using simple branching process model accepts index number cases seed outbreak, distribution offspring per case, chain statistic track (size length/duration). optionally accepts population related inputs population size (defaults Inf) percentage population initially immune (defaults 0). function returns object columns track information infected , generation infection , generation time function specified, time infection. simulate_chain_stats(): provides performant version simulate_chains() tracks return vector realized chain sizes lengths/durations index case without details infection tree. likelihood(): calculates loglikelihood (likelihood, depending value log) observing vector transmission chain sizes lengths. objects returned simulate_*() functions can summarised summary(). Running summary() output simulate_chains() return output simulate_chain_stats() using inputs. Objects returned simulate_chains() can aggregated cases per time generation function aggregate(). simulated object can plotted various ways using plot(). See plotting section vignette(\"epichains\") two use cases.","code":""},{"path":"https://epiverse-trace.github.io/epichains/index.html","id":"simulation","dir":"","previous_headings":"Quick start","what":"Simulation","title":"Simulating and Analysing Transmission Chain Statistics Using Branching Process Models","text":"simulation functionality, let’s look simple example simulate transmission chain 2020 index cases, constant generation time 33, poisson offspring distribution mean 11. tracking chain “size” statistic cap chain sizes 2525 cases. look summary simulation, aggregate cases per generation.","code":"set.seed(32) # Simulate chains sim_chains <- simulate_chains( n_chains = 20, statistic = \"size\", offspring_dist = rpois, stat_threshold = 25, generation_time = function(n) { rep(3, n) }, # constant generation time of 3 lambda = 1 # mean of the Poisson distribution ) # View the head of the simulation head(sim_chains) #> chain infector infectee generation time #> 21 1 1 2 2 3 #> 22 2 1 2 2 3 #> 23 3 1 2 2 3 #> 24 3 1 3 2 3 #> 25 4 1 2 2 3 #> 26 6 1 2 2 3 # Summarise the simulation summary(sim_chains) #> `epichains_summary` object #> #> [1] 5 17 4 8 1 16 9 Inf 5 18 5 1 Inf 24 1 14 19 2 4 #> [20] 14 #> #> Simulated sizes: #> #> Max: >=25 #> Min: 1 # Aggregate the simulation into cases per generation chains_agregegated <- aggregate(sim_chains, by = \"generation\") # view the time series of cases per generation chains_agregegated #> generation cases #> 1 1 20 #> 2 2 26 #> 3 3 36 #> 4 4 43 #> 5 5 31 #> 6 6 25 #> 7 7 20 #> 8 8 9 #> 9 9 3 #> 10 10 1 #> 11 11 1 #> 12 12 1 #> 13 13 1"},{"path":"https://epiverse-trace.github.io/epichains/index.html","id":"inference","dir":"","previous_headings":"Quick start","what":"Inference","title":"Simulating and Analysing Transmission Chain Statistics Using Branching Process Models","text":"Let’s look following example estimate log-likelihood observing hypothetical chain_lengths dataset. listed functionalities demonstrated detail “Getting Started” vignette.","code":"set.seed(32) # randomly generate 20 chain lengths between 1 to 40 chain_lengths <- sample(1:40, 20, replace = TRUE) chain_lengths #> [1] 6 11 20 9 40 33 39 27 6 12 39 35 9 25 6 15 12 6 37 35 # estimate loglikelihood of the observed chain sizes likelihood_eg <- likelihood( chains = chain_lengths, statistic = \"length\", offspring_dist = rpois, lambda = 0.99 ) # Print the estimate likelihood_eg #> [1] -104.2917"},{"path":"https://epiverse-trace.github.io/epichains/index.html","id":"package-vignettes","dir":"","previous_headings":"","what":"Package vignettes","title":"Simulating and Analysing Transmission Chain Statistics Using Branching Process Models","text":"theory behind models provided can found theory vignette. also collated bibliography branching process applications epidemiology. can found literature vignette. Specific use cases epichains can found online documentation package vignettes, “Articles”.","code":""},{"path":"https://epiverse-trace.github.io/epichains/index.html","id":"related-r-packages","dir":"","previous_headings":"","what":"Related R packages","title":"Simulating and Analysing Transmission Chain Statistics Using Branching Process Models","text":"far know, existing R packages simulating branching processes transmission chains. bpmodels: provides methods analysing size length transmission chains branching process models. epichains supersedes {bpmodels}, retired. ringbp: branching process model, parameterised 2019-nCoV outbreak, used quantify potential effectiveness contact tracing isolation cases. covidhm: code simulating COVID-19 dynamics range scenarios across real-world social network. model conceptually based {ringbp}. epicontacts: provides methods handling, analysing, visualizing transmission chains contact-tracing data/linelists. simulist: uses branching process model simulate individual-level infectious disease outbreak data, including line lists contact tracing data. package part Epiverse-TRACE Initiative. superspreading: provides set functions estimate understand individual-level variation transmission infectious diseases data secondary cases. useful understanding role superspreading spread infectious diseases informing public health interventions. earlyR: estimates reproduction number (R), early stages outbreak. model requires specified serial interval distribution, characterised mean standard deviation (Gamma) distribution, data daily disease incidence, including confirmed probable cases. projections: uses data daily incidence, serial interval (time onsets infectors infectees) reproduction number simulate plausible epidemic trajectories project future incidence. relies branching process daily incidence follows Poisson Negative Binomial distribution governed force infection. simulacr: simulates outbreaks specified values reproduction number, incubation period, duration infectiousness, optionally reporting delays. Outputs linelist stored data.frame class outbreak, including information transmission chains; output can converted objects visualisation. outbreakr2: Bayesian framework integrating epidemiological genetic data reconstruct transmission trees densely sampled outbreaks. re-implements, generalises replaces model outbreaker, uses modular approach enables fine customisation priors, likelihoods parameter movements. o2geosocial: integrates geographical social contact data reconstruct transmission chains. combines age group, location, onset date genotype cases infer import status, likely infector. nosoi: simulates agent-based transmission chains taking account influence multiple variables transmission process (e.g. dual-host systems (arboviruses), within-host viral dynamics, transportation, population structure), alone taken together, create complex relatively intuitive epidemiological simulations. TransPhylo: reconstructs infectious disease transmission using genomic data.","code":""},{"path":"https://epiverse-trace.github.io/epichains/index.html","id":"reporting-bugs","dir":"","previous_headings":"","what":"Reporting bugs","title":"Simulating and Analysing Transmission Chain Statistics Using Branching Process Models","text":"report bug please open issue.","code":""},{"path":"https://epiverse-trace.github.io/epichains/index.html","id":"contribute","dir":"","previous_headings":"","what":"Contribute","title":"Simulating and Analysing Transmission Chain Statistics Using Branching Process Models","text":"Contributions {epichains} welcomed. Please follow package contributing guide.","code":""},{"path":"https://epiverse-trace.github.io/epichains/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of conduct","title":"Simulating and Analysing Transmission Chain Statistics Using Branching Process Models","text":"Please note epichains project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"https://epiverse-trace.github.io/epichains/index.html","id":"citing-this-package","dir":"","previous_headings":"","what":"Citing this package","title":"Simulating and Analysing Transmission Chain Statistics Using Branching Process Models","text":"","code":"citation(\"epichains\") #> To cite package 'epichains' in publications use: #> #> Azam J, Funk S, Finger F (2024). _epichains: Simulating and Analysing #> Transmission Chain Statistics Using Branching Process Models_. R #> package version 0.1.1, https://epiverse-trace.github.io/epichains/, #> . #> #> A BibTeX entry for LaTeX users is #> #> @Manual{, #> title = {epichains: Simulating and Analysing Transmission Chain Statistics Using #> Branching Process Models}, #> author = {James M. Azam and Sebastian Funk and Flavio Finger}, #> year = {2024}, #> note = {R package version 0.1.1, #> https://epiverse-trace.github.io/epichains/}, #> url = {https://github.com/epiverse-trace/epichains}, #> }"},{"path":"https://epiverse-trace.github.io/epichains/reference/aggregate.epichains.html","id":null,"dir":"Reference","previous_headings":"","what":"Aggregate cases in objects by ","title":"Aggregate cases in objects by ","text":"function provides quick way create time series cases generation time (generation_time specified) simulated objects.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/aggregate.epichains.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Aggregate cases in objects by ","text":"","code":"# S3 method for class 'epichains' aggregate(x, by = c(\"time\", \"generation\"), ...)"},{"path":"https://epiverse-trace.github.io/epichains/reference/aggregate.epichains.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Aggregate cases in objects by ","text":"x object. variable aggregate ; character string options \"time\" \"generation\". ... used.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/aggregate.epichains.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Aggregate cases in objects by ","text":" object cases .","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/aggregate.epichains.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Aggregate cases in objects by ","text":"James M. Azam","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/aggregate.epichains.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Aggregate cases in objects by ","text":"","code":"set.seed(32) chains <- simulate_chains( n_chains = 10, statistic = \"size\", offspring_dist = rpois, stat_threshold = 10, generation_time = function(n) rep(3, n), lambda = 2 ) chains #> `` object #> #> < epichains head (from first known infector) > #> #> chain infector infectee generation time #> 11 1 1 2 2 3 #> 12 1 1 3 2 3 #> 13 2 1 2 2 3 #> 14 2 1 3 2 3 #> 15 3 1 2 2 3 #> 16 3 1 3 2 3 #> #> #> Number of chains: 10 #> Number of infectors (known): 9 #> Number of generations: 4 #> Use `as.data.frame()` to view the full output in the console. # Aggregate cases per time cases_per_time <- aggregate(chains, by = \"time\") head(cases_per_time) #> time cases #> 1 0 10 #> 2 3 25 #> 3 6 61 #> 4 9 33 # Aggregate cases per generation cases_per_gen <- aggregate(chains, by = \"generation\") head(cases_per_gen) #> generation cases #> 1 1 10 #> 2 2 25 #> 3 3 61 #> 4 4 33"},{"path":"https://epiverse-trace.github.io/epichains/reference/covid19_sa.html","id":null,"dir":"Reference","previous_headings":"","what":"COVID-19 Data Repository for South Africa — covid19_sa","title":"COVID-19 Data Repository for South Africa — covid19_sa","text":"aggregated subset COVID-19 Data Repository South Africa created, maintained hosted Data Science Social Impact research group, led Dr. Vukosi Marivate.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/covid19_sa.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"COVID-19 Data Repository for South Africa — covid19_sa","text":"","code":"covid19_sa"},{"path":[]},{"path":"https://epiverse-trace.github.io/epichains/reference/covid19_sa.html","id":"covid-sa","dir":"Reference","previous_headings":"","what":"covid19_sa","title":"COVID-19 Data Repository for South Africa — covid19_sa","text":"data frame 19 rows 2 columns: date Date case reported cases Number cases","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/covid19_sa.html","id":"source","dir":"Reference","previous_headings":"","what":"Source","title":"COVID-19 Data Repository for South Africa — covid19_sa","text":"https://github.com/dsfsi/covid19za details data-raw/covid19_sa.R.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/covid19_sa.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"COVID-19 Data Repository for South Africa — covid19_sa","text":"data originally provided linelist subsetted cleaned data-raw/covid19_sa.R.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dborel.html","id":null,"dir":"Reference","previous_headings":"","what":"Density of the Borel distribution — dborel","title":"Density of the Borel distribution — dborel","text":"Density Borel distribution","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dborel.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Density of the Borel distribution — dborel","text":"","code":"dborel(x, mu, log = FALSE)"},{"path":"https://epiverse-trace.github.io/epichains/reference/dborel.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Density of the Borel distribution — dborel","text":"x numeric vector quantiles. mu non-negative number poisson mean. log Logical; TRUE, probabilities p given log(p).","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dborel.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Density of the Borel distribution — dborel","text":"numeric vector borel probability density.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dborel.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Density of the Borel distribution — dborel","text":"Sebastian Funk James M. Azam","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dborel.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Density of the Borel distribution — dborel","text":"","code":"set.seed(32) dborel(1:5, 1) #> [1] 0.36787944 0.13533528 0.07468060 0.04884170 0.03509347"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-adjust_next_gen.html","id":null,"dir":"Reference","previous_headings":"","what":"Adjust new offspring if it exceeds the susceptible population size — .adjust_next_gen","title":"Adjust new offspring if it exceeds the susceptible population size — .adjust_next_gen","text":"function used internally, input checking performed , context used. Using directly recommended.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-adjust_next_gen.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Adjust new offspring if it exceeds the susceptible population size — .adjust_next_gen","text":"","code":".adjust_next_gen(next_gen, susc_pop)"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-adjust_next_gen.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Adjust new offspring if it exceeds the susceptible population size — .adjust_next_gen","text":"next_gen numeric vector next generation offspring. susc_pop susceptible population size; number coercible integer.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-adjust_next_gen.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Adjust new offspring if it exceeds the susceptible population size — .adjust_next_gen","text":"numeric vector adjusted next generation offspring.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_generation_time_valid.html","id":null,"dir":"Reference","previous_headings":"","what":"Check if the generation_time argument is specified as a function — .check_generation_time_valid","title":"Check if the generation_time argument is specified as a function — .check_generation_time_valid","text":"Check generation_time argument specified function","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_generation_time_valid.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check if the generation_time argument is specified as a function — .check_generation_time_valid","text":"","code":".check_generation_time_valid(generation_time)"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_generation_time_valid.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check if the generation_time argument is specified as a function — .check_generation_time_valid","text":"generation_time generation time function; name user-defined named anonymous function one argument n, representing number generation times sample.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_offspring_func_valid.html","id":null,"dir":"Reference","previous_headings":"","what":"Check if constructed random number generator for offspring exists and has an n argument. — .check_offspring_func_valid","title":"Check if constructed random number generator for offspring exists and has an n argument. — .check_offspring_func_valid","text":"Check constructed random number generator offspring exists n argument.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_offspring_func_valid.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check if constructed random number generator for offspring exists and has an n argument. — .check_offspring_func_valid","text":"","code":".check_offspring_func_valid(offspring_dist)"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_offspring_func_valid.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check if constructed random number generator for offspring exists and has an n argument. — .check_offspring_func_valid","text":"offspring_dist Offspring distribution: like ones provided R generate random numbers given distributions (e.g., rpois Poisson). specifically, function needs accept least one argument, n, number random numbers generate. can accept arguments, passed random number generating functions. Examples can provided rpois Poisson distributed offspring, rnbinom negative binomial offspring, custom functions.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_sim_args.html","id":null,"dir":"Reference","previous_headings":"","what":"Check inputs to simulate_chains() and simulate_summary() — .check_sim_args","title":"Check inputs to simulate_chains() and simulate_summary() — .check_sim_args","text":"Check inputs simulate_chains() simulate_summary()","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_sim_args.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check inputs to simulate_chains() and simulate_summary() — .check_sim_args","text":"","code":".check_sim_args( n_chains, statistic, offspring_dist, stat_threshold, pop, percent_immune )"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_sim_args.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check inputs to simulate_chains() and simulate_summary() — .check_sim_args","text":"n_chains Number chains simulate. statistic chain statistic track stopping criteria chain simulated stat_threshold Inf; . can one : \"size\": total number cases produced chain goes extinct. \"length\": total number generations reached chain goes extinct. offspring_dist Offspring distribution: like ones provided R generate random numbers given distributions (e.g., rpois Poisson). specifically, function needs accept least one argument, n, number random numbers generate. can accept arguments, passed random number generating functions. Examples can provided rpois Poisson distributed offspring, rnbinom negative binomial offspring, custom functions. stat_threshold stopping criterion individual chain simulations; positive number coercible integer. chain's cumulative statistic reaches surpasses stat_threshold, chain ends. Defaults Inf. example, statistic = \"size\" stat_threshold = 10, chain produces 10 cases stop. Note setting stat_threshold guarantee chains stop value. pop Population size; . Used alongside percent_immune define susceptible population. Defaults Inf. percent_immune Percent population immune infection start simulation; 0 1. Used alongside pop initialise susceptible population. Defaults 0.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_sim_args.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check inputs to simulate_chains() and simulate_summary() — .check_sim_args","text":"NULL; called side effects","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_statistic_args.html","id":null,"dir":"Reference","previous_headings":"","what":"Check that the statistic and stat_threshold arguments are valid — .check_statistic_args","title":"Check that the statistic and stat_threshold arguments are valid — .check_statistic_args","text":"function treats two arguments related checks one place remove repeated checks several places package.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_statistic_args.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check that the statistic and stat_threshold arguments are valid — .check_statistic_args","text":"","code":".check_statistic_args(statistic, stat_threshold)"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_statistic_args.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check that the statistic and stat_threshold arguments are valid — .check_statistic_args","text":"statistic chain statistic track stopping criteria chain simulated stat_threshold Inf; . can one : \"size\": total number cases produced chain goes extinct. \"length\": total number generations reached chain goes extinct. stat_threshold stopping criterion individual chain simulations; positive number coercible integer. chain's cumulative statistic reaches surpasses stat_threshold, chain ends. Defaults Inf. example, statistic = \"size\" stat_threshold = 10, chain produces 10 cases stop. Note setting stat_threshold guarantee chains stop value.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_statistic_args.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check that the statistic and stat_threshold arguments are valid — .check_statistic_args","text":"NULL; called side effects","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_time_args.html","id":null,"dir":"Reference","previous_headings":"","what":"Check inputs that control time events — .check_time_args","title":"Check inputs that control time events — .check_time_args","text":"function checks time-related inputs, .e., start time chain, t0, end time simulation, tf, generation time, generation_time. also checks generation_time argument specified tf specified go hand--hand.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_time_args.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check inputs that control time events — .check_time_args","text":"","code":".check_time_args(tf_specified, tf, generation_time, t0)"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_time_args.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check inputs that control time events — .check_time_args","text":"tf_specified ; Whether tf argument specified. makes sense context function called, .e., simulate_chains(). tf specified, generation_time must specified. tf number cut-infection times (generation time given); Defaults Inf. generation_time generation time function; name user-defined named anonymous function one argument n, representing number generation times sample. t0 Start time (generation time given); either single value vector length n_chains (number initial cases) corresponding initial times. Defaults 0, meaning cases started time 0.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-check_time_args.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check inputs that control time events — .check_time_args","text":"NULL; called side effects","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-complementary_logprob.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculates the complementary log-probability — .complementary_logprob","title":"Calculates the complementary log-probability — .complementary_logprob","text":"Given x norm, calculates log(1-sum(exp(x)))","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-complementary_logprob.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculates the complementary log-probability — .complementary_logprob","text":"","code":".complementary_logprob(x)"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-complementary_logprob.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculates the complementary log-probability — .complementary_logprob","text":"x numeric vector log-probabilities. Must negative.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-complementary_logprob.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculates the complementary log-probability — .complementary_logprob","text":"numeric value complementary log-probability.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-complementary_logprob.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Calculates the complementary log-probability — .complementary_logprob","text":"Sebastian Funk","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-epichains.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an object — .epichains","title":"Create an object — .epichains","text":"epichains() constructs object, inherently object stores inputs passed simulate_chains() simulated output. stored attributes useful downstream analyses reproducibility. function checks validity object created ensure right columns column types. object contains simulated outbreak ids infector infectee, generation, optionally, time, number chains simulated, chain statistic tracked, whether susceptible population tracked.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-epichains.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an object — .epichains","text":"","code":".epichains( sim_df, n_chains, offspring_dist, track_pop, statistic = c(\"size\", \"length\"), stat_threshold = Inf )"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-epichains.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an object — .epichains","text":"sim_df containing least columns \"infectee_id\", \"infector_id\", \"generation\". Also optional columns \"time\", \"chain_id\". n_chains Number chains simulate. offspring_dist Offspring distribution: like ones provided R generate random numbers given distributions (e.g., rpois Poisson). specifically, function needs accept least one argument, n, number random numbers generate. can accept arguments, passed random number generating functions. Examples can provided rpois Poisson distributed offspring, rnbinom negative binomial offspring, custom functions. track_pop susceptible population tracked? Logical. statistic chain statistic track stopping criteria chain simulated stat_threshold Inf; . can one : \"size\": total number cases produced chain goes extinct. \"length\": total number generations reached chain goes extinct. stat_threshold stopping criterion individual chain simulations; positive number coercible integer. chain's cumulative statistic reaches surpasses stat_threshold, chain ends. Defaults Inf. example, statistic = \"size\" stat_threshold = 10, chain produces 10 cases stop. Note setting stat_threshold guarantee chains stop value.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-epichains.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an object — .epichains","text":" object.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-epichains.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Create an object — .epichains","text":"James M. Azam","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-epichains_summary.html","id":null,"dir":"Reference","previous_headings":"","what":"Create an object — .epichains_summary","title":"Create an object — .epichains_summary","text":"epichains_summary() constructs object. object simulated chain sizes lengths. also stores information number chains simulated, statistic tracked.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-epichains_summary.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Create an object — .epichains_summary","text":"","code":".epichains_summary( chains_summary, n_chains, offspring_dist, statistic = c(\"size\", \"length\"), stat_threshold = Inf )"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-epichains_summary.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Create an object — .epichains_summary","text":"chains_summary numeric chain sizes lengths. n_chains Number chains simulate. offspring_dist Offspring distribution: like ones provided R generate random numbers given distributions (e.g., rpois Poisson). specifically, function needs accept least one argument, n, number random numbers generate. can accept arguments, passed random number generating functions. Examples can provided rpois Poisson distributed offspring, rnbinom negative binomial offspring, custom functions. statistic chain statistic track stopping criteria chain simulated stat_threshold Inf; . can one : \"size\": total number cases produced chain goes extinct. \"length\": total number generations reached chain goes extinct. stat_threshold stopping criterion individual chain simulations; positive number coercible integer. chain's cumulative statistic reaches surpasses stat_threshold, chain ends. also serves censoring limit results specified value, set Inf. Defaults Inf.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-epichains_summary.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Create an object — .epichains_summary","text":" object.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-epichains_summary.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Create an object — .epichains_summary","text":"James M. Azam","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-gborel_size_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — .gborel_size_ll","title":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — .gborel_size_ll","text":"Log-likelihood size chains gamma-Borel offspring distribution","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-gborel_size_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — .gborel_size_ll","text":"","code":".gborel_size_ll(x, size, prob, mu)"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-gborel_size_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — .gborel_size_ll","text":"x numeric vector chain sizes. size dispersion parameter (often called k ecological applications); positive number. prob Probability success (parameterisation prob, see also NegBinomial); number 0 1. mu Mean; positive number.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-gborel_size_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — .gborel_size_ll","text":"numeric vector log-likelihood values.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-gborel_size_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Log-likelihood of the size of chains with gamma-Borel offspring distribution — .gborel_size_ll","text":"Sebastian Funk James M. Azam","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-geom_length_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Log-likelihood of the length of chains with geometric offspring distribution — .geom_length_ll","title":"Log-likelihood of the length of chains with geometric offspring distribution — .geom_length_ll","text":"Log-likelihood length chains geometric offspring distribution","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-geom_length_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Log-likelihood of the length of chains with geometric offspring distribution — .geom_length_ll","text":"","code":".geom_length_ll(x, prob)"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-geom_length_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Log-likelihood of the length of chains with geometric offspring distribution — .geom_length_ll","text":"x numeric vector chain lengths. prob probability geometric distribution mean 1/prob. single numeric value 0 1.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-geom_length_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Log-likelihood of the length of chains with geometric offspring distribution — .geom_length_ll","text":"numeric vector log-likelihood values.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-geom_length_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Log-likelihood of the length of chains with geometric offspring distribution — .geom_length_ll","text":"Sebastian Funk James M. Azam","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-get_statistic_func.html","id":null,"dir":"Reference","previous_headings":"","what":"Return a function for calculating chain statistics — .get_statistic_func","title":"Return a function for calculating chain statistics — .get_statistic_func","text":"Return function calculating chain statistics","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-get_statistic_func.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return a function for calculating chain statistics — .get_statistic_func","text":"","code":".get_statistic_func(chain_statistic)"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-get_statistic_func.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return a function for calculating chain statistics — .get_statistic_func","text":"function calculating chain statistics.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-get_susceptible_offspring.html","id":null,"dir":"Reference","previous_headings":"","what":"Sample the number of susceptible offspring from all possible offspring — .get_susceptible_offspring","title":"Sample the number of susceptible offspring from all possible offspring — .get_susceptible_offspring","text":"Sample susceptible offspring infected possible offspring. function used internally, input checking performed , context used. Using directly recommended.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-get_susceptible_offspring.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Sample the number of susceptible offspring from all possible offspring — .get_susceptible_offspring","text":"","code":".get_susceptible_offspring(new_offspring, susc_pop, pop)"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-get_susceptible_offspring.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Sample the number of susceptible offspring from all possible offspring — .get_susceptible_offspring","text":"new_offspring numeric vector possible new offspring per chain produced .sample_possible_offspring(). pop Population size; . Used alongside percent_immune define susceptible population. Defaults Inf.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-get_susceptible_offspring.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Sample the number of susceptible offspring from all possible offspring — .get_susceptible_offspring","text":"numeric vector number offspring can infected given current susceptible population size.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-init_susc_pop.html","id":null,"dir":"Reference","previous_headings":"","what":"Adjust next generation vector to match susceptible population size — .init_susc_pop","title":"Adjust next generation vector to match susceptible population size — .init_susc_pop","text":"Calculates initial susceptible population size given total population size, percent immune, number index cases. function used internally, input checking performed , context used. Using directly recommended.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-init_susc_pop.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Adjust next generation vector to match susceptible population size — .init_susc_pop","text":"","code":".init_susc_pop(pop, percent_immune, index_cases)"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-init_susc_pop.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Adjust next generation vector to match susceptible population size — .init_susc_pop","text":"pop Population size; . Used alongside percent_immune define susceptible population. Defaults Inf. percent_immune Percent population immune infection start simulation; 0 1. Used alongside pop initialise susceptible population. Defaults 0.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-init_susc_pop.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Adjust next generation vector to match susceptible population size — .init_susc_pop","text":"Initial susceptible population size; numeric coercible integer.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-is_epichains.html","id":null,"dir":"Reference","previous_headings":"","what":"Test if x is an epichains object — .is_epichains","title":"Test if x is an epichains object — .is_epichains","text":"Test x epichains object","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-is_epichains.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Test if x is an epichains object — .is_epichains","text":"","code":".is_epichains(x)"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-is_epichains.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Test if x is an epichains object — .is_epichains","text":"x R object.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-is_epichains.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Test if x is an epichains object — .is_epichains","text":"Logical; TRUE object FALSE otherwise.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-is_epichains.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Test if x is an epichains object — .is_epichains","text":"James M. Azam","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-is_epichains_summary.html","id":null,"dir":"Reference","previous_headings":"","what":"Test if x is an epichains_summary object — .is_epichains_summary","title":"Test if x is an epichains_summary object — .is_epichains_summary","text":"Test x epichains_summary object","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-is_epichains_summary.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Test if x is an epichains_summary object — .is_epichains_summary","text":"","code":".is_epichains_summary(x)"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-is_epichains_summary.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Test if x is an epichains_summary object — .is_epichains_summary","text":"x R object.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-is_epichains_summary.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Test if x is an epichains_summary object — .is_epichains_summary","text":"Logical; TRUE object FALSE otherwise.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-is_epichains_summary.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Test if x is an epichains_summary object — .is_epichains_summary","text":"James M. Azam","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-nbinom_size_ll.html","id":null,"dir":"Reference","previous_headings":"","what":"Log-likelihood of the size of chains with Negative-Binomial offspring distribution — .nbinom_size_ll","title":"Log-likelihood of the size of chains with Negative-Binomial offspring distribution — .nbinom_size_ll","text":"Log-likelihood size chains Negative-Binomial offspring distribution","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-nbinom_size_ll.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Log-likelihood of the size of chains with Negative-Binomial offspring distribution — .nbinom_size_ll","text":"","code":".nbinom_size_ll(x, size, prob, mu)"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-nbinom_size_ll.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Log-likelihood of the size of chains with Negative-Binomial offspring distribution — .nbinom_size_ll","text":"x numeric vector chain sizes. size dispersion parameter (often called k ecological applications); positive number. prob Probability success (parameterisation prob, see also NegBinomial); number 0 1. mu Mean; positive number.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-nbinom_size_ll.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Log-likelihood of the size of chains with Negative-Binomial offspring distribution — .nbinom_size_ll","text":"numeric vector log-likelihood values.","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-nbinom_size_ll.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Log-likelihood of the size of chains with Negative-Binomial offspring distribution — .nbinom_size_ll","text":"Sebastian Funk James M. Azam","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-new_epichains.html","id":null,"dir":"Reference","previous_headings":"","what":"Construct an object — .new_epichains","title":"Construct an object — .new_epichains","text":"new_epichains() constructs object supplied extra attributes passed individual arguments. meant lazy performant, creating object without checking arguments correctness. safe call new_epichains() called within epichains() arguments checked. create object, use epichains().","code":""},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-new_epichains.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Construct an object — .new_epichains","text":"","code":".new_epichains( sim_df, n_chains, statistic, offspring_dist, stat_threshold, track_pop )"},{"path":"https://epiverse-trace.github.io/epichains/reference/dot-new_epichains.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Construct an object — .new_epichains","text":"sim_df
LICENSE.md
vignettes/branching_process_literature.Rmd
branching_process_literature.Rmd
vignettes/design-principles.Rmd
design-principles.Rmd
vignettes/epichains.Rmd
epichains.Rmd
vignettes/interventions.Rmd
interventions.Rmd
vignettes/projecting_incidence.Rmd
projecting_incidence.Rmd
vignettes/theoretical_background.Rmd
theoretical_background.Rmd
Source: DESCRIPTION
DESCRIPTION
Azam J, Funk S, Finger F (2024). epichains: Simulating and Analysing Transmission Chain Statistics Using Branching Process Models. -R package version 0.1.1, +R package version 0.1.1.9000, https://epiverse-trace.github.io/epichains/, https://github.com/epiverse-trace/epichains.
@Manual{, title = {epichains: Simulating and Analysing Transmission Chain Statistics Using Branching Process Models}, author = {James M. Azam and Sebastian Funk and Flavio Finger}, year = {2024}, - note = {R package version 0.1.1, + note = {R package version 0.1.1.9000, https://epiverse-trace.github.io/epichains/}, url = {https://github.com/epiverse-trace/epichains}, }
NEWS.md
CRAN release: 2024-10-14
This is the first CRAN release of epichains.
<epichains>
R/epichains.R
aggregate.epichains.Rd
R/covid19_sa.R
covid19_sa.Rd
R/borel.R
dborel.Rd
R/helpers.R
dot-adjust_next_gen.Rd
R/checks.R
dot-check_generation_time_valid.Rd
n
dot-check_offspring_func_valid.Rd
simulate_chains()
simulate_summary()
dot-check_sim_args.Rd
statistic
stat_threshold
dot-check_statistic_args.Rd
dot-check_time_args.Rd
R/utils.R
dot-complementary_logprob.Rd
dot-epichains.Rd
<epichains_summary>
dot-epichains_summary.Rd
R/stat_likelihoods.R
dot-gborel_size_ll.Rd
dot-geom_length_ll.Rd
dot-get_statistic_func.Rd
dot-get_susceptible_offspring.Rd
dot-init_susc_pop.Rd
epichains
dot-is_epichains.Rd
epichains_summary
dot-is_epichains_summary.Rd
dot-nbinom_size_ll.Rd
dot-new_epichains.Rd
dot-new_epichains_summary.Rd
dot-offspring_ll.Rd
dot-pois_length_ll.Rd
dot-pois_size_ll.Rd
dot-rbinom_size.Rd
dot-rgen_length.Rd
dot-sample_possible_offspring.Rd
dot-update_chain_stat.Rd
dot-validate_epichains.Rd
dot-validate_epichains_summary.Rd
R/epichains-package.R
epichains-package.Rd
head
tail
head.epichains.Rd
R/likelihood.R
likelihood.Rd
print.epichains.Rd
print.epichains_summary.Rd
rborel.Rd
rgborel.Rd
R/simulate.R
simulate_chain_stats.Rd
simulate_chains.Rd
summary.epichains.Rd
summary.epichains_summary.Rd