Skip to contents

brier_score() gives the inverse-probability-of-censoring weighted (Graf) Brier score at each time, the mean squared difference between the predicted survival probability and the observed status. At time \(t\), a subject with an event by \(t\) contributes \(\hat S_i(t)^2 / G(T_i-)\) and one still under observation after \(t\) contributes \((1 - \hat S_i(t))^2 / G(t-)\), where \(G\) is the Kaplan-Meier estimate of the censoring distribution. Subjects censored by \(t\) contribute 0, and the sum is divided by the number of subjects. Lower is better. Predicting 0.5 for everyone gives 0.25.

Usage

brier_score(response, survival_prob, times)

integrated_brier_score(response, survival_prob, times)

Arguments

response

A right-censored Surv() object.

survival_prob

The predicted survival probabilities, a matrix (or data frame) with one row per subject and one column per time. With one time, a vector is accepted.

times

The times, in the order of the columns of survival_prob. integrated_brier_score() needs at least two, in increasing order.

Value

brier_score() gives a vector with one score per time. integrated_brier_score() gives a single number.

Details

integrated_brier_score() averages the scores over the times with the trapezoidal rule.

Examples

lung <- data.frame(
  time = c(306, 455, 1010, 210, 883, 1022, 310, 361, 218, 166, 170, 654),
  status = c(2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2),
  age = c(74, 68, 56, 57, 60, 74, 68, 71, 53, 61, 57, 68)
)
fit <- cox_ph(Surv(time, status) ~ age, data = lung)
times <- c(200, 300, 400)

# One row per subject and one column per time
p <- predict(fit, newdata = lung, type = "survival", times = times)
probs <- matrix(p$estimate, ncol = length(times), byrow = TRUE)

death <- Surv(lung$time, lung$status)
brier_score(death, survival_prob = probs, times = times)
#> [1] 0.1329911 0.1874811 0.2373545
integrated_brier_score(death, survival_prob = probs, times = times)
#> [1] 0.1863269