RankMetric: Metrics for Rankings

Description Usage Arguments Value Author(s) References Examples

Description

Calculates the distances between a set of rankings or permutations, using one of six metrics.

Usage

1
distance(x, metric, perm = TRUE, ranktype = "full", k = 2)

Arguments

x

matrix where each row is a ranking or a permutation

metric

a distance metric, one of

  • "kendall"

  • "ulam"

  • "spearrho", spearman's rho

  • "spearfoot", spearman's footrule

  • "hamming"

  • "cayley"

perm

TRUE for a matrix of permutations, FALSE for a matrix of rankings

ranktype

indicates the type of ranking

  • "full" full ranking

  • "partial", partial ranking with no ties

  • "sametimes", ties allowed, the same number must be ranked 1st, 2nd etc

  • "anyties", ties allowed any number can be ranked 1st, 2nd etc

k

the number of items ranked in a partial ranking

Value

Returns a matrix of the distances between all the rankings/ permutations in the input matrix. If ranktype is "anyties" the function will work for any type of partial ranking or ranking with ties. However using "full" for complete rankings or "partial" for partial ranking with no ties for that kind of data will run faster.

If the ranking of some of the items is not known or given they can be left as NA.

Author(s)

Lucy Small, lucy.small@ucdconnect.ie

References

http://www.springer.com/gp/book/9780387962887

Examples

1
2
x = t(matrix(replicate(10,sample(1:5,5)),ncol=10))
distance(x,metric = "spearfoot",perm = FALSE,"full")

lucyov26/RankMetric documentation built on May 6, 2019, 9:09 a.m.