Rankings

Colley method

library( mau )
# Example without ties
d <- 10
n <- matrix( sample( x = 0:5, size = d * d, replace = TRUE ), d, d )
n <- n + t( n )
diag( n ) <- 0
g <- rowSums( n )
# Number of win matches for each team
w <- sapply( 1:d, FUN = function( i ) sample( x = 1:g[i], size = 1, replace = TRUE ) )
# Number of lost matches for ech team
l <- rowSums( n ) - w
r <- colley_rating( n, w, l )
print( r )
## [[1]]
##  [1] 10  6  2  5  3  4  8  7  1  9
## 
## [[2]]
##  [1] 2.838612 3.383796 3.576764 3.461508 3.537240 3.477859 3.027758 3.155513
##  [9] 3.622417 2.918533

Offensive - Defensive rating method

A <- matrix( c( 0, 7, 21, 7, 0,
                52, 0, 34, 25, 27, 
                24, 16, 0, 7, 3,
                38, 17, 5, 0, 14,
                45, 7, 30, 52, 0 ), 
             nrow = 5, ncol = 5 )
r <- od_rating( A )
print( r )
## $r
##           [,1]
## [1,]  20.09702
## [2,] 188.78533
## [3,]  41.79470
## [4,]  84.80018
## [5,] 279.80681
## 
## $o
##           [,1]
## [1,]  33.98927
## [2,] 151.57374
## [3,]  48.66316
## [4,]  82.04849
## [5,] 114.83557
## 
## $d
##           [,1]
## [1,] 1.6912590
## [2,] 0.8028894
## [3,] 1.1643379
## [4,] 0.9675509
## [5,] 0.4104102
## 
## $iter
## [1] 27

Borda counts

We take \(C\) the finite set of options of candidates, ranking matrix \(R \in C^{m\times n}\), number of votes for each case \(v \in \mathbb{R}^n\), \(u \in \mathbb{R}^m\) weights for each rank, \(N = |C|\) number of options or candidates, \(l : C \longrightarrow \{1, \ldots, N\}\) labels by option, \(W \in \mathbb{R}^{N \times n}\) the ranking matrix. For each \(i \in \{1, \ldots, N\}\) and \(j \in \{1, \ldots, n\}\) we compute \[ k = l( R_{i,j} ), \qquad W_{k,j} = u_i \]

\(\text{order}\) returns the order index of a vector. \[ w = W v,\qquad r = \text{order}( w ) \]

# Position of each participant
R <- matrix( c( 2, 3, 1, 3, 1, 2, 1, 2, 3 ), nrow = 3, ncol = 3 )
v <- c( 7, 5, 2 )
bc <- borda_count( R, v )
print( bc )
## $rank
## 1 2 3 
## 3 2 1 
## 
## $vrank
##  1  2  3 
## 23 30 31 
## 
## $mranks
##   [,1] [,2] [,3]
## 1    1    2    3
## 2    3    1    2
## 3    2    3    1
## 
## $labels
## 1 2 3 
## 1 2 3 
## 
## $mlabels
##      [,1] [,2] [,3]
## [1,]    2    3    1
## [2,]    3    1    2
## [3,]    1    2    3
R <- matrix( c( 'A', 'B', 'C', 'B', 'A', 'C', 'C', 'A', 'B' ), nrow = 3, ncol = 3 )
v <- c( 5, 4, 3 )
bc <- borda_count( R, v )
print( bc )
## $rank
## A B C 
## 1 2 3 
## 
## $vrank
##  A  B  C 
## 29 25 18 
## 
## $mranks
##   [,1] [,2] [,3]
## A    3    2    2
## B    2    3    1
## C    1    1    3
## 
## $labels
## A B C 
## 1 2 3 
## 
## $mlabels
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    2    1    1
## [3,]    3    3    2
R <- matrix( c( 'Steak', 'Chicken', 'Barbacoa', 'Carnitas', 
                'Carnitas', 'Barbacoa', 'Chicken', 'Steak', 
                'Chicken', 'Carnitas', 'Steak', 'Barbacoa',
                'Steak', 'Barbacoa', 'Chicken', 'Carnitas' ), nrow = 4, ncol = 4 )
v <- c( 8, 7, 5, 3 )
bc <- borda_count( R, v )
print( bc )
## $rank
## Barbacoa Carnitas  Chicken    Steak 
##        4        3        1        2 
## 
## $vrank
## Barbacoa Carnitas  Chicken    Steak 
##       51       54       64       61 
## 
## $mranks
##          [,1] [,2] [,3] [,4]
## Barbacoa    2    3    1    3
## Carnitas    1    4    3    1
## Chicken     3    2    4    2
## Steak       4    1    2    4
## 
## $labels
## Barbacoa Carnitas  Chicken    Steak 
##        1        2        3        4 
## 
## $mlabels
##      [,1] [,2] [,3] [,4]
## [1,]    4    2    3    4
## [2,]    3    1    2    1
## [3,]    1    3    4    3
## [4,]    2    4    1    2
R <- matrix( c( 'A', 'B', 'C', 'B', 'A', 'C', 'C', 'A', 'B' ), nrow = 3, ncol = 3 )
v <- c( 5, 4, 3 )
u <- c( 6, 4, 2 )
bc <- borda_count( R, v, u )
print( bc )
## $rank
## A B C 
## 1 2 3 
## 
## $vrank
##  A  B  C 
## 58 50 36 
## 
## $mranks
##   [,1] [,2] [,3]
## A    6    4    4
## B    4    6    2
## C    2    2    6
## 
## $labels
## A B C 
## 1 2 3 
## 
## $mlabels
##      [,1] [,2] [,3]
## [1,]    1    2    3
## [2,]    2    1    1
## [3,]    3    3    2