Skip to content

EpiModelHIV ‐ code conventions

Adrien Le Guillou edited this page Dec 13, 2024 · 4 revisions

Work In Progress

Module Structure

new_module <- function(dat, at) {
  ##Inputs
  # Attributes
  an.attribute <- get_attr(dat, "an.attribute")

  # Parameters
  a.param <- get_param(dat, "a.param")

  ## Process
  an.attribute <- an.attribute + a.param

  ## Output
  # Attributes
  dat <- set_attr(dat, "an.attribute", an.attribute)

  # Epi Trackers
  dat <- set_epi(dat, "high.attributes", at, an.attribute > 10)

  return(dat)
}

Naming

  • parameters are lower.dot.case
  • attributes are lower.dot.case
  • variables in a module are lower_snake_case
  • functions are lower_snake_case

Name conventions

Try to follow the below example:

new disease xyz

  • xyz: 0-1; presence of the disease

  • xyz.tx: 0-1; presence of treatment for xyz`

  • xyz.dx: 0-1; xyz` diagnosed

  • xyz.sympt: 0-1; xyz` with symptoms

  • xyz.count: 0-Inf; number of time infected by xyz`

  • xyz.tst.last: time step; last time xyz was testd

  • xyz.dx.last: time step; last time xyz was diagnosed

  • xyz.stage: 0-N; stage of xyz

  • xyz.prob: [0, 1]; probability of getting xyz

  • xyz.tx.int: 0-N; duration of xyz treatment in timestep

  • xyz.sympt.prob: [0, 1]; probability of having xyz symptoms