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"))Value
A symmetric numeric matrix with zero diagonal, the Kemeny distance between every pair of rows.
See also
Other matrix algebra:
tda_mcel(),
tda_mcent(),
tda_mch(),
tda_mcross(),
tda_mdiag(),
tda_mev(),
tda_mevs(),
tda_midf(),
tda_midf1(),
tda_midf2(),
tda_midf3(),
tda_minvs(),
tda_mkp(),
tda_mmul(),
tda_mnc(),
tda_mnrow(),
tda_mpbl(),
tda_mpfit(),
tda_mpinv(),
tda_mpit(),
tda_mple(),
tda_mpz(),
tda_mscal1(),
tda_msqrtd(),
tda_msvd(),
tda_mwvec()
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