Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infect dist #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions R/get_infect_mat.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
14 changes: 8 additions & 6 deletions R/get_prop_infect_time.R
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
#'
#' 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.
#' @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)
}
Expand Down
4 changes: 2 additions & 2 deletions R/get_r_effective_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions man/get_infect_mat.Rd

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

2 changes: 1 addition & 1 deletion man/get_prop_infect_time.Rd

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

6 changes: 3 additions & 3 deletions man/get_r_effective_df.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/test-get_r_effective.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-get_r_effective_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down