Skip to contents

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.

Usage

eval_brier(time, event, S_mat, times, tmin = min(times), tmax = max(times))

Arguments

time

Numeric vector of observed follow-up times.

event

Numeric vector of event indicators (1 = event, 0 = censored).

S_mat

A numeric matrix of predicted survival probabilities (rows = observations, columns = time points).

times

Numeric vector of evaluation times matching the columns of S_mat.

tmin

Numeric. Lower bound for IBS integration. Defaults to min(times).

tmax

Numeric. Upper bound for IBS integration. Defaults to max(times).

Value

A list containing:

  • brier_scores: A numeric vector of Brier scores at each time point.

  • ibs: The Integrated Brier Score over the range \code{tmin}, \code{tmax}.

  • times: The time grid used.

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
)
#> $brier_scores
#> [1] 0.08094384 0.23312677 0.24225036
#> 
#> $ibs
#> [1] 0.1973619
#> 
#> $times
#> [1]  50 100 150
#>