Best NBA Teams Heading Into the Bubble

(07/07/2020)

Basketball! It's almost back... fingers crossed. Teams are starting to travel to Disney World where they will attempt to salvage the season. Other than the poor Nets, it looks like every team is almost fully intact. There are so many questions to be asked. Will no audience affect how a team does? Will the Oura ring that NBA players must wear affect how a player will shoot? Will the drama within the bubble affect a player's mindset? Will the amenities, like video games and ping pong, be a distraction? These are all valid questions, but I will not be answering any of these. Instead, I will be answering a much easier question: Who are the top teams heading into the Disney bubble?


To achieve this, I am going to use a Bradley-Terry model. A Bradley-Terry model is really useful in anything that has two outcomes. In this case either Team A will win and Team B will lose or Team A will lose and Team B will win. The model will provide a ranking of all 30 NBA teams based on the outcomes of games from the current season using something called the Maximum Likelihood Estimator, or MLE. 

Let's get to the good stuff, the results. Below are the rankings of each team. The Strength column gives a value of how strong that particular team is. This strength value was optimized based on how well a team has played so far this season; this includes a combination of each team faced and the margin of victory for each game. The Rank column is ranked based on the Strength column. 

So here it is. The Bucks should have all the confidence in the world when traveling down to Disney. According to the Bradley-Terry model, Milwaukee has been the best team this season and it's not even close. Coming in at second is the purple and gold. Remember, this strength rating is not accounting for the loss of Avery Bradley and the gain of J.R. Smith. This goes for any team who will have roster changes due to the unfortunate circumstances. Looking at the rest of the rankings, there are no real surprises. Maybe the Raptors being as high as they are or the 76ers being as low as they are. The new, skinny version of Jokic and company are ranked in the top 5. The Thunder also have an impressive ranking coming in at 11 with a strength rating of 1.52.

In conclusion, with everything going on and the long break of the NBA, it will be interesting to see how accurate the model performs. This will  be one of the toughest championships to win as everyone is rested up and ready to go. One team will overcome all these obstacles, and your guess is as good as mine of who the final winner will be. But one thing is for sure, we get to watch the sport that makes us the happiest being played at the happiest place in the world! 

 

Who Should Be Crowned NBA MVP?

(04/12/2020)

 
Unfortunately, there is a strong chance that the NBA will not continue the rest of the 2019-2020 season. Yes that sucks, but we still need to crown this season's most valuable player right? So let us look at this year's top contenders and who ultimately should be named 'MVP' if the season were to end today.

To figure out who should win this honor, I have decided to base the MVP race on a statistic that can approximate the value of any given player to his team. This statistic is called AV (Approximate Value), and was created by Stephen Shea and Christopher Baker in their book  Basketball Analytics: Objective and Efficient Strategies for Understanding How Teams WinAV takes the number of defensive stops gained (DSG) of a player and combines it with their Efficient Offensive Production (EOP), which is a statistic I discussed in previous posts. In short, defensive stops gained (DSG) can be created by looking at the opponent's Offensive Rebound %, Turnover %, and effective FG% when a player is on and off the court. Adding DSG and EOP together will give us an Approximate Value of a player.

Above, we have a bar chart showing the league leaders in Approximate Value (AV). Here is the Top 10, along with their AV values:
 1. Lebron James (2172)
 2. Giannis (2082)
 3.James Harden (2072)
 4. Jokic (1778)
    5. Lillard (1660)
 6. Westbrook (1640)
 7. Gobert (1477)
 8. Sabonis (1472)
 9. T. Young (1465)
 T-10. A. Davis (1461)
 T-10. Doncic (1461)

As we expected, it is a tight two-way race coming down to James and Giannis. But if the season were to end today, Lebron James should be crowned MVP based on the AV statistic. And well deserved too, as James narrowly leads Giannis at this point in the season. We will see what happens as the NBA will have to make a decision soon on ending or continuing the season. Will Lebron tie MJ on getting his 5th MVP Award? Will Giannis become a back to back MVP? Will the MVP Award even be given out if the season does not finish? Only time will tell.


Formulas

  AV (Approximate Value) =  (2 * DSG) + EOP

  DSG (Defensive Stops Gained) = [((-.434 * Opponent Offensive Rebound % Net) - (.84 * .748 * Opponent eFG% Net) +                             (1.01 * Opponent TO % Net)) / 48] * Total Minutes Played   
  EOP (Efficient Offensive Production) = G * (Raw EOP)   where G is a constant

  G = (Total League Points) / (sum of each player's EOP)  

  Raw EOP = (.76 * Total Assists + Total Points Per Game) * OE

  OE (Offensive Efficiency) = (Field Goals Made + Total Assists) / (Field Goals Attempt - Total Offensive Rebounds + Total                         Assists + Total Turnovers)



Top 20 Efficient Offensive NBA Players So Far

(11/18/2019)

Here are the top offensive players so far this season according to EOP. Just like how we left off last season, Giannis and James Harden are in the top two. The most surprising is maybe Luka Doncic being in the top 5 with a EOP score of about 2500. We also see some new faces as Brogdon and Ingram are having a pretty good season up to this point. As a Sixers fan, it is concerning to see not one Sixer in the top 20.

EOP (Efficient Offensive Production) is a NBA statistic created by Dr. Stephen Shea and Christopher Baker. I tweaked the formula a little bit by using averages to make it more consistent. Instead, I am making the assumption that each player sustained their averages (PPG and APG) for all 82 regular season games. I applied it to recent stats (3/31/2019) to come up with this model, which was created in R.


Formulas
  EOP (Efficient Offensive Production) = G * (Raw EOP)   where G is a constant

  Raw EOP = (.76 * Total Assists + Total Points Per Game) * OE

  OE (Offensive Efficiency) = (Field Goals Made + Total Assists) / (Field Goals Attempt - Total Offensive Rebounds + Total Assists + Total Turnovers)

  G = (Total League Points) / (sum of each player's EOP)

  Note: For Raw EOP, Total Assists and Total Points per Game are calculated based on averages assuming each player sustained their APG & PPG for all 82 regular season games, not actual total number of assist/points.


Will the Sixers Run It Back ?

[2019 Free Agency Outlook]

(6/25/2019)

Now that the draft is over, it's time for one of the most exciting times in sports. NBA Free Agency. As you many of you know, the Philadelphia 76ers were one basket away from making it to the Eastern Conference Championship. Maybe, just maybe, the Sixers would have been crowned world champions if Kawhi Leonard misses that unforgettable shot. This is why a lot of the current 76er's players are throwing around the phrase "Run it back". Running it back would consist of bringing back key role players and more importantly, Tobias Harris & Jimmy Butler. Not only talent-wise does this make sense but from a money perspective too. Using the Salary Cap tool at cleaningtheglass.com, I was able to examine the 2 realistic options the 76ers could explore this off season if they lose either Tobias or Jimmy.

 

This is what the Sixers' salary cap situation looks right now including all the player's cap holds. The 76ers are currently over the Salary Cap by $31.2M. I am not going to go into great detail of a lot of the salary terms I am going to use, so if you are more interested in this I would encourage you to look them up. 

The 76ers can "run it back" and sign a lot of these players because most of their key players either have Bird-Rights (eg. Tobias Harris, Boban, Jimmy Butler, TJ), Early-Bird Rights (eg. JJ Redick), or have the ability of the  non-Bird exception eg. (Mike Scott & James Ennis). This means they can resign these players up to a certain price even if it means going over the salary cap. Let's take a look at the situation if Jimmy Butler leaves.

 

Option 1: Keeping Tobias & Losing Butler

Table 1

Here is what the Sixers cap situation will look like if Butler decides to abandon the team. The Sixers have a grand total of -$0.6M ; this is without renouncing the cap holds to any player.  As stated before, the 76ers technically could sign all of their free agents. Lets renounce the rights to all free agents and see what the salary cap situation looks like.


Table 2

The 76ers will have about $38.5M in cap space if they let everyone leave the team except for Tobias Harris and the guys under contract (See Table 2). In this situation, the Sixers do have the opportunity to give a max contract to a player with 7-9 years experience, which will take up about $32.7M in the first year. Assuming the Sixers will not be able to attract any of these max players (excluding Jimmy Buckets), the more likely situation will be giving a max contract to a guy with less than 7 years experience that will cost $27.2M the first year or the situation where they sign quality role players to build around Embiid, Simmons, and Tobias. Note, Sixers own the Early-Bird Rights to JJ Redick and the Bird Rights to Boban & Tobias, giving them the opportunity to sign both of these players even if it takes them over the salary cap. 





 
 

Option 2: Losing Tobias & Keeping Butler

Table 3

Here is what the Sixers cap situation will look like if Tobias decides he wants out of Philly and before Butler signs his massive contract with the team (See Table 3). The Sixers will be over the salary cap by $9M with Jimmy Butler's cap hold at $30.7 M ; remember this is without renouncing the rights to any players. In this situation, it is a little more difficult for the Sixers to sign new players because of Jimmy's large cap hold. Let's see the cap situation after renouncing all players except for Jimmy Butler. 


Table 4

The 76ers will have about $30M in cap space if they let everyone walk away from the team except for Jimmy Butler and the guys under contract (See Table 4). In this situation, the Sixers do not have the opportunity to give a max contract to a player with 7-9 years experience since they will only have $30M in cap space. The 76ers will more than likely sign quality role players to build Embiid, Simmons, and Butler in this situation. Again note, Sixers own the Early-Bird Rights to JJ Redick and the Bird Rights to Boban, giving them the opportunity to sign both of these players even if it takes them over the salary cap. If the 76ers are not able to retain both Tobias and Jimmy, I do like this option a lot better. Having a big three consisting of Embiid, Simmons, and Butler is pretty solid. If the Sixers are able to fill out this team with solid role players like bringing back Redick/Scott and maybe signing a few different faces, I can see this team making another deep run in the playoffs. 


*Salary Tool that is being used  is from cleaningtheglass.com


Predicting the Market Value For Upcoming NBA Free Agents

(6/05/2019)

Free agency is coming. By this time next month we will know who the NBA champion is, Zion will have been selected by one lucky team, and the insanity of free agency will have already begun. Will Kevin Durant be a New York Knick? Is Kwahi Leonard going to abandon the Toronto Raptors? What will Kemba Walker do once he is offered a Supermax contract? Unfortunately, I cannot answer any of these questions, but I can maybe predict what these players are worth and what a team should be offering to the upcoming free agents.

Data That Was Used

For this model I wanted to see how player statistics from the previous year influenced the contract that the player signed the following year. I could not find what I was looking for online so I went and created my own data set. By scraping www.basketball-reference.com, I was able to retrieve regular statistics/advanced statistics through 2015-2017 seasons and details about NBA free agent contracts from those following off-seasons.

From there I was able to filter the data to only keep statistics from the free agents who signed a contract in the off-season. This concludes all the predictor variables that I wanted for the model. Next, I created the dependent variable which is: Salary of Signed NBA Player / Salary Cap of Team During That Season. For example, Steph Curry inked a Supermax contract during the 2017 off-season which accounted for $34,682,550 of the $99,093,000 salary cap budget that year, which is 35% of the salary cap in 2017. I did this for all free agents during the 2015-2017 seasons. I merged this variable ,which I called Cap Hit% Following Year, to the player's previous season statistics to complete my data set.

 
 
 

Results

If you look to the right, you can see which players should be making the biggest dents in a team's salary cap this upcoming free agency, according to my model. It looks like Kawahi Leonard has a slight edge over Kevin Durant because of the 3 year age difference between the two. Obviously, both will be offered max contracts and the model agrees with that, given that a player who has been in the league 7-9 years can max out to 30% of their team's salary.  Another interesting player is Kemba Walker, who will likely be offered a Supermax contract by the Charlotte Hornets. According to the model, Kemba should only receive about 26% of the team's salary cap rather than what the Supermax offers, 35%. The model also tells us that Jimmy Butler and Klay Thompson should be receiving roughly the same contract this off-season, which I agree with. But, the PMV's the model predicted for those two players I do not agree with.

 
 

Predicted Market Value (PMV)

I used multiple linear regression on the data set that I created to see what NBA statistics were important in predicting a free agent's value as a percentage of the salary cap. I found that the combination of these 6 significant predictors produced the best model: Age, Offensive Win Shares (OWS), Defensive Win Shares (DWS), Points Per Game (PPG), the estimate of the percentage of team plays used by a player while he was on the floor (Usage%), and whether or not that player made the All-NBA Team the previous year. Borrowing the term PMV from www.nbamath.com, I wanted to predict the upcoming NBA free agents' Predicted Market Value (PMV), which again is just the player's value as a percentage of the salary. I was able to do this by using the 6 statistics I stated earlier.

 
 
 
 

Conclusion

There are a couple of flaws with the model. First, I need to gather more statistics from contract seasons of players, as I only included contract seasons of players during these seasons: 2015-2016, 2016-2017, 2017-2018. This is the best I could do for now since I was having trouble finding detailed free agent transactions before those seasons. Secondly, my whole study was based on a NBA player receiving a contract only based on his previous season statistics not previous seasons*. I do believe a lot of general managers in the NBA today think this way. Overall, I thought the model did a great job. We will see what it predicts right once this upcoming free agency period is over. Below, I created a scatter-plot showing the PMV of all the 2019 Free Agents. Feel free to hover over the points to see the player's name and his corresponding PMV.

 

*All created in R      
*Inspiration from www.nbamath.com

*All code can be found here:  https://github.com/SportsPlusMath

Creating Animated NBA Win Probability Charts in R

(5/01/2019)


To the left is the win probability of the Houston Rockets and the Golden State Warriors over Game 2 of the Western Conference Semi-Finals. As you can see, win probabilities throughout a NBA game are constantly changing. Being able to visually see the probability changes through charts can help with analyzing many things, like seeing how each team's win probability charts differ from game to game. Some questions that could be answered are: Is there a pattern going? Is each one completely different? Does one team's win probability always decrease when heading into the 4th quarter? When does this team usually start pulling away from the other team? And so much more. Here, I will be showing how to create a basic win probability chart over a game, but you can do much more with these charts if you wish. 

 
 

Step 1First, we want to bring in all our packages that we will being using. The nbastatR package is helping us get the data of the winning probability percentages of each team throughout a game. The ggplot2 package will help us create our actual graph that we will be creating. The gganimate package will help give us that transition animation on our graph. The teamcolors package brings in all NBA team's colors to give us a proper color palette for the teams we want to graph.

 
 
 

Step 2: Here, we are creating a new data set called 'winprob'. To create this data set we use one of the nbastatR functions called 'win_probability'. To use this function we need a ID number from the boxscore of a game. You can find this ID number at stats.nba.com, and by clicking on a boxscore of any NBA game. I chose the 76ers vs Raptors Game 2 of the Eastern Conference Semi-Finals. The ID number is located in the link, as you can see here : 

stats.nba.com/game/0041800212/

Once the data set is created, we use the 'na.omit' function to remove all observations that have missing values since they will have no use to us.
 
 
 

Step 3 : This is a very simple step. We are using the 'league_palette' function that is in the teamcolors package.
We are creating a color palette that contains all the NBA Team's colors. To the left, you can see each ID number for each team color. You will need two codes for the next step.

 

Step 4 : Above, we have created the animated graph using the data set and color palette that we made earlier. I am not going to go over much of the code here as a lot of it just deals with titles and subtitles of the graph. If you do not know much about the ggplot2 package you should read up on the documentation of it since you can do many cool, interesting things with it. The main lines of code to see here is Line 20 & 21. In these lines, we are making two line plots using the data set 'winprob'. Our X variable is the time stamp in the game and our Y variable is the win percentages at certain points in game. In line 24, we are using the scale_color_manual function to change the colors of both line plots that were created, and we input the correct team color codes from the NBA palette that we made before this step. Lastly, in line 33, we use the transition_reveal function from the gganimate package. Below, we now have the win probability chart of the entire Game 2 of the Eastern Conference Semi-Finals between PHI and TOR!



*Stats were taken from stats.nba.com


76ers May Have Found Another Offensive Weapon In Boban Marjanovic

(4/16/2019)

Last night, the 76ers went on to blow out the Brooklyn Nets, 145-123. The whole 8 man rotation Brett Brown put out on the court for majority of the game gave important contributions for a much needed victory. The offense showed their true potential, led by Ben Simmons, Joel Embiid, JJ Redick, Tobias Harris, and .... Boban Marjanovic. Boban has arguably been the most consistent Sixer on the floor in the past two games. And the reason for this has been his consistent mid-range shot. Take a look below at Boban's playoff shot chart and shot accuracy so far.

Boban is getting majority of his scoring from above the free throw line, shooting a high percentage of 72.7% from that spot. If you watched the game last night, these shots were not even being contested. The reason for that is because Boban was not always this type of player, so it would be smart for the defense to let him take these more difficult mid-range shot.  Let's take a look at his progress through his years in the NBA through shot charts. Starting with his first year in the NBA, 2015-2016 season. 

As you can see above, Boban only took a couple of shots above that free throw line during the 15-16 season. We also see that he was taking a few mid range shots but nearly as efficient as he has been this year, including the playoffs. Lets continue with the 2016-2017 and 2017-2018 season below. Remember, Boban Marjanovic went on to sign with the Detroit Pistons in 2016-2017 and then was involved in the Blake Griffin trade, sending Boban to the Los Angeles Clippers. 

Now we see in both seasons that the mid range shot of Boban is almost completely gone, and he is scoring most of his points in the paint. We also see that his field goal percentages have been decreasing since his first year in the NBA. This could be because of the systems he was playing, where the Detroit Pistons and the Los Angeles Clippers played more of a down-low/post-up game during those seasons. It is possible that this not the correct way to play Boban.  Once Boban gets traded to a run and gun team , like the 76ers squad, we start to see the real potential of Boban. Let's take a look at the progress below.

You can now see the evolution of Boban. His range is finally extending out, even as far as the three point line. If you didnt already catch it, Boban's shot chart from the 2015-2016 season with the Spurs looks very similar to the 2018-2019 season, and this could be explained by the connection of Brett Brown's and Popovich's systems. When given the chance by the 76er's this year, we see that Boban's true range could be scary in many ways. Including, shooting almost 50% from 3 pointer and mid-range this season. Maybe Boban is a big man that can really stretch the court. Only time will tell how consistently he can keep this mid-range/three-point shot up. Soon teams will maybe want to rethink leaving the big man open. We will see teams begin adjusting to Boban as soon as Thursday, when the 76ers take on the Nets in Game 3. 
 
 

*Shot Charts/Shot Accuracy were all created in R       
*Stats and pictures were taken from NBA.com


Point Distribution On Teams

(4/6/2019)

PB (Point Balance) is a metric that measures how much a team spreads the ball around on offense depending on points scored by each player of a team and minutes given to each player of a team. It is defined in the book, Basketball Analytics: Objective and Efficient Strategies for Understanding How Teams Win. It is measured between 0 and 1, where 1 is being perfectly balanced distribution on offense. We are able to get this metric by simply dividing the distribution of points on a team and divide that by the distribution of minutes on that same team. As you can see above, some of the best teams in the NBA are unbalanced; unbalanced meaning that only a few players are scoring majority of points for these teams, and that these players are also getting a majority of the minutes each game. Look at the Golden State Warriors, who arguably is the best team in the league. They are considered the most unbalanced team on offense when it comes to the PB metric. Over the past few years, we saw that the best teams are usually always the most unbalanced; most likely because of "super teams". Golden State has maintained this PB metric of around 0.90 for the last couple of years and it has rewarded them. The 2011 Miami Heat and the 2012 Oklahoma Thunder have the lowest PB scores of the past 10 years,  with scores of 0.862 and 0.871, respectively. PB scores have risen over the last couple of years, which means maybe teams are leaning more towards having a balanced team rather than a "super team", or just having trouble putting together a "super team". If we look above, we see that the Toronto Raptors and the Boston Celtics have a lower PB score than a lot of teams. We will see how these balanced teams will compare to the unbalanced team as we arrive the playoffs.


Formulas 

   Pi= total points of a player/total points of whole team
   h(PT) (distribution of points of team) =  -(Pi * log Pi) , do this for all players of a team and add them all up to get h(PT)

   Pm= total minutes of a player/total minutes of whole team 

   h(Min) (distribution of minutes of team) = -(Pm * log Pm) , do this for all players of a team and add them all up to get    h(Min)


     *If you would like to know more about this statistic please read Basketball Analytics: Objective and Efficient Strategies for Understanding How Teams Win; I have no rights to this book



Top 20 Efficient Offensive NBA Players 

(4/6/2019)

 

EOP (Efficient Offensive Production) is a NBA statistic created by Dr. Stephen Shea and Christopher Baker. I tweaked the formula a little bit by using averages to make it more consistent. Instead, I am making the assumption that each player sustained their averages (PPG and APG) for all 82 regular season games.  I applied it to recent stats (3/31/2019) to come up with this model, which was created in R.


Formulas
  EOP (Efficient Offensive Production) = G * (Raw EOP)   where G is a constant

  Raw EOP = (.76 * Total Assists + Total Points Per Game) * OE

  OE (Offensive Efficiency) = (Field Goals Made + Total Assists) / (Field Goals Attempt -  Total Offensive Rebounds + Total Assists + Total Turnovers)

  G = (Total League Points) / (sum of each player's EOP)

   Note: For Raw EOP, Total Assists and Total Points per Game are calculated based on averages assuming each player sustained their APG & PPG for all 82 regular season games, not actual total number of assist/points.

 

    *If you would like to know more about this statistic please read Basketball Analytics: Objective and Efficient Strategies for Understanding How Teams Win; I have no rights to this book