From 04b26c4e964ffb9fd50d616b1d0085ff2486cacc Mon Sep 17 00:00:00 2001 From: Kyra Grantz Date: Tue, 5 Jan 2021 21:53:55 -0500 Subject: [PATCH 1/3] adding offset to g(x) dist, changing shape, rate, offset defaults --- R/get_infect_mat.R | 14 +++++++------- R/get_prop_infect_time.R | 4 ++-- R/get_r_effective_df.R | 4 ++-- man/get_infect_mat.Rd | 6 +++--- man/get_prop_infect_time.Rd | 2 +- man/get_r_effective_df.Rd | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/R/get_infect_mat.R b/R/get_infect_mat.R index f13b906..83583f6 100755 --- a/R/get_infect_mat.R +++ b/R/get_infect_mat.R @@ -43,8 +43,8 @@ #' @export get_infect_mat <- function(alpha = 0.2, R = 2.5, kappa = 0.5, eta = 0.5, nu = 4, t_ds = 3, t_da = 3, t_qcs = 3, t_qca = 3, t_qhs = 3, - t_qha = 3, t_q = 3, t_incubation = 5.5, offset = -2.31, - shape = 1.65, rate = 0.5) { + t_qha = 3, t_q = 3, t_incubation = 5.5, offset = -12.27, + shape = 21.13, rate = 1.592) { is_probability(alpha) is_probability(eta) is_positive(R) @@ -70,23 +70,23 @@ get_infect_mat <- function(alpha = 0.2, R = 2.5, kappa = 0.5, eta = 0.5, nu = 4, gamma_qcs <- get_prop_infect_time( t_qcs, - shape = second_gen_shape, rate = rate, offset = 0 + shape = second_gen_shape, rate = rate, offset = offset ) gamma_qca <- get_prop_infect_time( t_qca, - shape = second_gen_shape, rate = rate, offset = 0 + shape = second_gen_shape, rate = rate, offset = offset ) gamma_qhs <- get_prop_infect_time( t_qhs, - shape = second_gen_shape, rate = rate, offset = 0 + shape = second_gen_shape, rate = rate, offset = offset ) gamma_qha <- get_prop_infect_time( t_qha, - shape = second_gen_shape, rate = rate, offset = 0 + shape = second_gen_shape, rate = rate, offset = offset ) gamma_q <- get_prop_infect_time( t_q, - shape = second_gen_shape, rate = rate, offset = 0 + shape = second_gen_shape, rate = rate, offset = offset ) R_s <- R / ((alpha * kappa) - alpha + 1) diff --git a/R/get_prop_infect_time.R b/R/get_prop_infect_time.R index e775e2d..f8f23fd 100644 --- a/R/get_prop_infect_time.R +++ b/R/get_prop_infect_time.R @@ -15,8 +15,8 @@ #' @return Numeric. Proportion of infectious period reduced given the #' distribution of infectiousness and time from symptom onset to isolation. #' @export -get_prop_infect_time <- function(delay, offset = -2.31, - shape = 1.65, rate = 0.5) { +get_prop_infect_time <- function(delay, offset = -12.27, + shape = 21.13, rate = 1.592) { if (delay < offset) { return(0) } diff --git a/R/get_r_effective_df.R b/R/get_r_effective_df.R index 053b02d..0d22190 100644 --- a/R/get_r_effective_df.R +++ b/R/get_r_effective_df.R @@ -98,8 +98,8 @@ get_r_effective_df <- function(alpha = 0.2, R = 2.5, kappa = 0.5, eta = 0.5, nu omega_h = 0.5, omega_q = 0.5, quarantine_days = Inf, - rho_s = 0.1, rho_a = 0.05, offset = -2.31, - shape = 1.65, rate = 0.5, + rho_s = 0.1, rho_a = 0.05, offset = -12.27, + shape = 21.13, rate = 1.592, stoch = FALSE, theta = NULL, n_inf = NULL, n_iter = NULL) { if (length(n_iter) > 1 | length(stoch) > 1) { stop_glue( diff --git a/man/get_infect_mat.Rd b/man/get_infect_mat.Rd index 35b69de..07b217c 100755 --- a/man/get_infect_mat.Rd +++ b/man/get_infect_mat.Rd @@ -18,9 +18,9 @@ get_infect_mat( t_qha = 3, t_q = 3, t_incubation = 5.5, - offset = -2.31, - shape = 1.65, - rate = 0.5 + offset = -12.27, + shape = 21.13, + rate = 1.592 ) } \arguments{ diff --git a/man/get_prop_infect_time.Rd b/man/get_prop_infect_time.Rd index 88eba4e..02b3e49 100644 --- a/man/get_prop_infect_time.Rd +++ b/man/get_prop_infect_time.Rd @@ -4,7 +4,7 @@ \alias{get_prop_infect_time} \title{Calculate proportion of the infectious period reduced} \usage{ -get_prop_infect_time(delay, offset = -2.31, shape = 1.65, rate = 0.5) +get_prop_infect_time(delay, offset = -12.27, shape = 21.13, rate = 1.592) } \arguments{ \item{delay}{Numeric greater than 0. Time from symptom onset to isolation} diff --git a/man/get_r_effective_df.Rd b/man/get_r_effective_df.Rd index f2852dc..ec945f8 100755 --- a/man/get_r_effective_df.Rd +++ b/man/get_r_effective_df.Rd @@ -23,9 +23,9 @@ get_r_effective_df( quarantine_days = Inf, rho_s = 0.1, rho_a = 0.05, - offset = -2.31, - shape = 1.65, - rate = 0.5, + offset = -12.27, + shape = 21.13, + rate = 1.592, stoch = FALSE, theta = NULL, n_inf = NULL, From 884e25ff0d7bd3e898f10df06fbf307a627bd880 Mon Sep 17 00:00:00 2001 From: Kyra Grantz Date: Tue, 5 Jan 2021 21:59:52 -0500 Subject: [PATCH 2/3] updating tests for new default infectiousness dist --- tests/testthat/test-get_r_effective.R | 2 +- tests/testthat/test-get_r_effective_df.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-get_r_effective.R b/tests/testthat/test-get_r_effective.R index d6ce97d..9eeda92 100644 --- a/tests/testthat/test-get_r_effective.R +++ b/tests/testthat/test-get_r_effective.R @@ -156,7 +156,7 @@ test_that("get_r_effective works, change incubation", { }) test_that("get_r_effective works, change shape of gamma", { - param <- 4 + param <- 30 dqc <- c( Ds = 0.2, Da = 0.1, Qcds = 0.1, Qhds = 0.1, Qcda = 0.1, Qhda = 0.1, Qq = 0.15, Cs = 0.1, Ca = 0.05 diff --git a/tests/testthat/test-get_r_effective_df.R b/tests/testthat/test-get_r_effective_df.R index fc1282a..57dde0f 100644 --- a/tests/testthat/test-get_r_effective_df.R +++ b/tests/testthat/test-get_r_effective_df.R @@ -2,7 +2,7 @@ test_that("get_r_effective_df works", { r <- get_r_effective_df(quarantine_days = Inf) expect_equal(nrow(r), 1) expect_equal(ncol(r), 20) - expect_equal(round(r$r_effective, 3), 2.362) + expect_equal(round(r$r_effective, 3), 2.359) }) test_that("get_r_effective_df works with stochastic arguments", { From ef24c764b224573e3330cf9d877afd93ce670f7d Mon Sep 17 00:00:00 2001 From: eclee25 Date: Thu, 7 Jan 2021 14:42:45 -0500 Subject: [PATCH 3/3] fix documentation --- R/get_prop_infect_time.R | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) mode change 100644 => 100755 R/get_prop_infect_time.R diff --git a/R/get_prop_infect_time.R b/R/get_prop_infect_time.R old mode 100644 new mode 100755 index f8f23fd..9064b4a --- a/R/get_prop_infect_time.R +++ b/R/get_prop_infect_time.R @@ -2,15 +2,17 @@ #' #' Calculates the proportion of the infections period reduced given the #' distribution of infectiousness and time from symptom onset to isolation. -#' Infectious period is assumed to be gamma distributed. +#' Infectious period is assumed to be gamma distributed. Defaults derived +#' from a correction of He et al. (2020) where the incubation period was +#' assumed to be 5.5 days and the generation time 6.5 days. #' #' @param delay Numeric greater than 0. Time from symptom onset to isolation #' @param offset Numeric. Offset of infectiousness compared to symptom onset. -#' Default is -2.31. +#' Default is -12.27. #' @param shape Numeric. Shape of the gamma distribution of infectious period. -#' Default is 1.65. +#' Default is 21.13. #' @param rate Numeric. Rate of the gamma distribution of infectious period. -#' Default is 0.5. +#' Default is 1.592. #' #' @return Numeric. Proportion of infectious period reduced given the #' distribution of infectiousness and time from symptom onset to isolation.