Calculate Time-dependent ROC and AUC


This is the main function of this package. It calculates the time-dependent sensitivity and specificity and area under the curve (AUC) using a nonparametric weighting adjustment. It also provides variance estimation through bootstrap.


tdROC(X, Y, delta, tau, span = 0.1, h = NULL, type = "uniform", = NULL, nboot = 0, alpha = 0.05, n.grid = 1000,
  X.min = NULL, X.max = NULL)



a numeric vector of biomarker values. Same length with Y and delta.


a numeric vector of time to event.Same length with X and delta.


a vector of binary indicator of event (1) or censoring (0). Same length with X and Y.


a scalar, the prediction horizon at which the prediction is evaluated.


a numeric value, the proportion of neighbour observations used in nearest neighbor method, default is 0.1.


a numeric value, the bandwidth of kernel weights, defualt is NULL. If not specified, the function will use the value of span to calculate kernel weights. In case both span and h are specified, the function will use h.


a character value, indicating the type of kernel function used to calculate kernel weights. Default is "uniform" kernel. Other options are "Epanechnikov" and "normal". It will only be used when the bandwidth h is specified.

a vector of biomarker cut-off values at which sensitivity and specificity will be calculated.When bootstrap is requested, the corresponding confidence intervals will also be provided.


the number of bootstrap replications to be used for variance estimation; default is nboot = 0, corresponding to no variance estimation.


1-level of confidence interval, default is 0.05. It is used only when nboot > 0.


an positive integer, the number of grid points used when calculating the ROC curve. The default is 1000.


the lower boundary of grid cut-off points for biomarker X. If not specified, default will be the minimum of biomarker X.


the upper boundary of grid cut-off points for biomarker X. If not specified, default will be the maximum of biomarker X. X.min and X.max are not needed for point estimate but are needed for bootstrap variance estimation.


This function read in the prognostic biomarker value X, the time-to-event data Y and censoring indicator delta to calculate the sensitivity and specificity at the prediction horizon tau for a series specified grid points. It uses a simple nonparametric weight adjustments for right censored data (Li et al., 2015).


Returns a list of the following items:

ROC: a data frame of dimension (2+n.grid) x 3, the three columns are: grid, sens, and spec.

AUC: a data frame of one row and four columns: AUC, standard error of AUC, the lower and upper limits of bootstrap CI. AUC is calculated by integrating the area under ROC curve with trapezoidal method.

AUC2: a data frame of one row and four columns: AUC2, standard error of AUC2, the lower and upper limits of bootstrap CI. AUC2 is the AUC calculated by the concordance based formula (Li et al., 2015).

prob: a data frame of three columns if nboot=0:, sens, and spec. If nboot>0, another six columns of standard error, lower and upper limits of both sens and spec will be added. The number of rows equals length of A series of sensivitity and specificity are calculated at requested points.


Liang Li, Cai Wu


Li, Liang, Bo Hu, and Tom Greene. "A Simple Method to Estimate the Time-dependent ROC Curve Under Right Censoring." (2015).

See Also

survfit, mayo


library( survival ) ;
data( mayo ) ;
dat <- mayo[ ,c( "time","censor","mayoscore5" )] ;

fm <- tdROC( X = dat$mayoscore5, Y = dat$time, delta = dat$censor,
       tau = 365*6, span = 0.1, nboot = 0, alpha = 0.05,
       n.grid = 1000, = 5:9 ) ;
comments powered by Disqus