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:
The actual function that I used to find the longest streak was:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
'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.