Compute the Spearman foot-rule (L1) distance between two complete rankings of the same set of items. In the context of MaxDiff models, this is for comparing item rankings of two different models.
Details
The distance is the sum of absolute rank differences between the two
orderings. It equals zero when the rankings are identical and reaches its
maximum when one ranking is the exact reverse of the other. If
normalize = TRUE, the distance is divided by this maximum so that the
result lies between 0 and 1.
Examples
spearman_footrule(c("a", "b", "c"), c("a", "b", "c"))
#> [1] 0
#> 0
spearman_footrule(c("a", "b", "c"), c("a", "c", "b"))
#> [1] 0.5
#> 0.5
# biggest distance is between reversed sequences
spearman_footrule(c("a", "b", "c"), c("c", "b", "a"))
#> [1] 1
#> 1
# Without normalization
spearman_footrule(c("a", "b", "c"), c("c", "b", "a"), normalize = FALSE)
#> [1] 4
#> 4