View source: R/compute_rank_distance.R
compute_rank_distance | R Documentation |
Compute the distance between a matrix of rankings and a rank sequence.
compute_rank_distance(
rankings,
rho,
metric = c("footrule", "spearman", "cayley", "hamming", "kendall", "ulam"),
observation_frequency = 1
)
rankings |
A matrix of size |
rho |
A ranking sequence. |
metric |
Character string specifying the distance measure to use.
Available options are |
observation_frequency |
Vector of observation frequencies of length |
The implementation of Cayley distance is based on a C++
translation of Rankcluster::distCayley()
\insertCiteGrimonprez2016BayesMallows.
A vector of distances according to the given metric
.
Other rank functions:
compute_expected_distance()
,
compute_observation_frequency()
,
create_ranking()
,
get_mallows_loglik()
,
sample_mallows()
# Distance between two vectors of rankings:
compute_rank_distance(1:5, 5:1, metric = "kendall")
compute_rank_distance(c(2, 4, 3, 6, 1, 7, 5), c(3, 5, 4, 7, 6, 2, 1), metric = "cayley")
compute_rank_distance(c(4, 2, 3, 1), c(3, 4, 1, 2), metric = "hamming")
compute_rank_distance(c(1, 3, 5, 7, 9, 8, 6, 4, 2), c(1, 2, 3, 4, 9, 8, 7, 6, 5), "ulam")
compute_rank_distance(c(8, 7, 1, 2, 6, 5, 3, 4), c(1, 2, 8, 7, 3, 4, 6, 5), "footrule")
compute_rank_distance(c(1, 6, 2, 5, 3, 4), c(4, 3, 5, 2, 6, 1), "spearman")
# Difference between a metric and a vector
# We set the burn-in and thinning too low for the example to run fast
data0 <- sample_mallows(rho0 = 1:10, alpha = 20, n_samples = 1000,
burnin = 10, thinning = 1)
compute_rank_distance(rankings = data0, rho = 1:10, metric = "kendall")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.