Skip to content

Commit

Permalink
Rename serial_sampler argument to serial_dist
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmbaazam committed Sep 4, 2023
1 parent 4c89189 commit 22112d4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions R/simulate.r
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ simulate_summary <- function(nchains, statistic = c("size", "length"),
#' secondary cases. Ignored if \code{offspring == "pois"}. Must be > 1 to
#' avoid division by 0 when calculating the size. See details and
#' \code{?rnbinom} for details on the parameterisation in Ecology.
#' @param serial_sampler The serial interval. A function that takes one
#' @param serial_dist The serial interval. A function that takes one
#' parameter (`n`), the number of serial intervals to randomly sample. Value
#' must be >= 0.
#' @param initial_immune The number of initial immunes in the population.
Expand Down Expand Up @@ -334,20 +334,20 @@ simulate_summary <- function(nchains, statistic = c("size", "length"),
#' # Simulate with poisson offspring
#' simulate_tree_from_pop(
#' pop = 100, offspring_dist = "pois",
#' offspring_mean = 0.5, serial_sampler = function(x) 3
#' offspring_mean = 0.5, serial_dist = function(x) 3
#' )
#'
#' # Simulate with negative binomial offspring
#' simulate_tree_from_pop(
#' pop = 100, offspring_dist = "nbinom",
#' offspring_mean = 0.5, offspring_disp = 1.1, serial_sampler = function(x) 3
#' offspring_mean = 0.5, offspring_disp = 1.1, serial_dist = function(x) 3
#' )
#' @export
simulate_tree_from_pop <- function(pop,
offspring_dist = c("pois", "nbinom"),
offspring_mean,
offspring_disp,
serial_sampler,
serial_dist,
initial_immune = 0,
t0 = 0,
tf = Inf) {
Expand Down Expand Up @@ -418,7 +418,7 @@ simulate_tree_from_pop <- function(pop,
## add to df
if (n_offspring > 0) {
## draw serial times
new_times <- serial_sampler(n_offspring)
new_times <- serial_dist(n_offspring)

if (any(new_times < 0)) {
stop("Serial interval must be >= 0.")
Expand Down
8 changes: 4 additions & 4 deletions man/simulate_tree_from_pop.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/tests-sim.r
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test_that("Simulators output epichains objects", {
offspring_dist = "nbinom",
offspring_mean = 0.5,
offspring_disp = 1.1,
serial_sampler = function(x) 3
serial_dist = function(x) 3
),
"epichains"
)
Expand Down
4 changes: 2 additions & 2 deletions vignettes/epichains.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ tree_from_pop_pois <- simulate_tree_from_pop(
pop = 1000,
offspring_dist = "pois",
offspring_mean = 0.5,
serial_sampler = function(x) 3
serial_dist = function(x) 3
)
tree_from_pop_pois # print the output
Expand All @@ -102,7 +102,7 @@ tree_from_pop_nbinom <- simulate_tree_from_pop(
offspring_dist = "nbinom",
offspring_mean = 0.5,
offspring_disp = 1.1,
serial_sampler = function(x) 3
serial_dist = function(x) 3
)
tree_from_pop_nbinom # print the output
Expand Down

0 comments on commit 22112d4

Please sign in to comment.