Computes Kendall's tau for singly (y only) or doubly (x and y) censored data. Also computes the Akritas-Theil-Sen (ATS) nonparametric regression line, with the Turnbull estimate of the intercept.
cenken(y, ycen = NULL, x = NULL, xcen = NULL)
A numeric vector of observations or a formula.
A logical vector indicating TRUE
where an observation in y
is
censored (a less-than value) and FALSE
otherwise. Can be omitted for the case
where y
is not censored.
A numeric vector of observations.
default is NULL for trend analysis purposes. If included, a
logical vector indicating TRUE
where an observation in x
is
censored (a less-than value) and FALSE
otherwise.
A list containing:
Kendall's tau correlation coefficient.
The estimated slope from the ATS line.
P-value for testing the null hypothesis of no association.
If using the formula interface, the ycen
, x
, and xcen
arguments are not specified. All information is instead provided through a
formula via the y
argument. The formula must use a Cen
object
as the response (on the left-hand side of ~
), and predictors (optional)
on the right-hand side separated by +
. See examples below.
Kendall's tau is a nonparametric correlation coefficient that measures
monotonic association between y
and x
. For left-censored data,
concordant and discordant pairs are evaluated wherever possible. For example,
with increasing x
values, a change in y
from <1 to 10 is considered
an increase (concordant), while a change from <1 to 0.5 or <5 is considered a tie.
The ATS line is defined as the slope resulting in Kendall's tau of 0
between residuals (y - slope * x)
and x
. The routine uses
an iterative bisection search to find this slope. The intercept is the
median residual, computed using the Turnbull estimate for interval-censored
data as implemented in the Icens package.
Helsel, D. R. (2005). Nondetects and Data Analysis: Statistics for Censored Environmental Data. John Wiley & Sons.
Akritas, M. G., Murphy, S. A., & LaValley, M. P. (1995). The Theil-Sen Estimator with Doubly Censored Data and Applications to Astronomy. Journal of the American Statistical Association, 90, 170–177.
# Both y and x are censored
data(PbHeron)
with(PbHeron,cenken(Blood,BloodCen,Kidney,KidneyCen))
#> Censored Kendall's Tau Regression:
#> Slope : 0.0153829
#> Intercept : 0.005801006
#> Tau : 0.4216524
#> p-value : 0.0004277088
# x is not censored
data(TCEReg)
with(TCEReg, cenken(log(TCEConc), TCECen, PopDensity))
#> Censored Kendall's Tau Regression:
#> Slope : 0.3835066
#> Intercept : -1.15052
#> Tau : 0.1458477
#> p-value : 0.0003007718
# Synthetic time-series with trend analysis
set.seed(123)
## Parameters
n <- 15 # 15 years of data
time <- 1:n
## Components
trend <- 0.235 * time
noise <- rnorm(n, mean = 5, sd = 1.5)
syn_dat <- data.frame(Yr = 1989 + time, value = trend + noise)
syn_dat$censored <- syn_dat$value < quantile(syn_dat$value, 0.2)
with(syn_dat,cenken(value,censored,Yr))
#> Censored Kendall's Tau Regression:
#> Slope : 0.273156
#> Intercept : -538.3541
#> Tau : 0.4190476
#> p-value : 0.03269503
if (FALSE) {
plot(value~Yr,syn_dat,pch=21,bg=ifelse(syn_dat$censored==TRUE,"red","blue",cex=1.5))
abline(h=quantile(syn_dat$value, 0.2),lty=2,col="red")
}