Home Team Advantage - NBA

Posted by Dan Temkin on March 25, 2017

Home Team Advantage - How does your NBA team do when your there?

Often credit for “Home Team Advantage” in sports is attributed to the fervor of the fans. But, whether it is the roar of the crowd, the familiarity of the location, the jet-lag of the away team, or blind luck I attempt to find out which teams in the National Basketball Association have the best record at home. Using data collected from scraping (ShrpSports), I empirically show that teams with fair weather fans have reduced consistency, when it comes to winning at home and that newer teams seem to have an easier time winning at home than teams that have experienced the highs and lows of fan support/attendance.

I have made the data I used accessible via the github (here). If you would like to see the full code it can be downloaded here: (.py).

scraping the data and coercing it to a more consumable format

       away_score  away_team  day dayofweek   game_date  home_score
    0         105    Indiana   12    Friday  1979-10-12         114   
    1         106    Houston   12    Friday  1979-10-12         114   
    2         103  LA Lakers   12    Friday  1979-10-12         102   
    3         103  Milwaukee   12    Friday  1979-10-12         105   
    4          95  Cleveland   12    Friday  1979-10-12         102   
         home_team loc_abbr     location  margin  month overtime  overtime_count
    0      Detroit      Det      Detroit       9     10    False               0   
    1       Boston      Bos       Boston       8     10    False               0   
    2    San Diego       SD    LA Lakers       1     10    False               0   
    3  Kansas City       KC  Kansas City       2     10    False               0   
    4   New Jersey       NJ   New Jersey       7     10    False               0   
        season winner  year  
    0  1979-80   home  1979  
    1  1979-80   home  1979  
    2  1979-80   away  1979  
    3  1979-80   home  1979  
    4  1979-80   home  1979  

The above table is the header produced by the Pandas DataFrame object.

The chart above shows every NBA game for the past 37 years and is colored depending on the difference in score with the dark blue (purple) indicating a close score and the more yellow/greenish dots indicating games where one team blew out the other. It is interesting to note that the games with the largest margin occured when the home team won. Also we can even see the highest scoring game in the sample which was 171 to 166 from a game in 1982.

It should be noted that due to the limited number of potential variations in score there were likely points duplicated or that are being covered by more recent occurences.

This line chart is interesting because as we can see there despite the introduction of new teams, better players, equipment and so on that the average game is won by the same amount of points today as it was 37 years ago which is fascinating. What I would have expected is that the increase in the number of games per year which is simply due to the number of teams increasing, would have caused the score differential to trend towards a more normal distribution. But apparently it is as normal as it is going to get.

On a side note, I used the Harmonic Mean because given the uniformity of the distribution, the arithmetic mean was more likely to be effected by significant divergences especially in the cases where the number of games was lower. Leaving us with a better measure of central tendency for the differences in score over time.

Now, on to the home court advantage. As you can see home teams do have a greater win percentage over away teams and though the difference is shrinking slightly there is still about a 60% percent chance that any team when at home will win the game. This pattern is consistent over time even when the number of games increased by a couple hundred from the 1980s to now.

     Home_Team                                              Years
0    Vancouver         [1995, 1996, 1997, 1998, 1999, 2000, 2001]   
1  Cha Bobcats  [2004, 2005, 2006, 2007, 2008, 2009, 2010, 201...   
2    Minnesota  [1989, 1990, 1991, 1992, 1993, 1994, 1995, 199...   
3     Brooklyn               [2012, 2013, 2014, 2015, 2016, 2017]   
4    San Diego               [1979, 1980, 1981, 1982, 1983, 1984]   

   Num_Wins_Home  Num_Losses_Home  Num_Games  NumYears  Pct_Home_Losses
0             66              164        230         7         0.286957   
1            191              211        402        11         0.475124   
2            533              587       1120        29         0.475893   
3             96              104        200         6         0.480000   
4            100              105        205         6         0.487805   

   Pct_Home_Wins  AdjPct_Home_Wins  AdjPct_Home_Losses  
0       0.713043          0.040994            0.101863  
1       0.524876          0.043193            0.047716  
2       0.524107          0.016410            0.018073  
3       0.520000          0.080000            0.086667  
4       0.512195          0.081301            0.085366  

In the above graphs the size of each point corresponds to the number of years each team has been active in the league. In the “UnAdjusted Win Percent - Top 10 Winners & Losers” plot, the win percentage is taken regardless of the number of years the team has been around. As such, I would argue the teams within the center are the ones with the most consistent win percentage at home and subsequently are the ones wiht the best fans. For the first plot these are Sacramento, LA Clippers and New Jersey.

The adjusted plot containes the top 10 and bottom 10 teams by win percentage after controlling for number of years in the league. This control had a very polarizing effect. There were very few in the middle and those with the lowest “adjusted win percent” have been around for longer. Though this is to be expected, the more years a team plays the greater variance we expect in their, though in this case we could use it to see which teams have a greater number of “fair weather fans” who don’t stick around for more than a year or so. Ironically, the LA Clippers which were among the best performing on the unadjusted plot are now among the bottom 10.