The Massey Ranking Algorithm - drnickmines/MinesLinearAlgebra GitHub Wiki
Today we will see an application of least squares that is not finding a best fitting curve!
Ranking is a simple idea: put a list of things in order of importance. A good deal of money and effort is put into ranking:
- Sports teams
- Internet pages (how does a search engine know which of a million pages about linear algebra it should show us first?)
- Business (what things should we prioritize in our marketing?)
- Universities (US News and World Report rankings)
- Video games (I'm Bronze in Overwatch)
In this lesson, we'll learn about a widely used algorithm to rank sports teams.
Ranking sports teams is a difficult problem because it usually involves inconsistent data. Consider this small example from the 2025 college football season:
- Wake beat NC State 34-24
- NC State beat VaTech 32-21
- VaTech beat Wake 30-23
Clearly, Wake is better than NC State, and NC State is better than VaTech, and VaTech is better than Wake...this is inconsistent! Now imagine a season with over 800 games! It's very overdetermined.
In the 1990's, Ken Massey, then a graduate student in mathematics and Virginia Tech, developed a ranking system based on least squares solutions.
The issues described above is that the data are inconsistent. Remember, this is precisely what a least squares approach is for! Since there is no solution when there are so many equations (hundreds of games) and so few unknowns (number of teams), we will attempt to fit the sports data with a "best fitting" solution.
If we want to take a least squares approach to a football season, we need a way to turn games into equations. Here's what Massey proposed:
- If Wake beats NCState 34-24, we write
$\large r_W-r_{NCState}=10$ . - Here, the unknowns are the rankings:
$\large r_W$ for Wake, and$\large r_{NCState}$ for NC State. - The 10 in the equation is the margin of victory for the game.
- Essentially, we can read this equation as "If Wake beat NC State 34-24, then Wake is 10 points better than NC State".
We will have one equation like the one above for every game played in the season!
As we develop this method, it will be helpful to keep a running example. We'll use a set of games from the 2024 SEC college football season. There were 6 teams that all finished with a 5-3 record (that's 5 wins and 3 losses) in the conference that season. How do we rank them if they had the same record? Here's the information we'll use:
| Team | Bama | LSU | USC | A&M | Ole Miss | Mizzou |
|---|---|---|---|---|---|---|
| Bama | - | 42-13 | 27-25 | - | - | 34-0 |
| LSU | 13-42 | - | 36-33 | 23-38 | 29-26 | - |
| USC | 25-27 | 33-36 | - | 44-20 | 3-27 | 34-30 |
| A&M | - | 38-23 | 20-44 | - | - | 41-10 |
| Ole Miss | - | 26-29 | 27-3 | - | - | - |
| Mizzou | 0-34 | - | 30-34 | 10-41 | - | - |
In this small case, we have
If we write this as
We have an
Note
For a full season in most scenarios,
What do we do? The least squares solution will minimize the distance between
Let's call
There are some patterns here. The following always ends up being true:
- For the diagonal entries:
$\large M_{i,i}=$ the number of games played by team$\large i$ . - For the other entries:
$\large M_{i,j}=$ the negative of the number of games played by team$\large i$ against team$\large j$ .
Note
In college football, teams typically only play each other once, so we have a lot of -1's in the matrix above. In other sports, say baseball or basketball, teams play each other more than once, so those numbers would look different.
For our example, the full normal equations are:
What is the right hand side
In the end, we have a system:
where
Remember that the rank of a matrix (the dimension of the column space, or the number of linearly independent rows or columns of a matrix) is a measure of how much redundant information is in the matrix. Our matrix
Massey's solution to this issue was to simply throw out one row (since it contains redundant information) and to replace it with a row of 1's (with a zero in the corresponding spot in
Important
It sure feels like we are throwing away information here, but we aren't. There was a redundancy in the information, and we've removed it. It's not magic; it's linear algebra!
Note
We replaced the last row, but it doesn't matter which row we replace. The solution will be the same in the end.
The result of this is a new matrix
It simply forces the rankings to add up to zero; it doesn't affect them otherwise.
With a full rank matrix, we are now ready to proceed.
Let's go ahead and ask Python to solve our system. We get
Putting these in order, we get a ranking of Alabama, Ole Miss, USC, LSU, A&M, and Mizzou.
Note
The relative sizes of the numbers in
I can:
- Convert a game (or small set of games) into an equation (or a system of equations) in the style of the Massey method.
- Set up a Massey ranking system of equations
$\large M\vec{r}=\vec{p}$ based on a set of games (either by hand for a small set of games or in Python for a larger set). - Replace a row in
$\large M$ to make it full rank (and explain why this is necessary). - Interpret the output
$\large \vec{r}$ of the Massey method as a ranking.