ELO: Calculate ELO ratings

Description Usage Arguments Value References Examples

View source: R/ELO.R

Description

This function implements the ELO rating system for performing pairwise comparisons.

Usage

1
2
3
4
5
6
7
8
9
ELO(
  match_data,
  init_data = NULL,
  init_rating = 2200,
  eta = 27,
  p1_advantage = 0,
  save_history = TRUE,
  sort = TRUE
)

Arguments

match_data

A data frame containing four columns: (1) a numeric vector denoting the time period in which the game took place (2) a numeric or character identifier for player one (3) a numeric or character identifier for player two and (4) the result of the game expressed as a number, typically equal to one for a player one win, zero for a player two win and one half for a draw.

init_data

Initialise a rating model with ratings component of the returned list of the output from a previous ELO() call or a data.frame with columns Player and Rating.

init_rating

The initial rating for players not appearing in init_data.

eta

The learning rate.

p1_advantage

Player 1 advtange parameter. Either a single value or a vector equal to the number of rows in match_data.

save_history

If TRUE return the rating history for each player.

sort

If TRUE, sort the output ratings from highest to lowest.

Value

A list object of class "mELO_rating" with the following components:

ratings

A data frame of the results at the end of the final time period. The variables are self explanatory except for Lag, which represents the number of time periods since the player last played a game. This is equal to zero for players who played in the latest time period, and is also zero for players who have not yet played any games.

history

An array containing the ratings history for all players.

p1_advantage

A single value or a vector values for the advantage Player 1 had.

eta

The learning rate.

type

The type of model. In this case, "ELO".

preds

The player 1 success probabilities predicted prior to adjusting to the outcome of the match.

outcomes

The outcome for player 1 for each match.

preds_logloss

The mean logloss error for all predictions.

References

Elo, Arpad (1978) The Rating of Chessplayers, Past and Present. Arco. ISBN 0-668-04721-6.

Examples

1
2
3
4
# AFL data
head(afl_df)
afl_ELO_ratings <- ELO(afl_df[1:4], eta = 20, p1_advantage = 70)
afl_ELO_ratings

dclaz/mELO documentation built on May 17, 2021, 2:27 a.m.