Skip to content

Commit 5ac5b1b

Browse files
committed
rename incfn to incubation_period
1 parent 60c7eed commit 5ac5b1b

16 files changed

+93
-81
lines changed

R/aux_functions.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ inf_fn <- function(inc_samp = NULL, k = NULL) {
4242
#' disp.com = 0.16,
4343
#' disp.iso = 1,
4444
#' onset_to_isolation = \(x) stats::rweibull(n = x, shape = 1.65, scale = 4.28),
45-
#' incfn = \(x) stats::rweibull(n = x, shape = 2.322737, scale = 6.492272),
45+
#' incubation_period = \(x) stats::rweibull(n = x, shape = 2.322737, scale = 6.492272),
4646
#' k = 0,
4747
#' quarantine = FALSE
4848
#' )
@@ -86,7 +86,7 @@ extinct_prob <- function(outbreak_df_week = NULL, cap_cases = NULL, week_range
8686
#' disp.com = 0.16,
8787
#' disp.iso = 1,
8888
#' onset_to_isolation = \(x) stats::rweibull(n = x, shape = 1.65, scale = 4.28),
89-
#' incfn = \(x) stats::rweibull(n = x, shape = 2.322737, scale = 6.492272),
89+
#' incubation_period = \(x) stats::rweibull(n = x, shape = 2.322737, scale = 6.492272),
9090
#' k = 0,
9191
#' quarantine = FALSE
9292
#' )

R/outbreak_model.R

+10-9
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
#' @param onset_to_isolation a `function`: a random number generating
2525
#' `function` that accepts a single `integer` argument specifying the
2626
#' length of the `function` output.
27-
#' @param incfn a `function`: a random number generating `function` that
28-
#' samples from incubation period distribution, the `function` accepts a
29-
#' single `integer` argument specifying the number of times to sample
30-
#' the incubation period (i.e. length of the `function` output).
27+
#' @param incubation_period a `function`: a random number generating
28+
#' `function` that samples from incubation period distribution, the
29+
#' `function` accepts a single `integer` argument specifying the number of
30+
#' times to sample the incubation period (i.e. length of the `function`
31+
#' output).
3132
#' @param num.initial.cases a nonnegative `integer` scalar: number of initial
3233
#' or starting cases which are all assumed to be missed.
3334
#' @param cap_cases a positive `integer` scalar: number of cumulative cases at
@@ -63,7 +64,7 @@
6364
#' disp.subclin = 0.16,
6465
#' k = 0,
6566
#' onset_to_isolation = \(x) stats::rweibull(n = x, shape = 1.65, scale = 4.28),
66-
#' incfn = \(x) stats::rweibull(n = x, shape = 2.32, scale = 6.49),
67+
#' incubation_period = \(x) stats::rweibull(n = x, shape = 2.32, scale = 6.49),
6768
#' prop.asym = 0,
6869
#' quarantine = FALSE
6970
#' )
@@ -73,8 +74,8 @@ outbreak_model <- function(num.initial.cases = NULL, prop.ascertain = NULL,
7374
r0isolated = NULL, r0community = NULL,
7475
r0subclin = NULL, disp.iso = NULL,
7576
disp.com = NULL, disp.subclin = NULL,
76-
k, onset_to_isolation, incfn, prop.asym = NULL,
77-
quarantine = NULL) {
77+
k, onset_to_isolation, incubation_period,
78+
prop.asym = NULL, quarantine = NULL) {
7879

7980
# Set initial values for loop indices
8081
total.cases <- num.initial.cases
@@ -83,7 +84,7 @@ outbreak_model <- function(num.initial.cases = NULL, prop.ascertain = NULL,
8384

8485
# Initial setup
8586
case_data <- outbreak_setup(num.initial.cases = num.initial.cases,
86-
incfn = incfn,
87+
incubation_period = incubation_period,
8788
prop.asym = prop.asym,
8889
onset_to_isolation = onset_to_isolation,
8990
k = k)
@@ -103,7 +104,7 @@ outbreak_model <- function(num.initial.cases = NULL, prop.ascertain = NULL,
103104
r0isolated = r0isolated,
104105
r0community = r0community,
105106
r0subclin = r0subclin,
106-
incfn = incfn,
107+
incubation_period = incubation_period,
107108
onset_to_isolation = onset_to_isolation,
108109
prop.ascertain = prop.ascertain,
109110
k = k,

R/outbreak_setup.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@
2121
#'
2222
#' @examples
2323
#' # incubation period sampling function
24-
#' incfn <- \(x) stats::rweibull(n = x, shape = 2.32, scale = 6.49)
24+
#' incubation_period <- \(x) stats::rweibull(n = x, shape = 2.32, scale = 6.49)
2525
#' # delay distribution sampling function
2626
#' onset_to_isolation <- \(x) stats::rweibull(n = x, shape = 1.65, scale = 4.28)
2727
#' out <- outbreak_setup(
2828
#' num.initial.cases = 1,
29-
#' incfn = incfn,
29+
#' incubation_period = incubation_period,
3030
#' onset_to_isolation = onset_to_isolation,
3131
#' k = 1.95,
3232
#' prop.asym = 0
3333
#' )
3434
#' out
35-
outbreak_setup <- function(num.initial.cases, incfn, onset_to_isolation, k, prop.asym) {
35+
outbreak_setup <- function(num.initial.cases, incubation_period, onset_to_isolation, k, prop.asym) {
3636
# Set up table of initial cases
37-
inc_samples <- incfn(num.initial.cases)
37+
inc_samples <- incubation_period(num.initial.cases)
3838

3939
case_data <- data.table(exposure = rep(0, num.initial.cases), # Exposure time of 0 for all initial cases
4040
asym = as.logical(rbinom(num.initial.cases, 1, prop.asym)),

R/outbreak_step.R

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
#'
2323
#' @examples
2424
#' # incubation period sampling function
25-
#' incfn <- \(x) stats::rweibull(n = x, shape = 2.32, scale = 6.49)
25+
#' incubation_period <- \(x) stats::rweibull(n = x, shape = 2.32, scale = 6.49)
2626
#' # delay distribution sampling function
2727
#' onset_to_isolation <- \(x) stats::rweibull(n = x, shape = 1.65, scale = 4.28)
2828
#' # generate initial cases
2929
#' case_data <- outbreak_setup(
3030
#' num.initial.cases = 5,
31-
#' incfn = incfn,
31+
#' incubation_period = incubation_period,
3232
#' onset_to_isolation = onset_to_isolation,
3333
#' k = 1.95,
3434
#' prop.asym = 0
@@ -44,7 +44,7 @@
4444
#' r0subclin = 1.25,
4545
#' r0community = 2.5,
4646
#' prop.asym = 0,
47-
#' incfn = incfn,
47+
#' incubation_period = incubation_period,
4848
#' onset_to_isolation = onset_to_isolation,
4949
#' prop.ascertain = 0,
5050
#' k = 1.95,
@@ -54,7 +54,7 @@
5454
#' case_data
5555
outbreak_step <- function(case_data = NULL, disp.iso = NULL, disp.com = NULL,
5656
r0isolated = NULL, r0community = NULL,
57-
prop.asym = NULL, incfn = NULL,
57+
prop.asym = NULL, incubation_period = NULL,
5858
onset_to_isolation = NULL, prop.ascertain = NULL,
5959
k = NULL, quarantine = NULL, r0subclin = NULL,
6060
disp.subclin = NULL) {
@@ -90,7 +90,7 @@ outbreak_step <- function(case_data = NULL, disp.iso = NULL, disp.com = NULL,
9090
}
9191

9292
# Compile a data.table for all new cases, new_cases is the amount of people that each infector has infected
93-
inc_samples <- incfn(total_new_cases)
93+
inc_samples <- incubation_period(total_new_cases)
9494

9595
prob_samples <- data.table(
9696
# time when new cases were exposed, a draw from serial interval based on infector's onset

R/scenario_sim.R

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@
3636
#' disp.com = 0.16,
3737
#' k = 0.7,
3838
#' onset_to_isolation = \(x) stats::rweibull(n = x, shape = 2.5, scale = 5),
39-
#' incfn = \(x) stats::rweibull(n = x, shape = 2.32, scale = 6.49),
39+
#' incubation_period = \(x) stats::rweibull(n = x, shape = 2.32, scale = 6.49),
4040
#' prop.asym = 0,
4141
#' prop.ascertain = 0
4242
#' )
4343
#' res
4444
scenario_sim <- function(n.sim, prop.ascertain, cap_max_days, cap_cases,
4545
r0isolated, r0community, disp.iso, disp.com, k,
46-
onset_to_isolation, incfn, num.initial.cases, prop.asym,
47-
quarantine, r0subclin = NULL, disp.subclin = NULL) {
46+
onset_to_isolation, incubation_period,
47+
num.initial.cases, prop.asym, quarantine,
48+
r0subclin = NULL, disp.subclin = NULL) {
4849

4950
# Set infectiousness of subclinical cases to be equal to clinical cases unless specified otherwise
5051
if(is.null(r0subclin)) {
@@ -66,7 +67,7 @@ scenario_sim <- function(n.sim, prop.ascertain, cap_max_days, cap_cases,
6667
disp.iso = disp.iso,
6768
disp.com = disp.com,
6869
onset_to_isolation = onset_to_isolation,
69-
incfn = incfn,
70+
incubation_period = incubation_period,
7071
k = k,
7172
prop.asym = prop.asym,
7273
quarantine = quarantine))

README.Rmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ res <- scenario_sim(
5656
disp.com = 0.16, ## dispersion parameter in the community
5757
disp.iso = 1, ## dispersion parameter of those isolated
5858
onset_to_isolation = \(x) stats::rweibull(n = x, shape = 1.651524, scale = 4.287786), ## time from onset to isolation
59-
incfn = \(x) stats::rweibull(n = x, shape = 2.322737, scale = 6.492272),
59+
incubation_period = \(x) stats::rweibull(n = x, shape = 2.322737, scale = 6.492272), ## incubation period
6060
k = 0, ## skew of generation interval to be beyond onset of symptoms
6161
quarantine = FALSE ## whether quarantine is in effect
6262
)

man/detect_extinct.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/extinct_prob.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/outbreak_model.Rd

+7-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/outbreak_setup.Rd

+14-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/outbreak_step.Rd

+9-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/scenario_sim.Rd

+7-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)