% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/visualization.R
\name{plot_calibration}
\alias{plot_calibration}
\title{Plot Survival Calibration Curve}
\usage{
plot_calibration(object, newdata, time, event, eval_time, bins = 5)
}
\arguments{
\item{object}{A fitted SuperSurv object OR a standalone base learner.}

\item{newdata}{A data.frame of test covariates.}

\item{time}{Numeric vector of observed follow-up times for the test set.}

\item{event}{Numeric vector of event indicators for the test set.}

\item{eval_time}{Numeric. A single time point at which to assess calibration.}

\item{bins}{Integer. Defaults to 5.}
}
\value{
A ggplot object.
}
\description{
Plot Survival Calibration Curve
}
\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)
  )

  plot_calibration(
    object = fit,
    newdata = X,
    time = dat$duration,
    event = dat$event,
    eval_time = 100,
    bins = 4
  )
}
}
