Skip to content

Commit

Permalink
set default risks to NULL when onset-to-event is NULL, closes #146
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlambert committed Jul 17, 2024
1 parent 7369293 commit 8bd728a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions R/sim_linelist.R
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,27 @@ sim_linelist <- function(contact_distribution = function(x) stats::dpois(x = x,
confirmed = 0.5
),
config = create_config()) {
# if hosp_risk or hosp_death_risk is supplied but onset_to_hosp is NULL
# set risks to NULL without warning in .cross_check_sim_input()
# this needs to happen in the current function frame and not within
# .cross_check_sim_input() due to the behaviour of missing()
if (is.null(onset_to_hosp)) {
if (missing(hosp_risk)) {
hosp_risk <- NULL
}
if (missing(hosp_death_risk)) {
hosp_death_risk <- NULL
}
}
if (is.null(onset_to_death)) {
if (missing(non_hosp_death_risk)) {
non_hosp_death_risk <- NULL
}
if (missing(hosp_death_risk)) {
hosp_death_risk <- NULL
}
}

# check and convert distribution to func if needed before .check_sim_input()
funcs <- as_function(
list(
Expand Down

0 comments on commit 8bd728a

Please sign in to comment.