Flow and Dynamics in NBA games – Part III

[This article was first published on StatOfMind, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

In part I and II of this post series on NBA game dynamics, I explored both the average score differential and proportion of time spent in the lead for each NBA team. Interestingly, this proved to not be a very reliable proxy for overall performance and number of wins accrued over an entire season. To continue, I decided to look at scoring streaks patterns. Here, I simply extracted and averaged the maximal scoring streaks that teams achieved during the course of a full season. Given that my data was stored in a datatable in the following format:

 
GAME_ID      YEAR HOME    AWAY    QUARTER TIME   SCORE seconds away  home   score
                  TEAM    TEAM                         (in s)  score score  diff
201310290IND 2014 Indiana Orlando 1       11:39.0 0-0   21     0     0      0
201310290IND 2014 Indiana Orlando 1       11:30.0 0-2   30     0     2      2
201310290IND 2014 Indiana Orlando 1       11:15.0 0-2   45     0     2      2
201310290IND 2014 Indiana Orlando 1       11:14.0 0-2   46     0     2      2
201310290IND 2014 Indiana Orlando 1       11:03.0 0-2   57     0     2      2

The actual function that I used to find the longest streak was:

 
'find_longest_streak' <- function(vec) {
  streaks <- c()
  current <- 0
  for(i in 2:length(vec)) {
    if(abs(vec[i]) >= abs(vec[i-1])) {
      current <- current + (abs(vec[i]) - abs(vec[i-1]))
    }
    else{
      streaks <- c(streaks, current)
      current <- 0
    }
  }
  return(max(streaks))

Using the above, I looked at scoring streaks for teams playing at home and away over the course of the 2001-2014 seasons. The heatmap below, generated using the d3heatmap R library shows the average maximal scoring streak per game for teams playing at home. This shows that the LA Clippers is the team that goes on the longest scoring streaks. What is most intriguing is that scoring streaks appear to be longer now than they were perhaps 10 years ago.

Average maximal scoring streak per game for teams playing at home

The same observation holds for lead propensity scores of teams playing away: scoring streaks appear to be longer now than they were perhaps 10 years ago.

Average maximal scoring streak per game teams playing away

Finally, we can look at the differential in average maximal scoring streak per game when teams play at home or away.

Difference in maximal scoring streaks per game when playing at home and away

To leave a comment for the author, please follow the link and comment on their blog: StatOfMind.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)