kendall: Kendall's tau

Description Usage Arguments Details Value References See Also Examples

View source: R/kendalls.R

Description

Computes the unconditional Kendall's tau

Usage

1
kendall(x, y = NULL)

Arguments

x

a numeric vector.

y

a numeric vector with compatible length to x.

Details

This function computes the unconditional Kendall's tau (the Kendall rank correlation coefficient) for two variables. The returned value is equivalent to that from cor with method = "kendall", but kendall is implemented in C.

Value

The output is a numeric value for the unconditional Kendall's tau.

References

Kendall, M. G. (1938), A new measure of rank correlation, Biometrika, 81–93.

See Also

cor

Examples

1
2
3
4
5
6
library(MASS)
set.seed(1)
dat <- mvrnorm(5000, c(0, 0), matrix(c(1, .5, .5, 1), 2))
## True kendall's tau is 2 * asin(.5) / pi
system.time(print(kendall(dat)))
system.time(print(cor(dat, method = "kendall")))

Example output

[1] 0.3486412
   user  system elapsed 
  0.038   0.000   0.038 
          [,1]      [,2]
[1,] 1.0000000 0.3486412
[2,] 0.3486412 1.0000000
   user  system elapsed 
  1.249   0.000   1.283 

tranSurv documentation built on Jan. 16, 2021, 5:31 p.m.