R/scn_hmax.R

Defines functions .scn_hmax

#' Maximum quadrature piece length for a scenario
#'
#' Pieces are short enough that the integrands change by a factor of about
#' exp(2) at most within a piece, with at most about 400 pieces over the
#' range of integration.
#'
#' @param scenario An \code{ms_scenario} object.
#' @param span Length of the range of integration.
#' @return Maximum piece length.
#' @noRd
.scn_hmax <- function(scenario, span) {
  lam <- unlist(lapply(list(scenario$control, scenario$treatment), function(x) {
    c(x$prog + x$death + x$dropout + x$switch_pre + x$dropout_pfs,
      x$switch_rate + x$death_prog, x$death_switch,
      x$prog_switch + x$death_switch_pre)
  }))
  max(2 / max(lam, 1e-12), span / 400)
}

Try the DesignComplexSurvival package in your browser

Any scripts or data that you put into this service are public.

DesignComplexSurvival documentation built on Nov. 23, 2026, 5:07 p.m.