R/acc_cum.R

Defines functions .acc_cum

#' Enrolled fraction at calendar times (vectorized)
#'
#' Vectorized version of \code{.acc_frac()}: the fraction of the sample size
#' enrolled by each calendar time in \code{x} (0 for negative times).
#'
#' @param acc Output of \code{.acc_setup()}.
#' @param x Calendar times.
#' @return A numeric vector.
#' @noRd
.acc_cum <- function(acc, x) {
  nx <- length(x)
  if (nx == 0L) {
    return(numeric(0))
  }
  a <- acc$alpha
  lo <- a[-length(a)]
  len <- diff(a)
  d <- outer(x, lo, "-")
  d <- pmin(pmax(d, 0), matrix(len, nrow = nx, ncol = length(len), byrow = TRUE))
  as.vector(d %*% acc$rho)
}

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.