# Receptor occupancy and IGF-1 biomarker. See model-spec.md Section 4.

#' Fractional receptor occupancy from a saturable binding function, reusing
#' the PK model's own Km as the effective affinity constant (QSS-TMDD
#' convention) rather than introducing an independent, unfit Kd.
occupancy <- function(C, Km) {
  C / (C + Km)
}

#' Indirect-response derivative for free IGF-1: receptor blockade lowers
#' receptor-mediated consumption, raising steady-state IGF-1 up to
#' (1 / (1 - Imax))-fold over baseline.
igf1_deriv <- function(IGF1, occ, kin, kout, Imax) {
  kin - kout * (1 - Imax * occ) * IGF1
}
