Description Usage Arguments Details Value Note References Examples

This function estimates a time-dependent ROC curve following the cumulative/dynamic approach and returns a 'cdroc' object. This object can be `printed`

or `plotted`

. To deal with the right censored problem different statistics can be considered: those ones proposed by *Martinez-Camblor et al. (2016)* based on the hazard Cox regression model (semiparametric) or the Kaplan-Meier estimator (non-parametric); and the one included in *Li et al. (2016)* based on the kernel-weighted Kaplan-Meier method. See *References* below.

1 2 3 4 5 6 | ```
cdROC(stime, status, marker, predict.time, ...)
## Default S3 method:
cdROC(stime, status, marker, predict.time, method=c('Cox', 'KM', 'wKM'),
kernel=c('normal', 'Epanechnikov', 'other'), h=1,
kernel.fun = function(x,xi,h){u <- (x-xi)/h; 1/(2*h)*(abs(u) <= 1)},
ci=FALSE, boot.n=100, conf.level=0.95, seed=2032, ...)
``` |

`stime ` |
vector of observed times. |

`status ` |
vector of status (takes the value 0 if the subject is censored and 1 otherwise). |

`marker ` |
vector of (bio)marker values. |

`predict.time ` |
considered time point (scalar). |

`method ` |
procedure used to estimate the probability. One of "Cox" (method based on Cox regression), "KM" (method based on Kaplan-Meier estimator) or "wKM" (method based on kernel-weighted Kaplan-Meier estimator). |

`kernel ` |
procedure used to calculate the kernel function. One of "normal", "Epanechnikov" or "other". Only considered if |

`h ` |
bandwith used to calculate the kernel function. Only considered if |

`kernel.fun ` |
if |

`ci ` |
if TRUE, a confidence interval for the area under the curve is computed. |

`boot.n ` |
number of bootstrap replicates considered to build the confidence interval. Default: 100. |

`conf.level ` |
the width of the confidence band as a number in (0,1). Default: 0.95, resulting in a 95% confidence band. |

`seed ` |
seed considered to generate bootstrap replicates (for reproducibility). |

`... ` |
additional arguments for |

Assuming that larger values of the marker are associated with higher probabilities of occurrence of the event, the cumulative sensitivity and the dynamic specificity are defined by:

*Se^C(x,t) = P(*`marker`

*> x | *`stime`

*≤ t)* and *Sp^D(x,t) = P(*`marker`

*≤ x |* `stime`

*> t)*.

The resulting ROC curve is known as the cumulative/dynamic ROC curve, *R_t^{C/D}*, where *t = * `predict.time`

.

Data censored before *t* is the major handicap with regard to the estimation of the time-dependent ROC curve. In order to estimate the probability of surviving beyond *t* for the *i*-th subject, *\hat{P}_i*, three different methods are considered:

A semiparametric one, using a proportional hazard Cox regression model:

The hazard function is estimated by

*λ(t) = λ_0(t) \cdot exp(β \cdot X)*where*X*denotes the marker.The probability is estimated by

*\hat{P}_i = \frac{\hat{S}(t | X = x_i)}{\hat{S}(z_i | X = x_i)}*where*z_i*stands for the observed time of the*i*-th subject and*\hat{S}*is the survival function estimated from the Cox regression model.A non-parametric one, using the Kaplan-Meier estimator directly:

The probability is estimated by

*\hat{P}_i = \frac{\hat{S}(t)}{\hat{S}(z_i)}*where*z_i*stands for the observed time of the*i*-th subject and*\hat{S}*is the survival function estimated by the Kaplan-Meier method referred to those subjects satisfying*X ≤ x_i*.A non-parametric one, using the kernel-weighted Kaplan-Meier estimator:

The survival function is estimated by

*\hat{S}(t | X = x_i) = ∏_{s ≤q t} ≤ft[ 1- \frac{∑_{j=1}^n K_h(x_j,x_i) I(z_j = s) status_j}{∑_{j=1}^n K_h(x_j,x_i) I(z_j = s)} \right]*where*z_j*stands for the observed time of the*j*-th subject,*I*is the indicator function and*status_j*takes the value 0 if the*j*-th subject is censored and 1 otherwise.Two different methods can be considered in order to define the kernel function,

*K_h(x_j,x_i)*:`kernel='normal'`

:*K_h(x_j,x_i) = \frac{1}{h √{2 π}} exp\{ - \frac{(x_j - x_i)^2}{2 h^2} \}*`kernel='Epanechnikov'`

:*K_h(x_j,x_i) = \frac{3}{4h} ≤ft( 1 - \frac{x_j - x_i}{h} \right) I(|x_j - x_i| ≤ h)*

where

*h*is the bandwidth considered for kernel weights.If the user decide to use another kernel function,

`kernel='other'`

, it should be defined by the`kernel.fun`

input parameter, which has three parameters following this order:`x`

is a vector,`xi`

is the value around which the kernel weight should be computed and`h`

is the bandwidth.The probability is estimated by

*\hat{P}_i = \frac{\hat{S}(t | X = x_i)}{\hat{S}(z_i | X = x_i)}*where*z_i*stands for the observed time of the*i*-th subject and*\hat{S}*is the survival function estimated by the kernel-weighted Kaplan-Meier method considered above.

A list of class 'cdroc' with the following content:

`TP ` |
vector of sensitivities (true positive rates). |

`TN ` |
vector of specificities (true negative rates). |

`cutPoints ` |
vector of thresholds considered for the (bio)marker. It coincides with the |

`auc ` |
area under the curve estimate by trapezoidal rule. |

`ci ` |
if TRUE, a confidence interval for the area under the curve has been computed. |

`boot.n ` |
number of bootstrap replicates considered to build the confidence interval. Default: 100. |

`conf.level ` |
the width of the confidence band as a number in (0,1). Default: 0.95, resulting in a 95% confidence band. |

`seed ` |
seed considered to generate bootstrap replicates (for reproducibility). |

`meanAuc ` |
bootstrap area under the curve estimate (mean along bootstrap replicates). |

`ciAuc` |
bootstrap confidence interval for the area under the curve. |

`aucs` |
vector of bootstrap area under the curve estimates. |

`stime ` |
vector of observed times. |

`status ` |
vector of status (takes the value 0 if the subject is censored and 1 otherwise). |

`marker ` |
vector of (bio)marker values. |

`predict.time ` |
considered time point (scalar). |

`method ` |
procedure used in order to estimate the probability. |

`kernel ` |
procedure used to calculate the kernel function. Only considered if |

`h ` |
bandwith used to calculate the kernel function. Only considered if |

`survfit`

and `Surv`

functions in `survival`

package are used in order to estimate the survival functions in both methodologies. Additionally, `coxph`

from the same package is used to fit the Cox proportional hazard regression model in the semiparametric approach.

Martinez-Camblor P., F-Bayon G., Perez-Fernandez S., 2016, Cumulative/dynamic ROC curve estimation, *Journal of Statistical Computation and Simulation*, **86**(17), 3582-3594.

Li L., Greene T., Hu B., 2016, A simple method to estimate the time-dependent receiver operating characteristic curve and the area under the curve with right censored data, *Statistical Methods in Medical Research*, DOI: 10.1177/0962280216680239.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ```
# Basic example. Data
set.seed(123)
stime <- rchisq(50,3)
status <- sample(c(rep(1,40), rep(0,10)))
marker <- max(stime) - stime + rnorm(50,0,2)
# Cumulative/dynamic ROC curve estimate at time 2.8 (Cox method is used) with 0.95 confidence
# interval for the area under the curve
cdROC(stime, status, marker, 2.8, ci=TRUE)
# Cumulative/dynamic ROC curve estimate at time 3.1 (Kaplan-Meier method is used)
cdROC(stime, status, marker, 3.1, method="KM")
# Cumulative/dynamic ROC curve estimate at time 3 (kernel-weighted Kaplan-Meier method with
# gaussian kernel and bandwidth 1 is used)
cdROC(stime, status, marker, 3, method="wKM")
# Cumulative/dynamic ROC curve estimate at time 3 (kernel-weighted Kaplan-Meier method with
# biweight kernel and bandwidth equals to 2 is used)
cdROC(stime, status, marker, 3, method="wKM", kernel="other", h=2,
kernel.fun = function(x,xi,h){u <- (x-xi)/h; 15/(16*h)*(1-u^2)^2*(abs(u)<=1)})
``` |

```
cdroc object:
Number of cut points: 52
Method: Cox
predict.time: 2.8
AUC: 0.8538752
Bootstrap number of replicates: 100
Bootstrap AUC: 0.861
Bootstrap AUC Confidence Interval: 0.769 0.953
Bootstrap AUC Confidence Level: 0.95
Bootstrap seed: 2032
cdroc object:
Number of cut points: 52
Method: KM
predict.time: 3.1
AUC: 0.7789663
cdroc object:
Number of cut points: 52
Method: wKM
predict.time: 3
AUC: 0.8481199
Kernel function: normal
Kernel bandwidth: 1
cdroc object:
Number of cut points: 52
Method: wKM
predict.time: 3
AUC: 0.8505225
Kernel function: other
Kernel bandwidth: 2
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.