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)

ranking rankSchool

In this lesson, we'll learn about a widely used algorithm to rank sports teams.

Ranking Sports Teams: Inconsistent

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.

rock paper scissors

Massey Ranking Algorithm

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!

Running Scenario: 2024 SEC football

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 $\large n=6$ teams and $\large m=10$ games. Our overdetermined system of equations is:

$$\large \begin{array}{cccccccccccr} r_1 & - & r_2 & & & & & & & & & = & 29 \\ r_1 & & & - & r_3 & & & & & & & = & 2 \\ r_1 & & & & & & & & & - & r_6 & = & 34 \\ & & r_2 & - & r_3 & & & & & & & = & 3 \\ & & r_2 & & & - & r_4 & & & & & = & -15\\ & & r_2 & & & & & - & r_5 & & & = & 3 \\ & & & & r_3 & - & r_4 & & & & & = & 24 \\ & & & & r_3 & & & - & r_5 & & & = & -24 \\ & & & & r_3 & & & & & - & r_6 & = & 4 \\ & & & & & & r_4 & & & - & r_6 & = & 31 \\ \end{array} $$

If we write this as $\large A\vec{x}=\vec{b}$, we have:

$$\large \begin{bmatrix} 1 & -1 & 0 & 0 & 0 & 0\\ 1 & 0 & -1 & 0 & 0 & 0\\ 1 & 0 & 0 & 0 & 0 & -1\\ 0 & 1 & -1 & 0 & 0 & 0\\ 0 & 1 & 0 & -1 & 0 & 0\\ 0 & 1 & 0 & 0 & -1 & 0\\ 0 & 0 & 1 & -1 & 0 & 0\\ 0 & 0 & 1 & 0 & -1 & 0\\ 0 & 0 & 1 & 0 & 0 & -1\\ 0 & 0 & 0 & 1 & 0 & -1\\ \end{bmatrix}\begin{bmatrix} r_1\\ r_2\\ r_3\\ r_4\\ r_5\\ r_6\\ \end{bmatrix}=\begin{bmatrix} 29\\ 2\\ 34\\ 3\\ -15\\ 3\\ 24\\ -24\\ 4\\ 31\\ \end{bmatrix} $$

We have an $\large A$ that is $10\times 6$. It is overdetermined, and the system is inconsistent.

Note

For a full season in most scenarios, $\large m$ (the number of games) is much larger than $\large n$ (the number of teams). This system is usually even more overdetermined than we have in this example!

What do we do? The least squares solution will minimize the distance between $\large A\vec{x}$ and $\large \vec{b}$. We proceed with the normal equations: $\large A^TA\vec{x}=A^T\vec{b}$.

The Normal Equations

Let's call $\large A^TA$ the Massey matrix $\large M$. We can compute it for the example. We get:

$$\large \begin{bmatrix} 3 & -1 & -1 & 0 & 0 & -1\\ -1 & 4 & -1 & -1 & -1 & 0\\ -1 & -1 & 5 & -1 & -1 & -1\\ 0 & -1 & -1 & 3 & 0 & -1\\ 0 & -1 & -1 & 0 & 2 & 0\\ -1 & 0 & -1 & -1 & 0 & 3\\ \end{bmatrix} $$

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:

$$\large \begin{bmatrix} 3 & -1 & -1 & 0 & 0 & -1\\ -1 & 4 & -1 & -1 & -1 & 0\\ -1 & -1 & 5 & -1 & -1 & -1\\ 0 & -1 & -1 & 3 & 0 & -1\\ 0 & -1 & -1 & 0 & 2 & 0\\ -1 & 0 & -1 & -1 & 0 & 3\\ \end{bmatrix}\begin{bmatrix} r_1\\ r_2\\ r_3\\ r_4\\ r_5\\ r_6\\ \end{bmatrix}=\begin{bmatrix} 65\\ -38\\ -1\\ 22\\ 21\\ -69\\ \end{bmatrix} $$

What is the right hand side $\large A^T\vec{b}$? Those numbers are the total point differential for each team. Alabama scored 65 more points than its opponents over the course of the season. Mizzou scored 69 fewer points that its opponents.

In the end, we have a system:

$$\large M\vec{r}=\vec{p}$$

where $\large M$ is an $\large n\times n$ matrix with the structure outlined above, $\large \vec{r}$ is an $\large n\times 1$ vector of the unknown rankings, and $\large \vec{p}$ is an $n\times 1$ vector with the total point differentials.

An Issue with Rank

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 $\large M$ is $\large n\times n$, but it's rank is only $\large n-1$. We have $\large n$ total rows but only $\large (n-1)$ linearly independent rows! There is redundant information in our system! The result is that $\large M\vec{r}=\vec{p}$ has infinitely many solutions (there is a free variable in the solution).

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 $\large \vec{p}$). For our example, we have:

$$\large \begin{bmatrix} 3 & -1 & -1 & 0 & 0 & -1\\ -1 & 4 & -1 & -1 & -1 & 0\\ -1 & -1 & 5 & -1 & -1 & -1\\ 0 & -1 & -1 & 3 & 0 & -1\\ 0 & -1 & -1 & 0 & 2 & 0\\ 1 & 1 & 1 & 1 & 1 & 1\\ \end{bmatrix}\begin{bmatrix} r_1\\ r_2\\ r_3\\ r_4\\ r_5\\ r_6\\ \end{bmatrix}=\begin{bmatrix} 65\\ -38\\ -1\\ 22\\ 21\\ 0\\ \end{bmatrix} $$

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 $\large M$ with full rank $\large n$. What does this new, invented row do to our system of equations? The equation from that row is just:

$$\large r_1+r_2+r_3+r_4+r_5+r_6=0$$

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.

The Solution and its Meaning

Let's go ahead and ask Python to solve our system. We get

$$\large \vec{r}=\begin{bmatrix} 15.37\\ -5.57\\ -0.17\\ -5.62\\ 9.13\\ -13.14\\ \end{bmatrix} $$

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 $\large \vec{r}$ matter. Alabama and Ole Miss are ranked much higher than the rest. And, even though we have LSU ahead of A&M, at -5.57 and -5.62, they are essentially the same. And poor Mizzou was much worse than the others.

Section Outcomes

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.
⚠️ **GitHub.com Fallback** ⚠️