Elo ratings are a ubiquitous system for ranking individuals/teams who compete in pairs. They began as a chess rating system, designed by Arpad Elo, but have since spread to sports and elsewhere (here’s an application in education). As a result, there is a lot of info out there on how to compute Elo ratings, presumably because they’re easy to understand and surprisingly good at forecasting. Heck, pretty much all of Nate Silver’s 538 sports coverage revolves around it. Here’s their forecast going into the last Superbowl … I guess they called it?
But there are very, very few resources on how the ratings work. I don’t mean what the formula is, I mean why the formula is what it is. What is the deeper statistical truth going on here?
I’m going to take a schwack at this. I’ll explore the Elo ratings as weights of a logistic regression found through stochastic gradient descent. A few other resources mention or hint at this interpretation, but their explanations feel cursory at best to me. (This also helps me connect Elo to its more typical framing as an AR(1) autoregressive process, where things like 538’s autocorrelation adjustment come in, since SGD is itself interpretable this way too.)
My hope is that placing Elo in a statistical learning framework will allow us to extend it, or improve it.
CAVEAT: An ulterior motive of this post is to lure the casual sports analytics enthusiast into a deeper understanding of stats, so if you have a PhD in statistics and a lot of this seems pedantic … my bad. (Also, if you find errors, let me know!)
Let’s say Team and Team have Elo ratings and . They play a game against each other. This results in the update
and the corresponding update for . Here is the “k”-factor, if beats (0 otherwise) is the game outcome, and is the probability that wins the game. The k-factor captures how much impact a single game has on the ranking, so for example, 538 uses 20 for NFL games and 4 for MLB games. The probability of winning is defined as a weird base-10 sigmoid function of the difference in ratings:
That 400 is typically described as a “scale factor” (but why 400?). The base 10 comes because, for whatever reason, Arpad Elo decided to use odds instead of the typically odds.
For games with point spreads, we can also use Elo ratings to predict the spread: each game point corresponds to 25 Elo points (but why?).
This should all remind us of logistic regression. As a quick and dirty review, let’s say we have some data where and . We are interested in predicting an outcome given input .
First recall “odds” is defined as the probability of something happening divided by the probability it doesn’t (so 3:1 odds implies the thing has a 75% chance, since 0.75/0.25 = 3). Now define the “log-odds”
where we typically assume . Then note, by Bayes’ theorem,
This is the workhorse “sigmoid” function, usually written .
(And doesn’t it remind you of the Elo rating probability??)
If we now assume the log-odds can be written as a linear combination of the inputs (or more probabilistically, if we assume the conditional densities are Gaussian with a shared covariance matrix and equally likely classes), then
for some “weight” vector . Then the data likelihood can be written
which we’d like to maximize, or equivalently the negative log-likelihood
called the “cross-entropy,” which we’d like to minimize. Since (so nice!), the gradient turns out to be
which you should verify on a piece of scrap paper sometime when you’re feeling frisky.
(Notice each term in the sum here kinda looks like the term from the Elo update in Eq. \eqref{eq:elo} — more on this in a bit.)
There isn’t a closed-form solution to Eq. \eqref{eq:entropy_grad} like there is for, say, linear regression, but we can readily apply a numerical technique like gradient descent.
Gradient descent is the beautifully simple technique of looking for a minimum by taking small steps in the direction of the negative gradient, that is,
where controls how fast we update our estimate of (and could be adaptive, i.e. depend on ).
(Storytime: “first order” methods like gradient descent — so-called because they only use the first order derivatives, as opposed to second-order methods like Newton-Raphson — were once dismissed as too simplistic and slow, but found redemption in the age of big data (we need it to be simple!) and fast computers (not slow anymore!).)
Now notice, when the dataset is very large, the sum happening in is very large, and so we are evaluating a very large function at every step of the algorithm.
It turns out, you can just evaluate the gradient at one of the terms in the sum, and move in that direction, and you will still provably reach a minimum, so long as you keep picking random terms and you do it enough times! This is absolutely magical to me.
This is called stochastic gradient descent, and so for logistic regression would look like
This is looking eerily familiar. We’re almost there.
Let’s connect Elo to all this. For a concrete running example, consider the NFL. The weight vector is now the ratings of all 32 teams. Let’s denote a specific game between teams and as the datapoint , where
and if wins, 0 if wins. The class conditional probability of winning is then
since or in Elo notation, . Then given some initial estimate of the weight vector , we can hone our estimate of the weights by iteratively applying an SGD step on the data,
or being a little more explicit,
Take a second and confirm: the only two lines where anything’s going on out of this update correspond to the two Elo update equations for a game up in Eq. \eqref{eq:elo}. Lots of signs flipping back and forth, and don’t forget , but they’re the same!
(Yes, instead of log-odds defined , Elo uses , but this amounts to a rescaling.)
This sparse input vector thing I haven’t seen elsewhere, and it does seem weird. It seems strange that you could encode the entire dataset with , and it seems strange that the effective space of the input data is strictly less than the original dimension.
Anyway, from a high level, Elo ratings are actually weights of a logistic regression to predict pairwise game outcomes, which we learn through SGD-like updates over streaming data.
This was a quick look at a statistical learning interpretation of the Elo rating system. Some other topics I’d like to explore:
538’s ratings incorporate margin of victory and an autocorrelation remediation term in their learning rate . Margin of victory seems to fit in as a use of “side-information” to create an adaptive learning rate. The autocorrelation factor is better understood as a correction term with Elo as an autoregression. I get the idea of why this term should be here, but not why 538 chose the form it uses.
A typical extension to SGD is doing a sum over some of the terms in , called a “mini-batch.” Technically, doing all the Elo updates for a week of NFL football counts as a minibatch, but not in spirit, since it gives us the same parameter estimates as before. What happens if we batch entire months, or seasons?
A common improvement to first order methods like GD/SGD is incorporation of momentum. (Here’s a beautiful Distill.pub article about it.) A simple example is the following modified gradient step:
Now, if we took a large “step” on our last update, we will take a large-ish step again, even if our gradient is small. This helps propel us through potentially long, flat portions of the error function surface. In the context of Elo ratings, this amounts to giving a team a little bump in ratings even if they had an unimpressive victory, so long as they had a blowout victory the week before.