% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/predict.SuperSurv.R
\name{predict.SuperSurv}
\alias{predict.SuperSurv}
\title{Predict method for SuperSurv fits}
\usage{
\method{predict}{SuperSurv}(
  object,
  newdata,
  new.times,
  type = c("both", "event", "censoring"),
  onlySL = FALSE,
  threshold = 1e-04,
  ...
)
}
\arguments{
\item{object}{A fitted object of class \code{SuperSurv}.}

\item{newdata}{A data.frame of new covariate values.}

\item{new.times}{A numeric vector of times at which to predict survival.}

\item{type}{Character string specifying the prediction output. Use
\code{"event"} for the event survival matrix, \code{"censoring"} for the
censoring survival matrix, or \code{"both"} for the full list of outputs.}

\item{onlySL}{Logical. If TRUE, only uses models with weights > threshold.}

\item{threshold}{Numeric. The weight threshold for onlySL.}

\item{...}{Additional ignored arguments.}
}
\value{
If \code{type = "event"} or \code{type = "censoring"}, a numeric
matrix with rows corresponding to observations and columns corresponding to
\code{new.times}. If \code{type = "both"}, a list containing:
\itemize{
\item \code{event.predict}: A numeric matrix of final event survival predictions.
\item \code{event.library.predict}: A 3D numeric array of event learner predictions.
\item \code{cens.predict}: A numeric matrix of final censoring survival predictions.
\item \code{cens.library.predict}: A 3D numeric array of censoring learner predictions.
}
}
\description{
Obtains predicted survival probabilities from a fitted SuperSurv ensemble.
}
\examples{
if (requireNamespace("glmnet", quietly = TRUE)) {
  data("metabric", package = "SuperSurv")
  dat <- metabric[1:80, ]
  x_cols <- grep("^x", names(dat))[1:5]
  X <- dat[, x_cols, drop = FALSE]
  newX <- X[1:10, , drop = FALSE]
  new.times <- seq(20, 120, by = 20)

  fit <- SuperSurv(
    time = dat$duration,
    event = dat$event,
    X = X,
    newdata = X,
    new.times = new.times,
    event.library = c("surv.coxph", "surv.ridge"),
    cens.library = c("surv.coxph"),
    control = list(saveFitLibrary = TRUE)
  )

  pred_event <- predict(
    object = fit,
    newdata = newX,
    new.times = new.times,
    type = "event"
  )

  dim(pred_event)
}
}
