R/predict.mELO_rating.R
predict.mELO_rating.Rd
This function gives predictions of success probabilities for agent or
player 1 from a fitted ELO or mELO model (a mELO_rating
oject).
# S3 method for mELO_rating predict( object, new_match_data, min_games = 15, default_ratings = NULL, p1_advantage = 0, thresh )
object | An object of class |
---|---|
new_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. |
min_games | A single value. If the number of games of either player is
below this value, the prediction will be based on the |
default_ratings | The rating to be used for agents or players who have
not yet played |
p1_advantage | Player 1 advantage parameter. A single value or numeric
vector with length equal to the number of rows in |
thresh | A single value. If given, a binary vector is returned indicating whether the prediction is greater than this value. |
A numeric vector of predictions, which may contain missing values.
#> # A tibble: 6 x 4 #> time_index throw_1 throw_2 outcome #> <int> <chr> <chr> <dbl> #> 1 1 PAPER ROCK 1 #> 2 2 ROCK SCISSORS 1 #> 3 3 SCISSORS PAPER 1 #> 4 4 ROCK PAPER 0 #> 5 5 SCISSORS ROCK 0 #> 6 6 PAPER SCISSORS 0#> #> ELO Ratings For 3 Players Playing 120 Games #> #> Player Rating Games Win Draw Loss Lag #> 1 SCISSORS 2204.6 80 40 0 40 0 #> 2 ROCK 2204.6 80 40 0 40 1 #> 3 PAPER 2190.7 80 40 0 40 0 #>#> time_index throw_1 throw_2 outcome ELO_preds #> 1 1 PAPER ROCK 1 0.4799619 #> 2 2 ROCK SCISSORS 1 0.4999898 #> 3 3 SCISSORS PAPER 1 0.5200482 #> 4 4 ROCK PAPER 0 0.5200381 #> 5 5 SCISSORS ROCK 0 0.5000102 #> 6 6 PAPER SCISSORS 0 0.4799518# Predictions are all ~0.5 # Fit a mELO model that can handle these types of interactions. rps_mELO <- mELO(rps_df, k=1) rps_mELO#> #> mELO Ratings For 3 Players Playing 120 Games #> #> k = 1. #> #> Player Rating Games Win Draw Loss Lag #> 1 SCISSORS 2206.2 80 40 0 40 0 #> 2 ROCK 2197.2 80 40 0 40 1 #> 3 PAPER 2196.7 80 40 0 40 0 #>#> PAPER ROCK SCISSORS #> PAPER 0.000 1145.892 -1129.229 #> ROCK -1145.892 0.000 1157.136 #> SCISSORS 1129.229 -1157.136 0.000# Get predictioncs mELO_preds <- predict( rps_mELO, head(rps_df) ) cbind( head(rps_df), mELO_preds )#> time_index throw_1 throw_2 outcome mELO_preds #> 1 1 PAPER ROCK 1 0.998632279 #> 2 2 ROCK SCISSORS 1 0.998654133 #> 3 3 SCISSORS PAPER 1 0.998579105 #> 4 4 ROCK PAPER 0 0.001367721 #> 5 5 SCISSORS ROCK 0 0.001345867 #> 6 6 PAPER SCISSORS 0 0.001420895# Much better predictions!