Friday, September 26, 2014

Offensive and Defensive Rating & Win %

Looking at team data, I was interested in understanding how effective team offensive and defensive rating serve as a measure of success. Offensive rating measures a team's points scored per 100 possessions. Conversely, defensive rating measures a team's points allowed per 100 possessions. To measure success I used regular season win %. I pulled historical team data from the 1950-51 through the 2013-14 regular seasons from basketball-reference.com. Because basketball-reference.com doesn't provide raw data for analysis, I used excellent code I found here*, which allowed me to loop the URLs for all teams for all seasons.

Before I simply plotted individual team offensive and defensive rating, I looked at the league average for each measure over the last 63 seasons to see if there was a trend. The chart below, which plots NBA regular season mean offensive rating on the left side and mean defensive rating on the right side illustrate two things. First, the ratings mirror each other. This makes sense because for one team to have a more offensively productive season there has to be another team(s) that gives up those points. When aggregated across the league for a given year the offensive and defensive ratings become quite close (usually the difference is tenths or hundredths of a point).

Second, and more importantly, from the 1950s until the early 1980s NBA offensive production soared from about 85 points per 100 possessions to about 108 points per 100 possessions. (The NBA shot clock was introduced in the 1954-55 season so its not like a technical rule change was responsible for this increase.) This high offensive output plateaued in the 1980s and 1990s, but dropped to about 100 points per offensive possession in the late 1990s and early 2000s. By the mid-2000s it picked up slightly but even last season is about 5 points per 100 possessions off the league mean peak established in the 1980s and 1990s. (So defenses appear to be adjusting to prolific offenses.)

The chart below matters because I cannot simply plot a team's offensive or defensive rating for a given season against win % because there were teams in the 1950s and 1960s that had a  high win % but had a much lower offensive rating than teams that played in the 1990s (that had a low win % but had a higher offensive rating) on account of the offensive zeitgeist of the 1990s. (In other words, I had to take into account the change in league-wide scoring over time.)


To account for the increase in scoring over time, I used relative offensive and defensive rating, which simply subtract a team's offensive/ defensive rating from the league mean for that specific season. As a result, it would be clear that a team in 1958 with a relative offensive rating of +10 (or about 100 points per 100 possessions) was better offensively than a team in 1988 with a relative offensive rating of -8 (which is also about 100 points per possession). The two plots below chart relative offensive rating (left side) and relative defensive rating (right side) against win % for all NBA teams that played from the 1950-51 season through the 2013-14 season. I included a blue regression line to help illustrate the relationship. Clearly, relative offensive rating is very positively correlated with win % and relative defensive rating is very negatively correlated with win %. Both make intuitive sense.


Looking at the plots, I was interested in those anomalies over the last 63 years. Below is the same plot on relative defensive rating but without the color and regression line. I identified those teams that were exceptionally deficient or successful. In terms of relative defensive rating, some of the worst teams in the history of the NBA were the 1998-99 Denver Nuggets, the 1981-82 Denver Nuggets, and the 2011-12 Charlotte Bobcats (the Bobcats set the NBA record for the worst win % this season). Some of the best ever were the 1995-96 Chicago Bulls, the 2007-08 Boston Celtics, and the mid-1960s Boston Celtics.


The best teams historically in terms of relative offensive rating were the 2003-04 Dallas Mavericks, the 2004-05 Phoenix Suns and the 1995-96 Chicago Bulls. Some of the most offensively deficient ever were the 1998-99 Chicago Bulls, the 1987-88 LA Clippers and the 2002-03 Denver Nuggets. It should come as no surprise that in the 1995-96 season when the Chicago Bulls set the NBA regular season record for wins (72) they were one of the best offensive and defensive teams relative to all other teams in the that season in the history of the NBA.


*One of the many amazing things about the internet are sites, like stackoverflow or github, that allow very smart people to share or explain complex coding just because they want to help people or to solve challenging problem (or, presumably--for some--for validation/ recognition).

Wednesday, September 3, 2014

Melo & LeBron: Career 30 game moving averages

Carmelo Anthony is a unique player in the NBA in that he is granted superstar status and money despite only reaching the conference finals once in his 12 year career. His critics have questioned his effort on defense and the adverse effect of his individual offensive play on his team. All this begs the question: Is Carmelo Anthony really a superstar? Considering that a big part of being a superstar in the NBA is fan appeal and scoring--two criteria Carmelo certainly exceeds in--the answer is 'yes'. However I'm interested if he will at the minimum maintain his offensive output when he begins his first full season as a thirty year old. To get a better picture of his performance I collected data on each of his regular season games over the course of his entire career from basketball-reference.com.  

I focused on three conventional statistics--points, field goal attempts (FGA) and plus/ minus. I wanted to see how he progressed in each statistics from his first regular season game to his most recent. I only included games where he played at least one minute which resulted in a population of 708 games. Simply plotting these three conventional statistics in chronological order from game 1 to game 708 would have created a visual mess as the variance between individual 'good' and 'bad' games would have had lines darting everywhere.

As a result, I took a technique common in stock charts to smooth the performance. I captured a moving 30 game average of  each statistic. This technique allows me to chart his performance over a sufficient amount of play, thus giving a better understanding of sustained performance as opposed to capturing anomalous high/ low output performances. To create the moving average, I did not include Carmelo's first 29 games of his career because those games are necessary (with the 30th game) to create the starting point for the 30 game moving average. As a result, the charts below actually capture 679 games (708 career games - Carmelo's first 29 games).

To give some idea as to how the chart progresses, the point for game 2 on the plot represents the 30 game average from his career game 2 through game 31. Point 3 represents the 30 game average from his career game 3 through game 32. All the way up to the final point, which represents the 30 game average for his career game 679 through game 708. (Obviously, all points are connected with a line.)

The top chart shows Carmelo's 30 game moving average for FGA (black) and points (grey). I included a dashed line signaling his career regular season average in points (25.3) and FGA (19.7). As expected Carmelo started off slow in his career, which makes sense because he was a rookie adjusting to the NBA. He appears to have peaked around his 200th game and outside of his rookie season his output reached its nadir around the 30 game moving average of 550, which coincides with his first season with the Knicks. Throughout his career his FGA and points seem to mirror each other, which also makes sense--you gotta take shots to make shots.

But if you look closely at the chart something else emerges--Carmelo needs a lot of shots to score all his points. Since he began his career with the Knicks (around what would be 550 on the horizontal axis) he appears to score only about five more points that FGA. Considering that he only averages about 3 assists a game this could challenge his efficacy as on offensive player.


But points and FGA can belie actual performance, especially if a player's teammates are of limited offensive means. The 2013-14 Knicks were certainly one such team as they had to rely disproportionately on Carmelo for offense. Opposing teams knew this and, thus, made it more difficult for him to succeed offensively. 

Plus/ minus is a very rough measure of overall performance but it does give some context as to the effect the player had on the outcome of the game while he was on the court. Carmelo's career plus/ minus average is 2.4 and the chart below shows that his 30 game moving average peaked at 7.9 and bottomed out at -3.5. Interestingly if you compare the chart below with the chart above, especially early in his career, Carmelo's plus/ minus appears indirectly related to his point/ FGA. In other words, the more he shot and scored the worst plus/ minus he had. 

Over the last 150 or so games of his career (almost his entire time with the Knicks), Carmelo seems to have fallen into a zone that hovers right around his career plus/ minus average of 2.4. In light of his prolific scoring, it is fair to question if a player that contributes just less than 2.5 points to the outcome of a game is worthy of the 'superstar' designation. 


Looking at just one player is limiting as it grants no context in comparison to the performance of others. As a result, I created the same charts for The superstar--LeBron. There is no comparing the two players as by every objective measure LeBron is a superior player. However, if a player, like Carmelo, is deigned a superstar then his performance should be measured against the highest criterion--LeBron.

For LeBron, I pulled the same data from basketball-reference.com and conducted the same analysis as I did for Carmelo. (Because LeBron has player one more season, he's played at least one minute in 842 regular season games.) The chart below shows LeBron's career regular season 30 game moving average for points (grey) and FGA (black). There is clearly a wider margin between the two lines than there is for Carmelo, which indicates that LeBron needs fewer shots to score points. In fact, by the time he reaches Miami (around 500 on the horizontal axis) he appears to score 10 more points than FGA. 

The final chart shows LeBron's career 30 game moving average for plus/ minus. LeBron's career regular season average plus/ minus of 5.4 is clearly negatively skewed by his early days in Cleveland. In fact, during his last few seasons in Miami he appears to have a plus/ minus consistently between 5 and 10. (Not to mention an exceptional plus/ minus peak of 14.9 toward the end of his first stint with the Cavaliers.) 

While LeBron was certainly surrounded with better talent in Miami than Carmelo was in New York during the 2013/14 season, one cannot ignore that LeBron's 30 game moving average plus/ minus over the last few seasons hovers around Carmelo's career peak. Again, the point isn't to compare Carmelo and LeBron as individual players. The point is to give some context of the performance of one player perceived as a superstar (Carmelo) with the NBA's greatest performer (LeBron) based on empirical data. Further, all of this ignores marketing factors and fan popularity, which can play an equally critical role is designating a player as a superstar.