% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/visualization.R
\name{plot_predict}
\alias{plot_predict}
\title{Plot Predicted Survival Curves}
\usage{
plot_predict(preds, eval_times, patient_idx = 1)
}
\arguments{
\item{preds}{A list containing SuperSurv predictions OR a raw prediction matrix.}

\item{eval_times}{Numeric vector of times at which predictions were evaluated.}

\item{patient_idx}{Integer vector. Defaults to 1.}
}
\value{
A ggplot object.
}
\description{
Plot Predicted Survival Curves
}
\examples{
if (requireNamespace("glmnet", quietly = TRUE)) {
  data("metabric", package = "SuperSurv")
  dat <- metabric[1:120, ]
  x_cols <- grep("^x", names(dat))[1:5]
  X <- dat[, x_cols, drop = FALSE]
  eval_times <- seq(20, 120, by = 20)

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

  preds <- predict(fit, newdata = X, new.times = eval_times, type = "event")

  plot_predict(
    preds = preds,
    eval_times = eval_times,
    patient_idx = c(1, 2)
  )
}
}
