kendallTau | R Documentation |
Compute Kendall rank correlation coefficient between two objects. Kendall is a coefficient used in statistics to measure the ordinal association between two measured quantities. A tau test is a non-parametric hypothesis test for statistical dependence based on the tau coefficient. The 'kendallTau' function applies the "kendall" method from 'stats::cor' with some previous treatment in the data, such as converting floating numbers into ranks (from the higher being the first and negative being the last) and the possibility to remove zeros from incomplete ranks
kendallTau(x, y, null.rm = TRUE, average = TRUE, na.omit = FALSE, ...)
## Default S3 method:
kendallTau(x, y, null.rm = TRUE, ...)
## S3 method for class 'matrix'
kendallTau(x, y, null.rm = TRUE, average = TRUE, na.omit = FALSE, ...)
## S3 method for class 'rankings'
kendallTau(x, y, ...)
## S3 method for class 'grouped_rankings'
kendallTau(x, y, ...)
## S3 method for class 'paircomp'
kendallTau(x, y, ...)
x |
a numeric vector, matrix or data frame |
y |
a vector, matrix or data frame with compatible dimensions to |
null.rm |
logical, to remove zeros from |
average |
logical, if |
na.omit |
logical, if |
... |
further arguments affecting the Kendall tau produced. See details |
The Kendall correlation coefficient and the Effective N, which is the equivalent N needed if all items were compared to all items. Can be used for significance testing.
Kauê de Sousa and Jacob van Etten
Kendall M. G. (1938). Biometrika, 30(1–2), 81–93. \Sexpr[results=rd]{tools:::Rd_expr_doi("https://doi.org/10.1093/biomet/30.1-2.81")}
cor
Other goodness-of-fit functions:
kendallW()
,
pseudoR2()
# Vector based example same as stats::cor(x, y, method = "kendall")
# but showing N-effective
x = c(1, 2, 3, 4, 5)
y = c(1, 1, 3, 2, NA)
w = c(1, 1, 3, 2, 5)
kendallTau(x, y)
kendallTau(x, w)
# Matrix and PlacketLuce ranking example
library("PlackettLuce")
R = matrix(c(1, 2, 4, 3,
1, 4, 2, 3,
1, 2, NA, 3,
1, 2, 4, 3,
1, 3, 4, 2,
1, 4, 3, 2), nrow = 6, byrow = TRUE)
colnames(R) = LETTERS[1:4]
G = group(as.rankings(R), 1:6)
mod = pltree(G ~ 1, data = G)
preds = predict(mod)
kendallTau(R, preds)
# Also returns raw values (no average)
kendallTau(R, preds, average = FALSE)
# Choose to ignore entries with NA
R2 = matrix(c(1, 2, 4, 3,
1, 4, 2, 3,
NA, NA, NA, NA,
1, 2, 4, 3,
1, 3, 4, 2,
1, 4, 3, 2), nrow = 6, byrow = TRUE)
kendallTau(R, R2, average = FALSE)
kendallTau(R, R2, average = TRUE)
kendallTau(R, R2, average = TRUE, na.omit = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.