Functions to compute rating and ranking using Elo method.
1 2 3 4 5 6 7 8 9
rate_elo(cr_data, K = 30, ksi = 400, initial_ratings = 0) rank_elo(cr_data, K = 30, ksi = 400, initial_ratings = 0, keep_rating = FALSE, ties = c("average", "first", "last", "random", "max", "min"), round_digits = 7) add_elo_ratings(cr_data, K = 30, ksi = 400, initial_ratings = 0) elo(rating1, score1, rating2, score2, K = 30, ksi = 400)
Competition results in format ready for as_longcr().
K-factor for Elo formula.
Normalization coefficient for Elo formula.
Initial ratings (see Iterative ratings).
Whether to keep rating column in ranking output.
Rating of player1 before the game.
Score of player1 in the game.
Rating of player2 before the game.
Score of player2 in the game.
add_elo_ratings() are wrappers for
add_iterative_ratings() correspondingly. Rate
function is based on Elo algorithm of updating ratings:
Probability of player1 (with rating r1) winning against player2 (with
rating r2) is computed based on rating difference and sigmoid function:
P = 1 / (1 + 10^( (r2 - r1) / ksi ) ).
ksi defines the spread of ratings.
Result of the game from player1 perspective is computed based on rule:
S = 1 (if
S = 0.5 (if
S = 0 (if
Rating delta is computed:
d = K * (S - P). The more the
K the more the
delta (with other being equal).
New ratings are computed:
r1_new = r1 + d,
r2_new = r2 - d.
elo() function implements this algorithm. It is vectorized over all its
arguments with standard R recycling functionality. Note that not this
function is used in
add_elo_ratings() because of its not
appropriate output format, but rather its non-vectorized reimplementation is.
Ratings are computed based only on games between players of interest (see
rate_elo() returns a tibble with columns
player (player identifier) and
ratings, based on row order, by the end of competition
results). Bigger value indicates better player performance.
rank_elo() returns a
tibble with columns
keep_rating = TRUE) and
ranking_elo (Elo ranking
add_elo_ratings() returns a widecr form of
with four rating columns added:
rating1Before - Rating of player1 before the game.
rating2Before - Rating of player2 before the game.
rating1After - Rating of player1 after the game.
rating2After - Rating of player2 after the game.
elo() always returns a matrix with two columns containing ratings after the
game. Rows represent games, columns - players.
comperank offers a possibility to handle certain set of players. It is done
player column (in longcr format) as factor
with levels specifying all players of interest. In case of factor the result
is returned only for players from its levels. Otherwise - for all present
Wikipedia page for Elo rating system.
1 2 3 4 5 6 7 8 9 10 11 12 13
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.