I am using R package 'survcomp' to calculate the c-index of predicted survival vs. known test set survival. But it returned NA as result. Data are as following:
Test set known survival:
OS.Time OS.event
1 1686 0
2 517 0
3 7 0
4 1965 0
5 5748 0
6 495 0
7 10 0
8 365 1
9 1733 0
Predicted survival (may not be a good estimate, but should not affect c-index calculation anyhow):
0.11946905 0.27748710 0.88212024 0.19557143 0.09421667 0.27926806 1.53901710 1.03344646 0.73955159
The R code used to calculate c-index is: concordance.index(pred, test_surv$OS.Time, test_surv$OS.event, method="noether")$c.index
. As said, NA returned.
Is this because there is only one event in the test set? But I checked the c-index calculation formular. It seems only when the denominator is 0, the c-index can be NA, but it is not the case above.
If you look at the code you wil see this was intended behavior:
if (sum(cc.ix) < 3) {
if (msurv) {
data <- list(x = x, surv.time = surv.time, surv.event = surv.event)
}
else {
data <- list(x = x, cl = cl)
}
return(list(c.index = NA, se = NA, lower = NA, upper = NA,
p.value = NA, n = sum(cc.ix), data = data, comppairs = NA))
When the number of events were 2 or less the authors clearly intend to return NA for pretty much everything. (It's not that difficult to construct an experiment that replicates this conclusion.)