vignettes/tranSurv-quasi-independence.Rmd
tranSurv-quasi-independence.Rmd
In this vignette, we demonstrate how to test quasi-independence of Failure and Truncation Times with the tranSurv
package.
The tranSurv
package can be installed from CRAN with
> install.packages("tranSurv")
or from GitHub with
> devtools::install_github("stc04003/tranSurv")
Once installed, the tranSurv
package can be loaded with
> library(tranSurv)
> packageVersion("tranSurv")
[1] '1.2.1'
Suppose we have the correlated data generated from the following codes with the copula
package:
> library(copula)
> set.seed(1)
> rho <- iTau(normalCopula(dim = 2), .5) ## convert kendall's tau to pearson's rho
> dat <- rCopula(3000, normalCopula(rho, dim = 2))
> dat <- data.frame(qweibull(dat, 2, 1))
> colnames(dat) <- c("T", "X")
> head(dat)
T X
1 0.6038558 0.7992435
2 0.7565791 1.4441495
3 0.8279813 0.5533043
4 1.2090490 1.2835750
5 1.0400184 0.8031469
6 1.6720669 1.3225104
The above codes generate random sample of points \((T, X)\) from the bivariate Weibull distribution with the Kendall’s tau (\(\tau\)) of 0.5. The pairs \((T, X)\) are stored in the rows of the data frame dat
.
The consistent estimator of \(\tau\) is the U-statistics \[ \widehat\tau = \frac{1}{\binom{n}{2}} \sum_{i = 1}^{n - 1}\sum_{j = i + 1}^n\mbox{sgn}\{(X_i - X_j)(T_i - T_j)\},\] where \(n\) is the sample size, and \(\mbox{sgn}(u)\) is the sign of \(u\), e.g., Schucany (1985). The estimator, \(\widehat\tau\) can be computed with cor
:
> cor(dat, method = "kendall")
T X
T 1.0000000 0.5059304
X 0.5059304 1.0000000
The tranSurv
package has a faster implementation to compute the Kendall’ tau:
> kendall(dat)
[1] 0.5059304
> microbenchmark::microbenchmark(kendall(dat), cor(dat, method = "kendall"))
Unit: milliseconds
expr min lq mean median
kendall(dat) 8.753816 8.96441 10.20887 9.629006
cor(dat, method = "kendall") 274.699690 278.06297 305.53340 300.487028
uq max neval cld
10.85673 23.22783 100 a
333.22581 361.76708 100 b
Assume \(X\) is (left) truncated by \(T\) as in the scenario of left-truncation so that samples with \(X < T\) are not observed. We further assume \(X\) is subject to independent right-censoring time \(C\), and \(Y = \min(X, C)\) and \(\Delta = I(X \le C)\) are also observed. The observed data is then iid copies of \((Y, T, \Delta)|Y\ge T\).
> dat$C <- rexp(3000, .5)
> dat$Y <- pmin(dat$C, dat$X)
> dat$delta <- 1 * (dat$X <= dat$C)
> dat <- subset(dat, Y >= T)
> dim(dat)
[1] 1077 5
> head(dat)
T X C Y delta
4 1.2090490 1.2835750 9.472833 1.2835750 1
9 1.0044891 1.2819928 3.109907 1.2819928 1
15 0.7019466 0.9320237 5.836156 0.9320237 1
18 0.2815466 0.4472697 1.249041 0.4472697 1
24 1.1539707 1.2730134 1.737876 1.2730134 1
25 0.9471815 1.2298707 2.570207 1.2298707 1
The tranSurv
package provides three implementations of conditional Kendall’s tau (\(\tau_c\)) for left-truncated, right-censored data. These implementations are called with function cKendall
, whose arguments are as follows:
> args(cKendall)
function (trun, obs, delta = NULL, method = "MB", weights = NULL,
a = 0, trans = "linear", ...)
NULL
trun
left truncation time satisfying trun <= obs
.obs
observed failure time. Must be the same length as trun
, and might be right-censored.delta
an optional 0-1 vector of censoring indicator (0 = censored, 1 = event) for obs
. If this vector is not specified, cKendall
assumes all observed failure times are events.method
a character string specifying the different version of conditional Kendall’s tau to be computed. The possible methods are:
MB
conditional Kendall’s tau proposed in Tsai (1990) and Martin and Betensky (2005)
IPW1
inverse probability weighted conditional Kendall’s tau proposed in Austin and Betensky (2014)
IPW2
restricted inverse probability weighted conditional Kendall’s tau proposed in Austin and Betensky (2014)
weights
an optional vector of user-specified sampling weightsa
a numeric transformation parameter. The default value is 0, indicating no transformation. See Chiou et al. (2018) for more details.trans
a character string specifying the transformation structure. See Chiou et al. (2018) for more details. The following are permitted:
linear
linear transformation structurelog
log-linear transformation structureexp
exponential transformation structureTsai (1990) and Martin and Betensky (2005) consider the consistent estimator: \[\widetilde\tau_c = \frac{1}{M}\sum_{i = 1}^{n - 1}\sum_{j = i + 1}^n \mbox{sgn}\{(Y_i - Y_j)(T_i - T_j)\}I(\Lambda_{ij}),\] where \(\Lambda_{ij} = \{\max(T_i, T_j)\le \min(Y_i, Y_j)\}\cap \{\Delta_{ij}^{(1)}=1\}\), \(\Delta_{ij}^{(1)} = 1\) if \(\min{Y_i, Y_j}\) is not a censored event and 0 otherwise. The notation \(\Lambda_{ij}\) ensures \(Y_i\) and \(Y_j\) are orderable and comparable. The corresponding quasi-independence test can be called with the function cKendall
> cKendall(dat$T, dat$Y, dat$delta)
Test for quasi-independence with conditional Kendall's tau
Call: cKendall(trun = dat$T, obs = dat$Y, delta = dat$delta)
Kendall's tau = 0.1627 , SE = 0.0222 , Z = 7.3285 , p-value = 0
where the asymptotic variance is computed using the asymptotic U-statistic variance outlined in Section 6 of Martin and Betensky (2005). The conditional Kendall’s tau value and the corresponding \(p\)-value can be called individually:
> cKendall(dat$T, dat$Y, dat$delta)$PE
[1] 0.1626586
> cKendall(dat$T, dat$Y, dat$delta)$p.value
[1] 2.327027e-13
Austin and Betensky (2014) proposed an inverse probability weighted versions of the conditional Kendall’s tau estimator. When method = "IPW1"
, cKendall
compute the conditional Kendall’s tau defined as \(\widehat\tau_{c2}\) in Section 4 of Austin and Betensky (2014).
> cKendall(dat$T, dat$Y, dat$delta, method = "IPW1")
Test for quasi-independence with conditional Kendall's tau
Call: cKendall(trun = dat$T, obs = dat$Y, delta = dat$delta, method = "IPW1")
Kendall's tau = 0.1653 , SE = 0.022 , Z = 7.51 , p-value = 0
When method = "IPW2"
, cKendall
compute the conditional Kendall’s tau defined as \(\widehat\tau_{c3}\) in Section 4 of Austin and Betensky (2014).
> cKendall(dat$T, dat$Y, dat$delta, method = "IPW2")
Test for quasi-independence with conditional Kendall's tau
Call: cKendall(trun = dat$T, obs = dat$Y, delta = dat$delta, method = "IPW2")
Kendall's tau = 0.1713 , SE = 0.0229 , Z = 7.4867 , p-value = 0
We illustrate the use of cKendall
on the Channing House data set, which consists of 96 male retirees from their entry to the Channing House retirement community. The data can be prepared with the following codes.
The conditional Kendall’s tau values and the associated \(p\)-value with the different methods are:
Test for quasi-independence with conditional Kendall's tau
Call: cKendall(trun = entry, obs = exit, delta = cens)
Kendall's tau = 0.1967 , SE = 0.0958 , Z = 2.0529 , p-value = 0.0401
> cKendall(entry, exit, cens, method = "IPW1")
Test for quasi-independence with conditional Kendall's tau
Call: cKendall(trun = entry, obs = exit, delta = cens, method = "IPW1")
Kendall's tau = 0.1356 , SE = 0.0927 , Z = 1.4631 , p-value = 0.1434
> cKendall(entry, exit, cens, method = "IPW2")
Test for quasi-independence with conditional Kendall's tau
Call: cKendall(trun = entry, obs = exit, delta = cens, method = "IPW2")
Kendall's tau = 0.425 , SE = 0.174 , Z = 2.4423 , p-value = 0.0146
> detach(chan)
The results are similar to these reported in Austin and Betensky (2014).
Austin, Matthew D, and Rebecca A Betensky. 2014. “Eliminating Bias Due to Censoring in Kendall’s Tau Estimators for Quasi-Independence of Truncation and Failure.” Computational Statistics & Data Analysis 73. Elsevier: 16–26.
Chiou, Sy Han, Matthew D Austin, Jing Qian, and Rebecca A Betensky. 2018. “Transformation Model Estimation of Survival Under Dependent Truncation and Independent Censoring.” Statistical Methods in Medical Research. SAGE Publications Sage UK: London, England. doi:https://doi.org/10.1177/0962280218817573.
Martin, Emily C, and Rebecca A Betensky. 2005. “Testing Quasi-Independence of Failure and Truncation Times via Conditional Kendall’s Tau.” Journal of the American Statistical Association 100 (470). Taylor & Francis: 484–92.
Schucany, William R. 1985. “Introduction to the Theory of Nonparametric Statistics.” JSTOR.
Tsai, Wei-Yann. 1990. “Testing the Assumption of Independence of Truncation Time and Failure Time.” Biometrika 77 (1). Oxford University Press: 169–77.