# Single game player contribution metrics in basketball

While in the NBA you will rarely see a game’s stats sheet mention metrics like PER and PIR, this is quiet the norm for leagues around the world. In fact, these metrics are used to award game MVPs in these leagues – and as you can imagine many times the results are strange to say the least. Overall, the pitfalls of these type of metrics have been well-documented. Another alternative to PER and PIR, that one can also find in a boxscore in the NBA, is the raw +/-. When looking at the single game +/- and putting it in context of what happened in the game, then it can provide some useful information. However, if you just take this number at face value, then you get into problems similar with PER and PIR. It should also be evident that using an adjusted plus-minus regression approach (regularized or not) is going to be very noisy for a single game. Can we develop a method that approaches the adjusted plus/minus for whole season(s) but operates on a single game unit? (I will pretend that the single game box plus minus does not exist, so I have an excuse to use some ideas from game theory).

For basketball (and other sports in general) being a game, game theory has not been utilized enough – imo – to model interactions between teams, players, lineups etc. Given our objective, and the fact that teammates cooperate (at least we would hope they do) to achieve their goal of winning a game it is natural to look at tools used in cooperative game theory. An important concept – Nobel-important concept – in cooperative games is the Shapley value. Shapley values are a solution concept in such games. In brief, it assigns the surplus generated by a coallition of players, according to the contribution of each player to this total surplus. But wait, this sounds pretty much what we are trying to do for the players of a team in a single basketball game!

Let’s start with some definitions that will be useful for mapping our problem and data to the concept of Shapley values. In a coallition game we have a set $N$ of players and a characteristic function $v$, that is defined over the power-set of $N$; $v: 2^{N} \rightarrow \mathbb{R}$. The characteristic function captures the value of a coallition $\mathcal{S}\subseteq N$, and it essentially represents the expected sum of payoffs from the cooperation of the players in $\mathcal{S}$. The Shapley value of a player then distributes the total gain of the game to the players, in a fair manner. Fairness here is related to specific mathematical properties satisfied by the solution. While this is interesting by itself, it is out of the scope of this post, but you can read more about this and Shapley values in general here). However, just for completeness, here is the credit each player is allocated according to the Shapley value:

$\phi_i(v) = \sum_{\mathcal{S}\subseteq N \setminus \{i\}} \dfrac{|\mathcal{S}|!(n-|\mathcal{S}|-1)!}{n!}(v(\mathcal{S}\cup \{i\})-v(\mathcal{S}))$

Let’s now get back to our specific problem that we want to solve using the concept of Shapley values. In our case we have a team of basketball players, and the coach decides during the game which 5-player coallitions to play. For each one of those we also observe their value, which is the net rating the coallition (lineup) had during the game. Small sample sizes make its Bayesian adjustment more appropriate. So far so good, but from the definition of the characteristic function above, we can see that we need to define $v$, for each possible subset of the players in a team (those that played in the game). For coalitions with fewer than 5 players this is straightforward, and we can essentially obtain the net ratings for 2, 3, and 4-men lineups (and the on-off ratings for single players). However, the question is how to define the value of coalitions with more than 5 players. For this case we can aggregate the results from any lineup consisting exclusively of players in the coalition at hand. For example, if we want to estimate the value of the characteristic function for a coalition of 7 players, we will calculate the average net rating for any 5-man lineup played consisting only of players from this set of 7 players.

Let’s see an example here. Of course, I will choose one of Pitt’s games and let’s go with the first conference game of the season against Miami. Despite the fact that Miami had only 6 or 7 scholarship players available for the game, they fought well (partially due to early foul troubles for Champagnie and Johnson) before Pitt eventually got away in the latter part of the second half with a 70-55 win. Using the excellent R package from Jake Flancer, bigballR, I was able to obtain the lineup information needed to calculate the Shapley Player Value (SPV) for that game (code is available here).

These SPV values essentially consider all the different lineups that played for Pitt in that game and how they performed, and assigned a net rating to each player. According to SPV, Toney was the game MVP for Pitt (which also passes my eye test for that game). Coulibaly also played nice in that game and made contributions that would not be captured by bean counting his points and rebounds and had an SPV of +9.6. Now this is not to say that SPV is better than any other single-game metric. Far from it. How would even one go about showing this? SPV is just a “credit allocation” approach and there is no ground truth (if there was we would not need SPV or any other metric). However, I believe it looks at the contribution of players during a game more hollistically compared to other single game player ratings. Furthermore, Shapley values are able to deal with colinearity fairly well.

Some limitations of SPV is that it does not consider who was on the court from the opposing team when a specific player “coalition” was on the court. However, I would argue that for a single game – and for a descriptive metric – this might not be a big problem (if at all). At the end of the day, SPV allocates credit to players according to who contributed to the team for that specific game. If a player faced the second unit of the opponent but made significant contributions towards winning that specific game, so be it. SPV’s goal is not to predict the future performance of this player. For that, regularized adjusted plus/minus approaches are clearly better. However, there is an interesting question here on whether a similar approach can be used for estimating player ratings when we only have information about the lineups of a team (e.g., from the NBA stats website) and not which opponents they faced – and hence, we cannot run the +/- regression. One of the challenges is that the computation becomes intractable when more than 10-12 players are involved. For a single game this is rarely the case, but for lineups over a season the number of players involved can easily go way over this. Of course, time/possession limits can be applied and players with few minutes can be grouped together, but certainly more work is needed if one wants to apply the concept of Shapley values to season-long player ratings.