6

Currently I try to understand the Ranked Pairs method. From the Wikipedia entry I don't really get how to create the matrix of pairwise comparison. This explanation helped me to understand one way to compare the pairs - still, I'm not sure if this is exactly what is said in wiki. My first question is, whether the comparison of pairs in 2 is valid according to 1?

I managed to adapt the explanation in 2 into R code:

In follwoing (unrealistic) example there are more candidates (rows) than voters (columns), but all voters give a rank to each candidate (full rankings)

# some random example
random.example <- matrix(rnorm(50), ncol = 5, 
                         dimnames = list(candidates = paste("c", 1:10, sep=""), 
                                         voters = paste("v", 1:5, sep="")))
rmat <- apply(random.example, MARGIN = 2, rank, ties.method = "f")

The rank matrix is then ranked with Ranked Pairs method

pm <- apply(rmat , MARGIN=1, function(x) {
  return(apply(rmat , MARGIN=1, function(y) {
    return(sum(x > y) - sum(x < y))
  }))
})

sorted <- apply(pm , MARGIN=1, function(x, numberOfVoters) {
  return(c(like    = sum(x > 0), 
           dislike = numberOfVoters - sum(x < 0), 
           ties    = numberOfVoters - (sum(x == 0) - 1))) 
}, numberOfVoters = ncol(rmat)))

Comment on sorted : If I understand this right, then we need first to order by the like, then dislike, then by ties. I reassigned the values of dislike and ties (numberOfVoters) so that I can use it as a "number". This leads to my next question: sorting and determining the winner. I think, but I'm not sure, where I can just sort by the number with base of |candidates|:

scores <- apply(sorted  * (ncol(sorted) ^ c(2,1,0)), MARGIN=2, sum)

And so ranking by the scores (higher are better) gives us a ranking. Right?

The third question regards the interation to determine the ranking of candidates. The ranking by scores gives us a ranked list of candidates. But Wikipedia 1 tells that for true ranking the whole procedure should be recalculated by removing the winner from the list to determine the next winner. And I don't understand why this may return a different ranking. Has anybody a simple example?

Thank a lot!

Drey
  • 3,314
  • 2
  • 21
  • 26

0 Answers0