Skip to content

Commit

Permalink
generalise comments in calc_network_R
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlambert committed Jan 23, 2024
1 parent a11ce36 commit 46081af
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions R/calc_network_R.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,22 @@ calc_network_R <- function(mean_num_contact,
checkmate::assert_number(prob_transmission, lower = 0, finite = TRUE)
checkmate::assert_numeric(age_range, len = 2, lower = 0, finite = TRUE)

# define measured sexual contacts
# normalise by years sexually active
# define measured contacts (e.g. sexual contacts)
# normalise by time active in the network (e.g. sexually active)
scale_by_active <- 1 / (max(age_range) - min(age_range))
# calculate new partners per year
contacts_per_year <- c(
# calculate new partners per time
contacts_per_time <- c(
mean = mean_num_contact * scale_by_active,
var = sd_num_contact^2 * scale_by_active^2
)

beta <- prob_transmission

# calculate R0 with and without correction
R <- beta * contacts_per_year[["mean"]] * infect_duration
R <- beta * contacts_per_time[["mean"]] * infect_duration
R_var <- beta * infect_duration *
(contacts_per_year[["mean"]] + contacts_per_year[["var"]] /
contacts_per_year[["mean"]])
(contacts_per_time[["mean"]] + contacts_per_time[["var"]] /
contacts_per_time[["mean"]])

# return R0 with and without variance correction
c(R = R, R_var = R_var)
Expand Down

0 comments on commit 46081af

Please sign in to comment.