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

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

# AFL data head(afl_df)
#> # A tibble: 6 x 7 #> match_index home_team away_team outcome date home_score away_score #> <int> <chr> <chr> <dbl> <date> <int> <int> #> 1 1 Richmond Melbourne 1 2000-03-08 94 92 #> 2 2 Essendon Port Adela~ 1 2000-03-09 156 62 #> 3 3 North Melbou~ West Coast 0 2000-03-10 111 154 #> 4 4 Adelaide Footscray 0 2000-03-11 108 131 #> 5 5 Fremantle Geelong 0 2000-03-11 107 129 #> 6 6 St Kilda Sydney 0 2000-03-12 100 134
afl_ELO_ratings <- ELO(afl_df[1:4], eta = 20, p1_advantage = 70) afl_ELO_ratings
#> #> ELO Ratings For 18 Players Playing 3887 Games #> #> Player Rating Games Win Draw Loss Lag #> 1 Richmond 2392.3 454 215 5 234 0 #> 2 West Coast 2340.3 468 254 4 210 4 #> 3 Geelong 2329.6 475 309 5 161 2 #> 4 Collingwood 2294.9 472 266 3 203 1 #> 5 GWS 2285.7 187 82 3 102 0 #> 6 Hawthorn 2282.1 471 276 2 193 12 #> 7 Sydney 2235.3 477 280 5 192 16 #> 8 Adelaide 2232.5 464 259 1 204 11 #> 9 Port Adelaide 2217.1 462 240 3 219 9 #> 10 Footscray 2207.2 458 213 4 241 6 #> 11 Essendon 2204.7 457 222 5 230 8 #> 12 North Melbourne 2184.2 457 227 3 227 15 #> 13 Brisbane Lions 2146.5 459 209 4 246 3 #> 14 Melbourne 2124.1 452 172 3 277 15 #> 15 Fremantle 2116.1 455 212 1 242 9 #> 16 St Kilda 2089.0 457 207 8 242 16 #> 17 Carlton 2001.0 451 165 4 282 14 #> 18 Gold Coast 1917.4 198 47 1 150 13 #>