Skip to content

Commit

Permalink
added onset_to_recovery to sim_linelist and sim_outbreak, WIP #36
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlambert committed Apr 25, 2024
1 parent 4c54346 commit af56831
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 14 deletions.
21 changes: 16 additions & 5 deletions R/sim_linelist.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@
#' infectious period.
#' @param prob_infect A single `numeric` for the probability of a secondary
#' contact being infected by an infected primary contact.
#' @param onset_to_hosp An `<epidist>` object or anonymous function for
#' the onset to hospitalisation delay distribution.
#' @param onset_to_death An `<epidist>` object or anonymous function for
#' the onset to death delay distribution.
#' @param onset_to_hosp An `<epidist>` object, an anonymous function for
#' the onset to hospitalisation delay distribution, or `NA` to not simulate
#' hospitalisation (admission) dates.
#' @param onset_to_death An `<epidist>` object, an anonymous function for
#' the onset to death delay distribution, or `NA` to not simulate dates for
#' individuals that died.
#' @param onset_to_recovery An `<epidist>` object, an anonymous function for
#' the onset to death delay distribution, or `NA` to not simulate dates for
#' individuals that recovered. Default is `NA` so by default cases that
#' recover get an `NA` in the `$date_outcome` line list column.
#' @param hosp_risk Either a single `numeric` for the hospitalisation risk of
#' everyone in the population, or a `<data.frame>` with age specific
#' hospitalisation risks Default is 20% hospitalisation (`0.2`) for the entire
Expand Down Expand Up @@ -151,6 +157,7 @@ sim_linelist <- function(contact_distribution,
prob_infect,
onset_to_hosp,
onset_to_death,
onset_to_recovery = NA,
hosp_risk = 0.2,
hosp_death_risk = 0.5,
non_hosp_death_risk = 0.05,
Expand All @@ -171,13 +178,15 @@ sim_linelist <- function(contact_distribution,
contact_distribution = contact_distribution,
infect_period = infect_period,
onset_to_hosp = onset_to_hosp,
onset_to_death = onset_to_death
onset_to_death = onset_to_death,
onset_to_recovery = onset_to_recovery
)
)
contact_distribution <- funcs$contact_distribution
infect_period <- funcs$infect_period
onset_to_hosp <- funcs$onset_to_hosp
onset_to_death <- funcs$onset_to_death
onset_to_recovery <- funcs$onset_to_recovery

.check_sim_input(
sim_type = "linelist",
Expand All @@ -188,6 +197,7 @@ sim_linelist <- function(contact_distribution,
outbreak_size = outbreak_size,
onset_to_hosp = onset_to_hosp,
onset_to_death = onset_to_death,
onset_to_recovery = onset_to_recovery,
add_names = add_names,
add_ct = add_ct,
case_type_probs = case_type_probs,
Expand Down Expand Up @@ -241,6 +251,7 @@ sim_linelist <- function(contact_distribution,
prob_infect = prob_infect,
onset_to_hosp = onset_to_hosp,
onset_to_death = onset_to_death,
onset_to_recovery = onset_to_recovery,
hosp_risk = hosp_risk,
hosp_death_risk = hosp_death_risk,
non_hosp_death_risk = non_hosp_death_risk,
Expand Down
7 changes: 6 additions & 1 deletion R/sim_outbreak.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ sim_outbreak <- function(contact_distribution,
prob_infect,
onset_to_hosp,
onset_to_death,
onset_to_recovery = NA,
hosp_risk = 0.2,
hosp_death_risk = 0.5,
non_hosp_death_risk = 0.05,
Expand All @@ -83,13 +84,15 @@ sim_outbreak <- function(contact_distribution,
contact_distribution = contact_distribution,
infect_period = infect_period,
onset_to_hosp = onset_to_hosp,
onset_to_death = onset_to_death
onset_to_death = onset_to_death,
onset_to_recovery = onset_to_recovery
)
)
contact_distribution <- funcs$contact_distribution
infect_period <- funcs$infect_period
onset_to_hosp <- funcs$onset_to_hosp
onset_to_death <- funcs$onset_to_death
onset_to_recovery <- funcs$onset_to_recovery

.check_sim_input(
sim_type = "outbreak",
Expand All @@ -100,6 +103,7 @@ sim_outbreak <- function(contact_distribution,
outbreak_size = outbreak_size,
onset_to_hosp = onset_to_hosp,
onset_to_death = onset_to_death,
onset_to_recovery = onset_to_recovery,
add_names = add_names,
add_ct = add_ct,
case_type_probs = case_type_probs,
Expand Down Expand Up @@ -154,6 +158,7 @@ sim_outbreak <- function(contact_distribution,
prob_infect = prob_infect,
onset_to_hosp = onset_to_hosp,
onset_to_death = onset_to_death,
onset_to_recovery = onset_to_recovery,
hosp_risk = hosp_risk,
hosp_death_risk = hosp_death_risk,
non_hosp_death_risk = non_hosp_death_risk,
Expand Down
16 changes: 12 additions & 4 deletions man/sim_linelist.Rd

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

16 changes: 12 additions & 4 deletions man/sim_outbreak.Rd

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

0 comments on commit af56831

Please sign in to comment.