% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/evaluation.R
\name{eval_brier}
\alias{eval_brier}
\title{IPCW Brier Score and Integrated Brier Score (IBS)}
\usage{
eval_brier(time, event, S_mat, times, tmin = min(times), tmax = max(times))
}
\arguments{
\item{time}{Numeric vector of observed follow-up times.}

\item{event}{Numeric vector of event indicators (1 = event, 0 = censored).}

\item{S_mat}{A numeric matrix of predicted survival probabilities
(rows = observations, columns = time points).}

\item{times}{Numeric vector of evaluation times matching the columns of \code{S_mat}.}

\item{tmin}{Numeric. Lower bound for IBS integration. Defaults to \code{min(times)}.}

\item{tmax}{Numeric. Upper bound for IBS integration. Defaults to \code{max(times)}.}
}
\value{
A list containing:
\itemize{
\item \code{brier_scores}: A numeric vector of Brier scores at each time point.
\item \code{ibs}: The Integrated Brier Score over the range \verb{\code{tmin}, \code{tmax}}.
\item \code{times}: The time grid used.
}
}
\description{
Calculates the Inverse Probability of Censoring Weighted (IPCW) Brier Score
over a grid of times, and computes the Integrated Brier Score (IBS) using
trapezoidal integration.
}
\examples{
data("metabric", package = "SuperSurv")
dat <- metabric[1:40, ]
x_cols <- grep("^x", names(dat))[1:3]
X <- dat[, x_cols, drop = FALSE]
newX <- X[1:10, , drop = FALSE]
times <- seq(50, 150, by = 50)

fit <- surv.coxph(
  time = dat$duration,
  event = dat$event,
  X = X,
  newdata = newX,
  new.times = times,
  obsWeights = rep(1, nrow(dat)),
  id = NULL
)

eval_brier(
  time = dat$duration[1:10],
  event = dat$event[1:10],
  S_mat = fit[["pred"]],
  times = times
)
}
