R/predictProb.coxnet.R

Defines functions predictProb.coxnet

Documented in predictProb.coxnet

predictProb.coxnet <- function(object, response, x, times, complexity = NULL, ...) {
   .require_suggested_package("glmnet", "predictProb.coxnet()")

   context <- .peperr_training_context(object, "predictProb.coxnet()")
   lambda <- .peperr_complexity_value(
      complexity = complexity,
      default = attr(object, "peperr_lambda"),
      caller = "predictProb.coxnet()"
   )

   survfit.object <- survival::survfit(
      object,
      s = lambda,
      x = context$x,
      y = survival::Surv(context$response[, "time"], context$response[, "status"]),
      newx = as.matrix(x),
      ...
   )

   .peperr_survfit_to_matrix(
      survfit_object = survfit.object,
      times = times,
      nobs = nrow(x)
   )
}

Try the peperr package in your browser

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

peperr documentation built on March 25, 2026, 9:06 a.m.