score.cindex: Scoring function for evaluating survival prediction through...

View source: R/int.R

score.cindexR Documentation

Scoring function for evaluating survival prediction through concordance index (c-index)

Description

C-index (Concordance index) of the predicted vs. true answer, i.e. proportion of pairs that go in correct direction over all pairwise comparisons

Usage

score.cindex(pred, time, event, real)

Arguments

pred

Numeric risk score for each event

time

A vector of event or censoring times

event

A binary valued vector that indicates either death (1) or right-censoring (0)

real

A previously constructed Surv-object instead of providing time and event

Value

Corcordance index (c-index) of the prediction

Examples

# A random prediction ought to be near 0.5
# c-index is not sensitive to time scale, as it tests pairwise prediction accuracy
set.seed(1); prediction <- sample(1:20)
time <- seq(from=1000, to=50, by=-50)
event <- c(0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1)
library(survival)
score.cindex(pred = prediction, real = Surv(time=time, event=event))

Syksy/ePCR documentation built on Feb. 20, 2024, 10:16 p.m.