Skip to content

Commit

Permalink
Rename 'transmissibility' to 'transmission_rate', WIP #186
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikunterwegs committed Mar 18, 2024
1 parent 826ff4e commit f73c2ce
Show file tree
Hide file tree
Showing 41 changed files with 262 additions and 262 deletions.
20 changes: 10 additions & 10 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' [model_default_cpp()].
#'
#' @param initial_state A matrix for the initial state of the compartments.
#' @param transmissibility The transmission rate \eqn{\beta} at which
#' @param transmission_rate The transmission rate \eqn{\beta} at which
#' unvaccinated and partially vaccinated individuals are infected by the
#' disease.
#' @param infectiousness_rate The rate of transition from exposed to infectious
Expand All @@ -35,8 +35,8 @@
#' as specified in the initial conditions matrix (see [population()]).
#' The second list element is a vector of timesteps.
#' @keywords internal
.model_default_cpp <- function(initial_state, transmissibility, infectiousness_rate, recovery_rate, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end = 100.0, increment = 1.0) {
.Call(`_epidemics_model_default_internal`, initial_state, transmissibility, infectiousness_rate, recovery_rate, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end, increment)
.model_default_cpp <- function(initial_state, transmission_rate, infectiousness_rate, recovery_rate, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end = 100.0, increment = 1.0) {
.Call(`_epidemics_model_default_internal`, initial_state, transmission_rate, infectiousness_rate, recovery_rate, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end, increment)
}

#' @title Run an SEIHR ODE model for diphtheria using a Boost solver
Expand All @@ -49,7 +49,7 @@
#' [model_diphtheria_cpp()].
#'
#' @param initial_state A matrix for the initial state of the compartments.
#' @param transmissibility The transmission rate \eqn{\beta}.
#' @param transmission_rate The transmission rate \eqn{\beta}.
#' @param infectiousness_rate The rate of transition from exposed to infectious
#' \eqn{\alpha}.
#' @param recovery_rate The recovery rate \eqn{\gamma}.
Expand All @@ -73,8 +73,8 @@
#' as specified in the initial conditions matrix.
#' The second list element is a vector of timesteps.
#' @keywords internal
.model_diphtheria_cpp <- function(initial_state, transmissibility, infectiousness_rate, recovery_rate, reporting_rate, prop_hosp, hosp_entry_rate, hosp_exit_rate, rate_interventions, time_dependence, pop_change_times, pop_change_values, time_end = 100.0, increment = 1.0) {
.Call(`_epidemics_model_diphtheria_internal`, initial_state, transmissibility, infectiousness_rate, recovery_rate, reporting_rate, prop_hosp, hosp_entry_rate, hosp_exit_rate, rate_interventions, time_dependence, pop_change_times, pop_change_values, time_end, increment)
.model_diphtheria_cpp <- function(initial_state, transmission_rate, infectiousness_rate, recovery_rate, reporting_rate, prop_hosp, hosp_entry_rate, hosp_exit_rate, rate_interventions, time_dependence, pop_change_times, pop_change_values, time_end = 100.0, increment = 1.0) {
.Call(`_epidemics_model_diphtheria_internal`, initial_state, transmission_rate, infectiousness_rate, recovery_rate, reporting_rate, prop_hosp, hosp_entry_rate, hosp_exit_rate, rate_interventions, time_dependence, pop_change_times, pop_change_values, time_end, increment)
}

#' @title Run the RIVM Vacamole model
Expand All @@ -90,10 +90,10 @@
#' [model_vacamole_cpp()].
#'
#' @param initial_state A matrix for the initial state of the compartments.
#' @param transmissibility The transmission rate \eqn{\beta} at which
#' @param transmission_rate The transmission rate \eqn{\beta} at which
#' unvaccinated and partially vaccinated individuals are infected by the
#' disease.
#' @param transmissibility_vax The transmission rate \eqn{\beta_V} at which
#' @param transmission_rate_vax The transmission rate \eqn{\beta_V} at which
#' individuals who have received two vaccine doses are infected by the disease.
#' @param infectiousness_rate The rate of transition from exposed to infectious
#' \eqn{\alpha}.
Expand Down Expand Up @@ -127,7 +127,7 @@
#' as specified in the initial conditions matrix (see [population()]).
#' The second list element is a vector of timesteps.
#' @keywords internal
.model_vacamole_cpp <- function(initial_state, transmissibility, transmissibility_vax, infectiousness_rate, mortality_rate, mortality_rate_vax, hospitalisation_rate, hospitalisation_rate_vax, recovery_rate, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end = 100.0, increment = 1.0) {
.Call(`_epidemics_model_vacamole_internal`, initial_state, transmissibility, transmissibility_vax, infectiousness_rate, mortality_rate, mortality_rate_vax, hospitalisation_rate, hospitalisation_rate_vax, recovery_rate, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end, increment)
.model_vacamole_cpp <- function(initial_state, transmission_rate, transmission_rate_vax, infectiousness_rate, mortality_rate, mortality_rate_vax, hospitalisation_rate, hospitalisation_rate_vax, recovery_rate, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end = 100.0, increment = 1.0) {
.Call(`_epidemics_model_vacamole_internal`, initial_state, transmission_rate, transmission_rate_vax, infectiousness_rate, mortality_rate, mortality_rate_vax, hospitalisation_rate, hospitalisation_rate_vax, recovery_rate, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end, increment)
}

4 changes: 2 additions & 2 deletions R/check_args_default.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' - `initial_state`: the initial conditions modified to represent absolute
#' rather than proportional values;
#'
#' - `transmissibility`, `infectiousness_rate`, `recovery_rate`: three numbers
#' - `transmission_rate`, `infectiousness_rate`, `recovery_rate`: three numbers
#' representing the transmission rate of the infection, the rate of transition
#' from exposed to infectious, and the recovery rate, respectively;
#'
Expand Down Expand Up @@ -50,7 +50,7 @@
# check the interventions list against the population
mod_args[["intervention"]] <- .cross_check_intervention(
mod_args[["intervention"]], mod_args[["population"]],
c("contacts", "transmissibility", "infectiousness_rate", "recovery_rate")
c("contacts", "transmission_rate", "infectiousness_rate", "recovery_rate")
)
# check the vaccination against the population
mod_args[["vaccination"]] <- .cross_check_vaccination(
Expand Down
4 changes: 2 additions & 2 deletions R/check_args_diphtheria.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' - `initial_state`: the initial conditions modified to represent absolute
#' rather than proportional values;
#'
#' - `transmissibility`, `transmissibility_vax`: two numbers representing the
#' - `transmission_rate`, `transmission_rate_vax`: two numbers representing the
#' transmission rate
#' of the infection for unvaccinated or single-dose vaccinated, and two-dose
#' vaccinated individuals, respectively;
Expand Down Expand Up @@ -84,7 +84,7 @@
mod_args[["intervention"]] <- .cross_check_intervention(
mod_args[["intervention"]], mod_args[["population"]],
c(
"transmissibility", "infectiousness_rate", "prop_hosp",
"transmission_rate", "infectiousness_rate", "prop_hosp",
"hosp_entry_rate", "hosp_exit_rate", "recovery_rate"
)
)
Expand Down
4 changes: 2 additions & 2 deletions R/check_args_vacamole.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' - `initial_state`: the initial conditions modified to represent absolute
#' rather than proportional values;
#'
#' - `transmissibility`, `transmissibility_vax`: two numbers representing the
#' - `transmission_rate`, `transmission_rate_vax`: two numbers representing the
#' transmission rate
#' of the infection for unvaccinated or single-dose vaccinated, and two-dose
#' vaccinated individuals, respectively;
Expand Down Expand Up @@ -63,7 +63,7 @@
# check the interventions list against the population
mod_args[["intervention"]] <- .cross_check_intervention(
mod_args[["intervention"]], mod_args[["population"]],
c("contacts", "transmissibility", "infectiousness_rate", "recovery_rate")
c("contacts", "transmission_rate", "infectiousness_rate", "recovery_rate")
)
# check the vaccination against the population
mod_args[["vaccination"]] <- .cross_check_vaccination(
Expand Down
6 changes: 3 additions & 3 deletions R/dummy_elements.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#' Specify no time dependence of model rates
#'
#' @param func_target A string for the parameter to be targeted. Defaults to the
#' transmissibility parameter.
#' @return A list with a single named element, `transmissibility`, which is a
#' transmission rate parameter.
#' @return A list with a single named element, `transmission_rate`, which is a
#' function that returns its second argument. This matches the specification for
#' functions to be passed as the `time_dependence` argument of epidemic
#' functions.
#' @noRd
#' @keywords internal
.no_time_dependence <- function(func_target = "transmissibility") {
.no_time_dependence <- function(func_target = "transmission_rate") {
l <- list(
function(time, x) x
)
Expand Down
22 changes: 11 additions & 11 deletions R/model_default.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' This model can accommodate heterogeneity in social contacts among demographic
#' groups, as well as differences in the sizes of demographic groups.
#'
#' The `population`, `transmissibility`, `infectiousness_rate`, and
#' The `population`, `transmission_rate`, `infectiousness_rate`, and
#' `recovery_rate`
#' arguments are mandatory, while passing an `intervention` and `vaccination`
#' are optional and can be used to simulate scenarios with different epidemic
Expand All @@ -19,7 +19,7 @@
#' @param population An object of the `population` class, which holds a
#' population contact matrix, a demography vector, and the initial conditions
#' of each demographic group. See [population()].
#' @param transmissibility A numeric for the rate at which individuals
#' @param transmission_rate A numeric for the rate at which individuals
#' move from the susceptible to the exposed compartment upon contact with an
#' infectious individual. Often denoted as \eqn{\beta}, with
#' \eqn{\beta = R_0 / \text{infectious period}}. See **Details** for default
Expand Down Expand Up @@ -67,7 +67,7 @@
#'
#' The default values are:
#'
#' - Transmissibility (\eqn{\beta}, `transmissibility`): 0.186, assuming an
#' - Transmission rate (\eqn{\beta}, `transmission_rate`): 0.186, assuming an
#' \eqn{R_0} = 1.3 and an infectious period of 7 days.
#'
#' - Infectiousness rate (\eqn{\sigma}, `infectiousness_rate`): 0.5, assuming
Expand Down Expand Up @@ -102,10 +102,10 @@
#' )
#'
#' # run epidemic simulation with no vaccination or intervention
#' # and three discrete values of transmissibility
#' # and three discrete values of transmission rate
#' data <- model_default(
#' population = uk_population,
#' transmissibility = c(1.3, 1.4, 1.5) / 7.0, # uncertainty in R0
#' transmission_rate = c(1.3, 1.4, 1.5) / 7.0, # uncertainty in R0
#' )
#'
#' # view some data
Expand All @@ -121,7 +121,7 @@
#' data
#' @export
model_default <- function(population,
transmissibility = 1.3 / 7.0,
transmission_rate = 1.3 / 7.0,
infectiousness_rate = 1.0 / 2.0,
recovery_rate = 1.0 / 7.0,
intervention = NULL,
Expand All @@ -136,7 +136,7 @@ model_default <- function(population,
assert_population(population, compartments)

# NOTE: model rates very likely bounded 0 - 1 but no upper limit set for now
checkmate::assert_numeric(transmissibility, lower = 0, finite = TRUE)
checkmate::assert_numeric(transmission_rate, lower = 0, finite = TRUE)
checkmate::assert_numeric(infectiousness_rate, lower = 0, finite = TRUE)
checkmate::assert_numeric(recovery_rate, lower = 0, finite = TRUE)
checkmate::assert_integerish(time_end, lower = 0)
Expand All @@ -148,7 +148,7 @@ model_default <- function(population,

# check all vector lengths are equal or 1L
params <- list(
transmissibility = transmissibility,
transmission_rate = transmission_rate,
infectiousness_rate = infectiousness_rate,
recovery_rate = recovery_rate,
time_end = time_end
Expand Down Expand Up @@ -221,7 +221,7 @@ model_default <- function(population,
time_dependence <- list(
.cross_check_timedep(
time_dependence,
c("transmissibility", "infectiousness_rate", "recovery_rate")
c("transmission_rate", "infectiousness_rate", "recovery_rate")
)
)

Expand Down Expand Up @@ -310,7 +310,7 @@ model_default <- function(population,
# `params` refers to the list passed as a function argument.
# e.g. contact matrix, or interventions, are not included in `model_params`
model_params <- params[c(
"transmissibility", "infectiousness_rate", "recovery_rate"
"transmission_rate", "infectiousness_rate", "recovery_rate"
)]

# apply time dependence before interventions
Expand Down Expand Up @@ -338,7 +338,7 @@ model_default <- function(population,
(params[["vax_time_end"]] > t))

# calculate transitions
sToE <- (model_params[["transmissibility"]] * y[, 1] *
sToE <- (model_params[["transmission_rate"]] * y[, 1] *
contact_matrix_ %*% y[, 3])
eToI <- model_params[["infectiousness_rate"]] * y[, 2]
iToR <- model_params[["recovery_rate"]] * y[, 3]
Expand Down
12 changes: 6 additions & 6 deletions R/model_diphtheria.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
#'
#' The default values are taken from Finger et al. (2019) where possible:
#'
#' - Transmissibility (\eqn{\beta}, `transmissibility`): 0.8888889, assuming an
#' \eqn{R_0} of 4.0 and a total infectious period of 4.5 days.
#' - Transmission rate (\eqn{\beta}, `transmission_rate`): 0.8888889, assuming
#' an \eqn{R_0} of 4.0 and a total infectious period of 4.5 days.
#'
#' - Infectiousness rate (\eqn{\sigma}, `infectiousness_rate`): 0.333, assuming
#' a pre-infectious period of 3 days.
Expand Down Expand Up @@ -145,7 +145,7 @@
#' tail(data)
#' @export
model_diphtheria <- function(population,
transmissibility = 4.0 / 4.5,
transmission_rate = 4.0 / 4.5,
infectiousness_rate = 1.0 / 3.0,
recovery_rate = 1.0 / 3.0,
reporting_rate = 0.03,
Expand All @@ -166,7 +166,7 @@ model_diphtheria <- function(population,
assert_population(population, compartments)

# NOTE: model rates very likely bounded 0 - 1 but no upper limit set for now
checkmate::assert_numeric(transmissibility, lower = 0, finite = TRUE)
checkmate::assert_numeric(transmission_rate, lower = 0, finite = TRUE)
checkmate::assert_numeric(infectiousness_rate, lower = 0, finite = TRUE)
checkmate::assert_numeric(recovery_rate, lower = 0, finite = TRUE)
# reporting rate and prop_hosp are expected to be proportions bounded 0 - 1
Expand All @@ -184,7 +184,7 @@ model_diphtheria <- function(population,

# check all vector lengths are equal or 1L
params <- list(
transmissibility = transmissibility,
transmission_rate = transmission_rate,
infectiousness_rate = infectiousness_rate,
recovery_rate = recovery_rate,
reporting_rate = reporting_rate,
Expand Down Expand Up @@ -258,7 +258,7 @@ model_diphtheria <- function(population,
.cross_check_timedep(
time_dependence,
c(
"transmissibility", "infectiousness_rate", "prop_hosp",
"transmission_rate", "infectiousness_rate", "prop_hosp",
"reporting_rate", "hosp_entry_rate", "hosp_exit_rate", "recovery_rate"
)
)
Expand Down
Loading

0 comments on commit f73c2ce

Please sign in to comment.