Title: | Nonparametric Estimation of Time-Dependent ROC, Brier Score, and Survival Difference from Right Censored Time-to-Event Data with or without Competing Risks |
---|---|
Description: | The tdROC package facilitates the estimation of time-dependent ROC (Receiver Operating Characteristic) curves and the Area Under the time-dependent ROC Curve (AUC) in the context of survival data, accommodating scenarios with right censored data and the option to account for competing risks. In addition to the ROC/AUC estimation, the package also estimates time-dependent Brier score and survival difference. Confidence intervals of various estimated quantities can be obtained from bootstrap. The package also offers plotting functions for visualizing time-dependent ROC curves. |
Authors: | Xiaoyang Li [aut, cre], Zhe Yin [aut], Liang Li [aut, ths] |
Maintainer: | Xiaoyang Li <[email protected]> |
License: | MIT + file LICENSE |
Version: | 2.0 |
Built: | 2024-12-08 06:50:16 UTC |
Source: | CRAN |
This example dataset is included for illustration. The Mayo PBC data is publicly available and has been used in many statistical researches (e.g., Zheng and Heagerty 2005). This example dataset is a subset of the full PBC data.
data(mayo)
data(mayo)
A data frame with 312 observations and 4 variables:
time
: event time or censoring time
censor
: censoring indicator.
mayoscore4
and mayoscore5
: derived from 4 and 5 covariates respectively.
Heagerty, P. J., & Zheng, Y. (2005). Survival model predictive accuracy and ROC curves. Biometrics, 61(1), 92-105.
data(mayo) head(mayo)
data(mayo) head(mayo)
This example dataset is included for illustration. The Melano data is publicly available. In 1962-1977, 205 patients with malignant melanoma (skin cancer) had a radical operation performed at an academic medical center. At the end of the follow-up, 57 died from cancer, 14 died from other causes, and the other 134 patients were alive (censored). This example dataset illustrates the prediction accuracy of competing risk outcomes with baseline age and tumor thickness.
data(Melano)
data(Melano)
A data frame with 312 observations and 4 variables: time (event time/censoring), time), censor (censoring mayoscore4, mayoscore5. The two scores are derived from 4 and 5 covariates respectively.
Andersen, P. K. , & Skovgaard, L. T. (2010). Regression with linear predictors. New York, NY: Springer.
data(Melano) head(Melano)
data(Melano) head(Melano)
This function reads in object returned by tdROC()
and plot ROC curve for it.
plot_tdROC( x, lwd = 2, xlab = "1-specificity", ylab = "sensitivity", xlim = c(0, 1), ylim = c(0, 1), main = "ROC curve", col = "black", abline = T, ... )
plot_tdROC( x, lwd = 2, xlab = "1-specificity", ylab = "sensitivity", xlim = c(0, 1), ylim = c(0, 1), main = "ROC curve", col = "black", abline = T, ... )
x |
the object returned by |
lwd |
user-specified line width. Default is |
xlab |
user-specified label for x-axis. Default is " |
ylab |
user-specified label for y-axis. Default is " |
xlim |
user-specified limit for x axis. Default is |
ylim |
user-specified limit for y axis. Default is |
main |
user-specified title for the plot. Default is " |
col |
user-specified color for ROC curve. Defualt is " |
abline |
user-specified reference diagnol line. Default is |
... |
for future methods |
Returns a plot of ROC curve. If the tdROC object comes with bootstrap result, then the ROC curve will be plotted with confidence interval.
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, cut.off = 5:9 ) # plot the object "fm" from tdROC() plot_tdROC(fm)
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, cut.off = 5:9 ) # plot the object "fm" from tdROC() plot_tdROC(fm)
This function reads in object returned by tdROC.cr()
and plot ROC curve for it.
plot_tdROC_cr( x, lwd = 2, xlab = "1-specificity", ylab = "sensitivity", xlim = c(0, 1), ylim = c(0, 1), col = c("red", "blue"), main = "ROC curve", abline = T, ... )
plot_tdROC_cr( x, lwd = 2, xlab = "1-specificity", ylab = "sensitivity", xlim = c(0, 1), ylim = c(0, 1), col = c("red", "blue"), main = "ROC curve", abline = T, ... )
x |
the object returned by |
lwd |
user-specified line width. Default is |
xlab |
user-specified label for x-axis. Default is " |
ylab |
user-specified label for y-axis. Default is " |
xlim |
user-specified limit for x axis. Default is |
ylim |
user-specified limit for y axis. Default is |
col |
user-specified color for ROC curve. Defualt is " |
main |
user-specified title for the plot. Default is " |
abline |
user-specified reference diagnol line. Default is |
... |
for future methods |
Returns several plots of ROC curve. For competing risk data, there are two definitions of controls introduced by Zheng et al, which was listed below
For more details about above two definitions, please read details of function tdROC.cr
.
If the tdROC.cr
object comes without bootstrap result, the ROC curve for above two definitions will be plotted together and indicated by the specified col
.
If the tdROC.cr
object with bootstrap result, one more ROC curve with confidence interval will be plotted for each definition.
Zheng Y, Cai T, Jin Y, Feng Z. Evaluating prognostic accuracy of biomarkers under competing risk. Biometrics. 2012;68(2):388-396. doi:10.1111/j.1541-0420.2011.01671.x
library(survival) data(Melano) tdROC.cr_res <- tdROC.cr( X = Melano$thick, Y = Melano$time, delta = Melano$status, tau = 1800, nboot = 10 ) plot_tdROC_cr(tdROC.cr_res)
library(survival) data(Melano) tdROC.cr_res <- tdROC.cr( X = Melano$thick, Y = Melano$time, delta = Melano$status, tau = 1800, nboot = 10 ) plot_tdROC_cr(tdROC.cr_res)
This is a core function of the ‘tdROC‘ package. It uses the nonparametric weights proposed by Li (Li et al., 2015) to estimate a number of time-dependent prediction accuracy measures for right-censored survival outcomes, including ROC curve, AUC, Brier score, and survival difference. For each measure, the variance can be estimated through bootstrap resampling.
tdROC( X, Y, delta, tau, span = 0.1, h = NULL, type = "uniform", n.grid = 1000, X.min = NULL, X.max = NULL, cut.off = NULL, nboot = 0, alpha = 0.05, epsilon = NULL, method = "both", output = "both" )
tdROC( X, Y, delta, tau, span = 0.1, h = NULL, type = "uniform", n.grid = 1000, X.min = NULL, X.max = NULL, cut.off = NULL, nboot = 0, alpha = 0.05, epsilon = NULL, method = "both", output = "both" )
X |
a numeric vector of risk score in the same length as |
Y |
a numeric vector of time to event in the same length as |
delta |
a vector of binary indicator of event (1) or censoring (0) in the same length as |
tau |
a scalar, the prediction horizon at which the prediction is evaluated. |
span |
a numeric value, the proportion of neighbour observations used in nearest neighbor method, default to 0.1. |
h |
a numeric value, the bandwidth of kernel weights, the defualt is |
type |
a character value, indicating the type of kernel function used to calculate kernel weights. The default is |
n.grid |
a positive integer, the number of grid points used when calculating the ROC curve. The default is |
X.min |
the lower boundary of grid cut-off points for biomarker |
X.max |
the upper boundary of grid cut-off points for biomarker |
cut.off |
a vector of |
nboot |
the number of bootstrap replications to be used for variance estimation. The default is |
alpha |
It is (1 - level of confidence interval)/2, default is |
epsilon |
The precision parameter used in an approximation to the weight calculation when the sample size is large. If a weight corresponding to a specific risk score is already calculated, then the weights corresponding to adjacent risk scores, within the distance specified by epsilon, will be the same under the approximation. This approximation avoids repeated calculation of weights that are almost the same, and hence increases the speed of computation in this situation. The default is NULL, which means no approximation is used. A higher value indicates less precision. |
method |
It is used to specify which method you would like to use to estimate AUC, default to |
output |
It is used to specify which kind of output you want, default to |
This function takes the risk score value X
, the time-to-event data Y
and censoring indicator delta
as input to estimate
a number of time-dependent prediction accuracy measures for right-censored survival outcomes, including ROC curve, AUC, Brier score, and survival difference.
The confidence intervals of above quantities will be estimated by bootstrap.
This function offer two options to estimate AUC. The first one make use of estimated sensitivity and specificity to calculate the AUC via trapezoidal integration
by setting a series of cutoff point. The output will also include corresponding sensitivity and specificity for our plot function. The other one estimate AUC by the empirical estimator
of the proportion of concordance pairs with proposed weight estimator (Li et al, 2015). These two methods will generate quite similar estimates. The option can be set by argument method
.
We also include Brier Score and survival difference to evaluate the calibration metrics. Their definitions are included below.
They can be estimated with the proposed conditional probability weight (Wu and Li, 2018).
Both of them are measures to assess the accuracy of probabilistic predictions X
. The calibration result makes sense only
when the risk score X
is a predicted probability, and should be ignored otherwise.
As mentioned in arguments, we introduced a small precision parameter epsilon
to speed up the computation when the sample size is large.
For each subject with a risk score, , we assess whether there exists a previously processed grid point,
where
,
within the proximity of
such that
. In the absence of such a point, we designate
as a new grid point,
, and store the corresponding
survfit
object for subsequent weight estimation and mark it as a processed grid point. Conversely,
if a previously processed grid point is found, we directly utilize the stored survfit
object associated with it for weight calculation.
Given that the most time-consuming step in our estimation process is the survfit
computation, this method significantly reduces computing time
without incurring notable bias especially when dealing with large sample sizes.
Returns a list of the following items:
main_res:
a list of AUC.integral
estimated by trapezoidal integration, AUC.empirical
estimated by empirical estimator of the proportion of concordance pairs.
and a data frame ROC
with dimension (2+n.grid) x 3
with columns cut.off
, sens
, and spec
.
calibration_res:
brier score and survival difference estimated based on the formula similar to Wu and Li (2018). When the risk score X
is a biomarker value instead of a predicted cumulative incidence probability, the brier score and survival difference cannot be calculated. In this case, please disregard the calibration results.
boot_res:
a list of bootstrap results, including bAUC
, bAUC2
, bBS
, bSurvDiff
, bROC
.
For bAUC
, bAUC2
, bBS
, bSurvDiff
, each one is a list including corresponding mean, standard deviation, and confidence interval.
bROC
is a data frame with colomns sens.mean
, sens.sd
, sens.lower
, sens.upper
, spec.mean
, spec.sd
, spec.lower
, spec.upper
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, cut.off = 5:9 ) # In the following example, We use biomarker mayoscore5 to estimate predicted probability # tipycally a monotone transformation function such as expit() is used to transform biomarker # with range out of range into estimated probability between 0 and 1 expit <- function(x){ 1/(1+exp(-x)) } tdROC( X = expit(dat$mayoscore5), Y = dat$time, delta = dat$censor, tau = 365 * 6, span = 0.1, nboot = 0, alpha = 0.05, n.grid = 1000, cut.off = 5:9 ) tdROC( X = expit(dat$mayoscore5), Y = dat$time, delta = dat$censor, tau = 365 * 6, span = 0.1, nboot = 0, alpha = 0.05, n.grid = 1000, cut.off = 5:9, epsilon = 0.05 )
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, cut.off = 5:9 ) # In the following example, We use biomarker mayoscore5 to estimate predicted probability # tipycally a monotone transformation function such as expit() is used to transform biomarker # with range out of range into estimated probability between 0 and 1 expit <- function(x){ 1/(1+exp(-x)) } tdROC( X = expit(dat$mayoscore5), Y = dat$time, delta = dat$censor, tau = 365 * 6, span = 0.1, nboot = 0, alpha = 0.05, n.grid = 1000, cut.off = 5:9 ) tdROC( X = expit(dat$mayoscore5), Y = dat$time, delta = dat$censor, tau = 365 * 6, span = 0.1, nboot = 0, alpha = 0.05, n.grid = 1000, cut.off = 5:9, epsilon = 0.05 )
This is a core function of the ‘tdROC‘ package. It uses the nonparametric weights proposed by Wu (Wu and Li, 2018) to estimate a number of time-dependent prediction accuracy measures for right-censored survival outcomes, including ROC curve, AUC, Brier score, and survival difference, with competing risk data. For each measure, the variance can be estimated through bootstrap resampling.
tdROC.cr( X, Y, delta, tau, span = 0.1, h = NULL, type = "uniform", epsilon = 0.01, cut.off = NULL, n.grid = 1000, nboot = 0, alpha = 0.05, method = "both", output = "both" )
tdROC.cr( X, Y, delta, tau, span = 0.1, h = NULL, type = "uniform", epsilon = 0.01, cut.off = NULL, n.grid = 1000, nboot = 0, alpha = 0.05, method = "both", output = "both" )
X |
a numeric vector of risk score in the same length as |
Y |
a numeric vector of time to event in the same length as |
delta |
a vector of numeric indicator of event type in the same length as |
tau |
a scalar, the prediction horizon at which the prediction is evaluated. |
span |
a numeric value, the proportion of neighbour observations used in nearest neighbor method. The default is 0.1. |
h |
a numeric value, the bandwidth of kernel weights, the defualt is |
type |
a character value, indicating the type of kernel function used to calculate kernel weights. The default is |
epsilon |
The precision parameter used in an approximation to the weight calculation when the sample size is large. If a weight corresponding to a specific risk score is already calculated, then the weights corresponding to adjacent risk scores, within the distance specified by epsilon, will be the same under the approximation. This approximation avoids repeated calculation of weights that are almost the same, and hence increases the speed of computation in this situation. The default is NULL, which means no approximation is used. A higher value indicates less precision. |
cut.off |
a vector of |
n.grid |
a positive integer, the number of grid points used when calculating the ROC curve. The default is |
nboot |
the number of bootstrap replications to be used for variance estimation. The default is |
alpha |
It is (1 - level of confidence interval)/2, default is |
method |
It is used to specify which method you would like to use to estimate AUC, default to |
output |
It is used to specify which kind of output you want, default to |
This function takes the risk score value X
, the time-to-event data Y
and censoring indicator delta
as input to estimate
a number of time-dependent prediction accuracy measures for survival outcomes, including ROC curve, AUC, Brier score, and survival difference, with competing risk.
The confidence intervals of above quantities are estimated by bootstrap.
For competing risk data, there are two definition of controls introduced by Zheng et al, which are listed below
Based on the definition A, both the event-free subjects and subjects who experience other competing events were included as controls. While definition B include only event-free subjects.
This function offers two options to estimate AUC. The first one make use of estimated sensitivity and specificity to calculate the AUC via trapezoidal integration
by setting a series of cutoff point. For the two different definition, we separately calculate the sensitivity, specificity and AUC. The output will also include the sensitivities
and specificities for our plot function. The other one estimates AUC by the empirical estimator of the proportion of concordance pairs with proposed weight estimator (Wu and Li, 2018).
These two methods generate quite similar estimates. The option can be set by the argument method
.
In addition to the above prediction measures, we include Brier Score and survival difference to evaluate the calibration metrics. Their definitions are included below.
They can be estimated with the proposed conditional probability weight (Wu and Li, 2018).
Both of them are measures to assess the accuracy of probabilistic predictions X
. The calibration result makes sense only
when the risk score X
is a predicted probability, and should be ignored otherwise.
This function uses the same approximation as tdROC
with the argument epsilon
Returns a list of the following items:
main_res:
a list of AUC.A.integral
estimated by trapezoidal integration for definition A,
AUC.A.empirical
estimated by empirical estimator for definition A,
AUC.B.integral
estimated by trapezoidal integration for definition B,
AUC.B.empirical
estimated by empirical estimator for definition B,
and a data frame ROC
with dimension (2+n.grid) x 4
with columns cut.off
, sens
, specA
and specB
.
calibration_res:
brier score and survival difference estimated based on the formula similar to Wu and Li (2018). When the risk score X
is a biomarker value instead of a predicted cumulative incidence probability, the brier score and survival difference cannot be calculated. In this case, please disregard the calibration results.
boot_res:
a list of bootstrap results, including bAUC.A.integral
, bAUC.A.empirical
, bAUC.B.integral
, bAUC.B.empirical
, bBS
, bSurvDiff
, bROC
.
For bAUC.A.integral
, bAUC.A.empirical
, bAUC.B.integral
, bAUC.B.empirical
, bBS
, bSurvDiff
, each one is a list including corresponding mean, standard deviation, confidence interval.
bROC
is a data frame with colomns sens.mean
, sens.sd
, sens.lower
, sens.upper
,
specA.mean
, specA.sd
, specA.lower
, specA.upper
, specB.mean
, specB.sd
, specB.lower
, specB.upper
Zheng Y, Cai T, Jin Y, Feng Z. Evaluating prognostic accuracy of biomarkers under competing risk. Biometrics. 2012;68(2):388-396. doi:10.1111/j.1541-0420.2011.01671.x
library(survival) data(Melano) expit <- function(x){ 1/(1+exp(-x)) } tdROC.cr(X = expit(Melano$thick) , Y = Melano$time, delta = Melano$status, tau = 1800, nboot = 10)
library(survival) data(Melano) expit <- function(x){ 1/(1+exp(-x)) } tdROC.cr(X = expit(Melano$thick) , Y = Melano$time, delta = Melano$status, tau = 1800, nboot = 10)