elo (version 2.1.1)

elo.run: elo.run

Description

Calculate Elos for a series of matches.

Usage

elo.run(formula, data, na.action, subset, k = NULL, initial.elos = NULL, ...)

elo.run2( formula, data, na.action, subset, k = NULL, initial.elos = NULL, ..., prob.fun = elo.prob, update.fun = elo.update )

Arguments

formula

A formula. See the help page for formulas for details.

data

A data.frame in which to look for objects in formula.

na.action

A function which indicates what should happen when the data contain NAs.

subset

An optional vector specifying a subset of observations.

k

A constant k-value (or a vector, where appropriate).

initial.elos

An optional named vector containing initial Elo ratings for all teams in formula.

...

Other arguments (not used at this time).

prob.fun

A function with at least 4 arguments: elo.A, elo.B, adjust.A, and adjust.B. It should return a predicted probability that team A wins. The values passed in will be scalars, and a scalar is expected as output.

update.fun

A function with at least 6 arguments: the same as elo.update.default. The function takes in the Elos, the win indicator, k, and any adjustments, and returns a value by which to update the Elos. The values passed in will be scalars, and a scalar is expected as output.

Value

An object of class "elo.run" or class "elo.run.regressed".

Details

elo.run and elo.run2 by default return the exact same thing. elo.run uses C++ and may be up to 50 times faster, while elo.run2 uses R but also supports custom update functions. Prefer the first unless you really need a custom update function.

See Also

score, elo.run.helperselo.run helpers, elo.calc, elo.update, elo.prob, elo.model.frame.

Examples

Run this code
# NOT RUN {
data(tournament)
elo.run(score(points.Home, points.Visitor) ~ team.Home + team.Visitor,
        data = tournament, k = 20)

# Create non-constant 'k'
elo.run(score(points.Home, points.Visitor) ~ team.Home + team.Visitor +
        k(20*log(abs(points.Home - points.Visitor) + 1)), data = tournament)

# Adjust Elo for, e.g., home-field advantage
elo.run(score(points.Home, points.Visitor) ~ adjust(team.Home, 30) + team.Visitor,
        data = tournament, k = 20)

tournament$home.field <- 30
elo.run(score(points.Home, points.Visitor) ~ adjust(team.Home, home.field) + team.Visitor,
        data = tournament, k = 20)

# Regress the Elos back toward 1500 at the end of the half-season
elo.run(score(points.Home, points.Visitor) ~ adjust(team.Home, 30) +
        team.Visitor + regress(half, 1500, 0.2), data = tournament, k = 20)

# }

Run the code above in your browser using DataLab