% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rmst.R
\name{plot_rmst_vs_obs}
\alias{plot_rmst_vs_obs}
\title{Plot Predicted RMST vs. Observed Survival Times}
\usage{
plot_rmst_vs_obs(fit, data, time_col, event_col, times, tau)
}
\arguments{
\item{fit}{A fitted \code{SuperSurv} ensemble object.}

\item{data}{A \code{data.frame} containing the patient covariates, times, and events.}

\item{time_col}{Character string. The exact name of the observed follow-up time column in \code{data}.}

\item{event_col}{Character string. The exact name of the event indicator column in \code{data} (e.g., 1 for event, 0 for censored).}

\item{times}{Numeric vector of time points matching the prediction grid.}

\item{tau}{Numeric. A single truncation time limit up to which the RMST is calculated.}
}
\value{
A \code{ggplot} object comparing predicted RMST to observed outcomes.
}
\description{
Evaluates the calibration of the causal RMST estimator by plotting the model's
predicted RMST for each patient against their actual observed follow-up time.
}
\examples{
data("metabric", package = "SuperSurv")
dat <- metabric[1:80, ]
x_cols <- grep("^x", names(dat))[1:5]
X <- dat[, x_cols, 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.glmnet"),
  cens.library = c("surv.coxph"),
  control = list(saveFitLibrary = TRUE)
)

plot_rmst_vs_obs(
  fit = fit,
  data = dat,
  time_col = "duration",
  event_col = "event",
  times = new.times,
  tau = 350
)
}
