Skip to content

Commit

Permalink
Initial implementation of ebola args checker, WIP #173
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikunterwegs committed Apr 15, 2024
1 parent f43e022 commit 49d4be9
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions R/check_args_ebola.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#' @title Prepare arguments to ebola model function
#' @name prepare_ebola_args
#' @rdname prepare_ebola_args
#'
#' @description Prepare arguments to [model_ebola()] for
#' [.model_ebola_internal()].
#'
#' @param mod_args A named list of composable elements; must include a
#' `<population>`.
#'
#' @return
#' A list of model arguments suitable for [.model_ebola_internal()].
#' This is a named list consisting of:
#'
#' **WIP**
#'
#' @keywords internal
#' @details
#' `.check_prepare_args_ebola()` prepares arguments for
#' [.model_ebola_internal()], by converting some of the arguments
#' collected in `mod_args` into simpler structures that are appropriate for the
#' internal model function.
.check_prepare_args_ebola <- function(mod_args) {
# prepare the initial conditions; accessed from prepared list
# NOTE: round to integer as this is a discrete-time model
initial_state <- round(
.prepare_population(
mod_args[["population"]]
)[["initial_state"]]
)

# check that rate interventions are on allowed targets
# NOTE: type `<rate_intervention>` is already checked at top level
# NOTE: `infectiousness_rate` and `removal_rate` are not allowed as they
# control the number of epidemiological sub-compartments, which cannot be
# safely changed while the model is running
intervention <- .cross_check_intervention(
mod_args[["intervention"]], mod_args[["population"]],
c(
"transmission_rate", "prop_community", "etu_risk", "funeral_risk"
)
)

# extract and provide time_dependence
time_dependence <- mod_args[["time_dependence"]]

# return selected arguments for internal function
list(
initial_state = initial_state,
intervention = intervention, # keep consistent naming
time_dependence = time_dependence
)
}

0 comments on commit 49d4be9

Please sign in to comment.