| pairwise | R Documentation |
Convenience functions to generate likelihoods for pairwise comparisons.
pairwise(M)
zermelo(M, maxit = 100, start, tol = 0, give = FALSE)
home_away(home_games_won, away_games_won, monster="home")
home_away3(home_games_won, away_games_won, lambda)
home_away_table(a, give=FALSE, teams)
white_draw3(A, lambda, D)
M |
Matrix of pairwise comparison results |
maxit |
Maximum number of iterations |
start |
Starting value for iteration; if missing, use
|
tol |
Numerical tolerance for stopping criterion |
give |
In |
home_games_won, away_games_won |
Matrices showing home games won and away games won |
monster |
The monster, with default |
lambda |
The home ground advantage (or white advantage in chess) |
D |
Weight of draw |
A |
Array of dimension |
a, teams |
In function |
Function pairwise(M) takes a M, a matrix of pairwise
comparisons and returns a hyper2 likelihood function. If there
are only two competitors, so M is 2-by-2, it might be better to
use dirichlet() or race() with 2 players, or one of
the pick() quartet.
Function home_away() takes two matrices, one for home wins and
one for away wins. It returns a hyper2 support function that
includes a home advantage monster [or indeed any systematic
advantage]. Set the monster to NULL if the home advantage is
not present. Function home_away3() is the same, but returns a
hyper3 object. A complex matrix is interpreted as real parts
being the home wins and imaginary parts away wins.
Function home_away_table() takes a dataframe of results (each
row being a single match) and returns a table amenable to analysis by
home_away() or home_away3(). If give takes its
default value of FALSE, draws are discarded and a complex
matrix of wins and losses is returned. Files
inst/monster_vs_lambda.Rmd and inst/home_advantage.Rmd
show some use-cases. Argument teams is a character vector that
specifies the teams to be tabulated (useful if one wishes to change
the default ordering of the teams).
Function white_draw3() returns a hyper3 likelihood
function for pairwise comparisons, one of whom has a home team-type
advantage (white player in the case of chess). It is designed to
work with an array of dimensions n\times n\times 3,
where n is the number of players. It is used in
inst/kka.Rmd to create chess3 likelihood function.
If home_games_won is complex, then the real parts of the
entries are interpreted as home games won, and the imaginary parts as
away games won.
Function zermelo() implements a standard iterative procedure
for maximization of pairwise Bradley-Terry likelihoods (such as those
produced by function pairwise()). It takes a matrix of
pairwise comparisons; the diagonal is disregarded. The process keeps
going until the difference between successive estimates does not
exceed argumet tol; note that tol=0 is acceptable. If
give=TRUE, a matrix with rows corresponding to successive
approximations is returned; if so, argument maxit corresponds
to the maximum number of rows.
An extended discussion of pairwise() is given in
inst/zermelo.Rmd and also inst/karate.Rmd. Functions
home_away() and home_away3() are described and used in
inst/home_advantage.Rmd; see Davidson and Beaver 1977.
Experimental function pair3() is now removed as
dirichlet3() is more general and has nicer idiom;
pair3(a=4, b=3, lambda=1.88) and dirichlet3(c(a=4, b=3),
1.88) give identical output.
Robin K. S. Hankin
D. R. Hunter 2004. “MM algorithms for generalized Bradley-Terry models”. The Annals of Statistics, volume 32, number 1, pages 384–406
S. Borozki and others 2016. “An application of incomplete pairwise
comparison matrices for ranking top tennis
players”. arXiv:1611.00538v1 10.1016/j.ejor.2015.06.069
R. R. Davidson and R. J. Beaver 1977. “On extending the Bradley-Terry model to incorporate within-pair order effects”. Biometrics, 33:693–702
maxp
#Data is the top 5 players from Borozki's table 1
M <- matrix(c(
0,10,0, 2,5,
4, 0,0, 6,6,
0, 0,0,15,0,
0, 8,0, 0,7,
1 ,0,3, 0,0
),5,5,byrow=TRUE)
players <- c("Agassi","Becker","Borg","Connors","Courier")
dimnames(M) <- list(winner=players,loser=players)
M
# e.g. Agassi beats Becker 10 times and loses 4 times
pairwise(M)
zermelo(M)
# maxp(pairwise(M)) # should be identical (takes ~10s to run)
M2 <- matrix(c(NA,19+2i,17,11+2i,16+5i,NA,12+4i,12+6i,12+2i,19+10i,
NA,12+4i,11+2i,16+2i,11+7i,NA),4,4)
teams <- LETTERS[1:4]
dimnames(M2) <- list("@home" = teams,"@away"=teams)
home_away(M2)
home_away(M2, monster = NULL) # nullify the home ground monster
# home_away3(M2,lambda=1.2) # works but takes too long (~3s)
home_away3(M2[1:3,1:3],lambda=1.2)
M <- kka_array[,,1] + 1i*kka_array[,,3] # ignore draws
home_away(M)
# home_away3(M,lambda=1.3) # works but takes too long (~3s)
white_draw3(kka_array,1.88,1.11)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.