From 37b36fd1b8744317837ffadb1ad2d88245f84e3a Mon Sep 17 00:00:00 2001 From: jamesaazam Date: Thu, 22 Aug 2024 14:36:31 +0100 Subject: [PATCH 1/6] Update WORDLIST --- inst/WORDLIST | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/inst/WORDLIST b/inst/WORDLIST index cc46fc3..0a0d423 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,6 +1,8 @@ Borel CMD COVID +Eq +Lifecycle Marivate ORCID Poisson @@ -9,16 +11,25 @@ README's Vukosi Zhian codecov +cutoff dfrac doi ecdf +epichains +frac gborel +geq immunes +infectee infectees +infector infectors json +kS linelist ln +mathbf +mathrm nbinom nolint pois @@ -27,4 +38,6 @@ quickstart sim superspreading susceptibles +th +unnormalised var From 5c7f79450d6afe4b6765609c16adbbac3b5d2ce7 Mon Sep 17 00:00:00 2001 From: jamesaazam Date: Thu, 22 Aug 2024 14:37:40 +0100 Subject: [PATCH 2/6] Check that nbinom params are not both zero --- R/simulate.r | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/R/simulate.r b/R/simulate.r index 4f1db91..56e65aa 100644 --- a/R/simulate.r +++ b/R/simulate.r @@ -128,6 +128,13 @@ chain_sim <- function(n, offspring, stat = c("size", "length"), infinite = Inf, if (!(exists(roffspring_name)) || !is.function(get(roffspring_name))) { stop("Function ", roffspring_name, " does not exist.") } + # If both parameters of the negative binomial are zero, you get NaNs + if (roffspring_name == "rnbinom" && all(c(...) == 0)) { + stop( + "The negative binomial parameters must have at least one ", + "non-zero parameter." + ) + } if (!missing(serial)) { if (!is.function(serial)) { From b913f51dfd3e5f2026341a1a2d114231a54a8b58 Mon Sep 17 00:00:00 2001 From: jamesaazam Date: Thu, 22 Aug 2024 14:37:52 +0100 Subject: [PATCH 3/6] Add test for expected error --- tests/testthat/tests-sim.r | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/testthat/tests-sim.r b/tests/testthat/tests-sim.r index c284b32..f287b7b 100644 --- a/tests/testthat/tests-sim.r +++ b/tests/testthat/tests-sim.r @@ -134,6 +134,16 @@ test_that("Errors are thrown", { ), "If `tf` is specified, `serial` must be specified too." ) + expect_error( + chain_sim( + n = 10, + offspring = "nbinom", + stat = "size", + mu = 0, + size = 0 + ), + "must have at least one non-zero parameter" + ) }) test_that("Chains can be simulated", { From d10fdb15dd7805730a1df758f4a614dd6e781ff7 Mon Sep 17 00:00:00 2001 From: jamesaazam Date: Thu, 22 Aug 2024 15:52:39 +0100 Subject: [PATCH 4/6] Bump up version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index ed89c41..40b86e9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: bpmodels Title: Simulating and Analysing Transmission Chain Statistics using Branching Process Models -Version: 0.3.1 +Version: 0.3.2 Authors@R: c( person("James M.", "Azam", , "james.azam@lshtm.ac.uk", role = c("aut", "cre"), comment = c(ORCID = "https://orcid.org/0000-0001-5782-7330")), From 540228d44203b589d6fba23cfa95c3c5ab0072f4 Mon Sep 17 00:00:00 2001 From: jamesaazam Date: Thu, 22 Aug 2024 15:52:50 +0100 Subject: [PATCH 5/6] Add NEWS item --- NEWS.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS.md b/NEWS.md index a77841f..9934ec2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# bpmodels 0.3.2 + +## Model + +* `chain_sim()` now ensures that the parameters of the negative binomial offspring are not both zero else returns an informative error. + # bpmodels 0.3.1 ## Unit tests and input validation From 59b80a17ddbcbac16e1d54347950dac7e53573c0 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Thu, 22 Aug 2024 15:02:47 +0000 Subject: [PATCH 6/6] Update CITATION.cff --- CITATION.cff | 56 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/CITATION.cff b/CITATION.cff index 6352874..cc1071a 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -1,7 +1,7 @@ -# ----------------------------------------------------------- -# CITATION file created with {cffr} R package, v0.5.0 +# -------------------------------------------- +# CITATION file created with {cffr} R package # See also: https://docs.ropensci.org/cffr/ -# ----------------------------------------------------------- +# -------------------------------------------- cff-version: 1.2.0 message: 'To cite package "bpmodels" in publications use:' @@ -9,11 +9,11 @@ type: software license: MIT title: 'bpmodels: Simulating and Analysing Transmission Chain Statistics using Branching Process Models' -version: 0.3.1 +version: 0.3.2 abstract: Provides methods to simulate and analyse the size and length of branching processes with an arbitrary offspring distribution. These can be used, for example, to analyse the distribution of chain sizes or length of infectious disease outbreaks, - as discussed in Farrington et al. (2003) . + as discussed in Farrington et al. (2003) . authors: - family-names: Azam given-names: James M. @@ -37,8 +37,8 @@ preferred-citation: - name: James M. Azam year: '2023' url: https://github.com/epiverse-trace/bpmodels/ -repository-code: https://github.com/epiverse-trace/bpmodels -url: https://epiverse-trace.github.io/bpmodels/ +repository-code: https://github.com/epiforecasts/bpmodels +url: https://epiforecasts.io/bpmodels/ contact: - family-names: Azam given-names: James M. @@ -63,11 +63,10 @@ references: url: https://www.R-project.org/ authors: - name: R Core Team - location: - name: Vienna, Austria - year: '2023' institution: name: R Foundation for Statistical Computing + address: Vienna, Austria + year: '2024' version: '>= 3.6.0' - type: software title: bookdown @@ -80,7 +79,8 @@ references: given-names: Yihui email: xie@yihui.name orcid: https://orcid.org/0000-0003-0645-5666 - year: '2023' + year: '2024' + doi: 10.32614/CRAN.package.bookdown - type: software title: dplyr abstract: 'dplyr: A Grammar of Data Manipulation' @@ -104,7 +104,8 @@ references: given-names: Davis email: davis@posit.co orcid: https://orcid.org/0000-0003-4777-038X - year: '2023' + year: '2024' + doi: 10.32614/CRAN.package.dplyr - type: software title: ggplot2 abstract: 'ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics' @@ -139,7 +140,12 @@ references: - family-names: Dunnington given-names: Dewey orcid: https://orcid.org/0000-0002-9415-4582 - year: '2023' + - family-names: Brand + given-names: Teun + name-particle: van den + orcid: https://orcid.org/0000-0002-9335-7468 + year: '2024' + doi: 10.32614/CRAN.package.ggplot2 - type: software title: knitr abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R' @@ -151,7 +157,8 @@ references: given-names: Yihui email: xie@yihui.name orcid: https://orcid.org/0000-0003-0645-5666 - year: '2023' + year: '2024' + doi: 10.32614/CRAN.package.knitr - type: software title: lubridate abstract: 'lubridate: Make Dealing with Dates a Little Easier' @@ -166,7 +173,8 @@ references: given-names: Garrett - family-names: Wickham given-names: Hadley - year: '2023' + year: '2024' + doi: 10.32614/CRAN.package.lubridate - type: software title: rmarkdown abstract: 'rmarkdown: Dynamic Documents for R' @@ -209,12 +217,13 @@ references: given-names: Richard email: rich@posit.co orcid: https://orcid.org/0000-0003-3925-190X - year: '2023' + year: '2024' + doi: 10.32614/CRAN.package.rmarkdown - type: software title: spelling abstract: 'spelling: Tools for Spell Checking in R' notes: Suggests - url: https://docs.ropensci.org/spelling/ + url: https://ropensci.r-universe.dev/spelling repository: https://CRAN.R-project.org/package=spelling authors: - family-names: Ooms @@ -224,7 +233,8 @@ references: - family-names: Hester given-names: Jim email: james.hester@rstudio.com - year: '2023' + year: '2024' + doi: 10.32614/CRAN.package.spelling - type: software title: testthat abstract: 'testthat: Unit Testing for R' @@ -235,7 +245,8 @@ references: - family-names: Wickham given-names: Hadley email: hadley@posit.co - year: '2023' + year: '2024' + doi: 10.32614/CRAN.package.testthat - type: software title: truncdist abstract: 'truncdist: Truncated Random Variables' @@ -248,7 +259,8 @@ references: - family-names: Nadarajah given-names: Saralees email: saralees.nadarajah@manchester.ac.uk - year: '2023' + year: '2024' + doi: 10.32614/CRAN.package.truncdist - type: software title: checkmate abstract: 'checkmate: Fast and Versatile Argument Checks' @@ -260,4 +272,6 @@ references: given-names: Michel email: michellang@gmail.com orcid: https://orcid.org/0000-0001-9754-0393 - year: '2023' + year: '2024' + doi: 10.32614/CRAN.package.checkmate +