Skip to content

Commit

Permalink
add include_index_case argument in simulate_scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlambert committed Sep 6, 2024
1 parent 0e87e5e commit 6237c9b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 9 additions & 1 deletion R/simulate.R
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ simulate_chain_stats <- function(n_chains,
#' @param ... [dots] Extra arguments to be passed to [simulate_chain_stats()].
#' If argument does not match one from [simulate_chain_stats()] the function
#' will error.
#' @param include_index_case A `logical` determining whether the index case
#' that seeds the outbreak is counted in the transmission chain statistic.
#'
#' @return A `<data.frame>`.
#' @export
Expand Down Expand Up @@ -531,7 +533,10 @@ simulate_scenarios <- function(statistic,
R_seq,
k_seq,
breaks,
...) {
...,
include_index_case = TRUE) {
browser()

Check warning on line 538 in R/simulate.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/simulate.R,line=538,col=3,[undesirable_function_linter] Function "browser" is undesirable. As an alternative, remove this likely leftover from debugging. It pauses execution when run.
checkmate::assert_logical(include_index_case, any.missing = FALSE, len = 1)
scenarios <- expand.grid(
offspring_dist = offspring_dist,
statistic = statistic,
Expand Down Expand Up @@ -569,6 +574,9 @@ simulate_scenarios <- function(statistic,
}
args <- utils::modifyList(x = args, val = list(...))
x <- do.call(epichains::simulate_chain_stats, args = args)
if (!include_index_case) {
x <- x - 1
}
interval <- cut(x, breaks = breaks)
prop <- table(interval) / sum(table(interval))
df_ <- as.data.frame(prop)
Expand Down
13 changes: 12 additions & 1 deletion man/simulate_scenarios.Rd

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

0 comments on commit 6237c9b

Please sign in to comment.