eloratingopt: Create daily ML fitted Elo ranks and multiple derivatives

Description Usage Arguments Details Value Examples

View source: R/eloratingopt.R

Description

Conducts optimized elo rating analyses as per Foerster, Franz et al and outputs raw, normalized, cardinal, and categorical ranks as a list object in R or in an output file. For non-optimized Elo score calculation, use eloratingfixed.

Usage

1
2
eloratingopt(agon_data, pres_data, fit_init_elo = FALSE, outputfile = NULL, 
  returnR = TRUE)

Arguments

agon_data

Input data frame with dominance interactions, should only contain Date, Winner, Loser. Date should be formatted as MONTH/DAY/YEAR, or already as Date class.

pres_data

Input data frame with columns "id", "start_date" and "end_date". Date columns should be formatted as MONTH/DAY/YEAR, or already as Date class. If all IDs are present the whole time, you can ignore this and a pres_data table will be automatically generated.

fit_init_elo

If FALSE (the default), fits only the K parameter, with a default starting Elo score of 1000 for each individual. If TRUE, fits K and starting Elo for each individual. The latter option is much slower.

outputfile

Name of csv file to save ranks to. Default is NULL, in which case the function will only return a table in R. If you supply an output file name the function will save the results as a csv file in your working directory.

returnR

whether to return an R object from the function call. Default is TRUE

Details

This function accepts a data frame of date-stamped dominance interactions and (optionally) a data frame of start and end dates for each individual to be ranked, and outputs daily Elo scores with K parameter, and optionally initial elo scores, fitted using a maximum likelihood approach. The optimization procedure uses the optim() function, with a burn in period of 100 interactions. We use the "Brent" method when fitting only the K parameter, and the "BFGS" method for fitting both K and initial Elo scores. See optim for more details. Future package development will add additional user control of the optimization procedure, allowing for specification of the burn in period, optimization algorithm, and initial values for optimization.

Note also that the fitting procedure requires each individual to have at least one win and one loss, so any individual that doesn't meet those criteria is automatically removed. Additionally, any instance of an individual winning against itself is cleaned from the data, and several other checks of the data are performed before the optimization procedure is run.

A detailed description of the function output is given in the Value section of this help file:

Value

Returns a list with five or six elements (depending on input):

Examples

1
2
3
nbadata = EloOptimized::nba #nba wins and losses from the 1995-96 season
nbaelo = eloratingopt(agon_data = nbadata, fit_init_elo = FALSE)
# generates optimized elo scores (optimizing only K) and saves them as "nbaelo" 

EloOptimized documentation built on May 2, 2019, 10:39 a.m.