Skip to contents

Pairwise Kemeny (Kendall-tau-with-ties) distance between every pair of rows of A, each row a ranking (or score) over the same set of items – TDA's mkmet. For two rankings, each pair of items contributes 0 if both rankings order (or tie) the pair the same way, 1 if one ranking ties the pair and the other doesn't, or 2 if the rankings strictly disagree on the pair's order.

Usage

tda_mkmet(A, dir = tempfile("tda"))

Arguments

A

a numeric matrix, one ranking per row.

dir

working directory.

Value

A symmetric numeric matrix with zero diagonal, the Kemeny distance between every pair of rows.

Examples

# four rankings of the same four items: b swaps the last two of a,
# c reverses a, d ties items in pairs
R <- rbind(a = c(1, 2, 3, 4),
           b = c(1, 2, 4, 3),
           c = c(4, 3, 2, 1),
           d = c(1, 1, 2, 2))
tda_mkmet(R)   # a-b: 2 (one pair reversed); a-c: 12 (all six pairs)
#>      [,1] [,2] [,3] [,4]
#> [1,]    0    2   12    2
#> [2,]    2    0   10    2
#> [3,]   12   10    0   10
#> [4,]    2    2   10    0