cindex: Concordance index calculation

Description Usage Arguments Details Value Author(s) Examples

View source: R/cindex.R

Description

Calculate concordance index

Usage

1
2
3
4
5
6
7
8
9
cindex(
  prob,
  fstatus,
  ftime,
  type = "crr",
  failcode = 1,
  cencode = 0,
  tol = 1e-20
)

Arguments

prob

predicted risk of failure event, either probability or risk score

fstatus

failure(event) variable

ftime

follow-up time variable for survival or competing risks predictions

type

type of regression models corresponding to different type of outcomes. 'logis' is the default value for binary outcome, 'surv' for ordinary survival outcome and 'crr' for competing risks outcome.

failcode

coding for failure(event). 1 is the default value.

cencode

coding for censoring. 0 is the defaul

tol

error tolerance. the default value is 1e-20.

Details

to calculate the discrimination metric, concordance index for binary, time-to event and competing risks outcomes

Value

a vector of returned values.

N

the total number of observations in the input data

n

the nonmissing number of observations that was used f or calculation

usable

the total number of usable pairs.

oncordant

the number of concordant pairs

cindex

the concordance index that equal to the number of concordant pairs divided by the total number of usable pairs.

Author(s)

Changhong Yu, Michael Kattan, Brian Wells, Amy Nowacki.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
seed <- 5555

# simulated data to test the function
n <- 20000
ftime <- rexp(n)
fstatus <- sample(0:2,n,replace=TRUE)
cov <- matrix(runif(3*n),nrow=n)
dimnames(cov)[[2]] <- c('x1','x2','x3')
dat <- data.frame(ftime,fstatus,cov)
require(Design)
print(z <- cph(Surv(ftime,fstatus == 1) ~ x1 + x2 + x3,data = dat))

# summary(z)
z.p <- predict(z)

#debug(cindex)
cindex(prob=z.p,fstatus=fstatus,type="logis")
cindex(prob=z.p,fstatus=fstatus,ftime=ftime,type="surv")
cindex(prob=z.p,fstatus=fstatus,ftime=ftime,type="crr")

jixccf/QHScrnomo documentation built on Dec. 21, 2021, 12:08 a.m.