Modeling Spatial Expected Points Allowed by NBA Defenses

STAT479 Group 28: Paddy Lavin, Owen Klabough, Barnabás Valkó, Steven Yang

Introduction: Beyond the Box Score

  • There are a great number of stats to measure offense in basketball, but not for defense
  • Traditional counting stats like steals and blocks are rare and do not reflect true defensive ability
  • Defensive metrics often ignore spatial context

Our Goal

To create a metric for analyzing team defensive efficiency that takes into account the location of shots taken.

Our Approach

We’ll use a Generalized Additive Model (GAM):

  • Smooths over the variance seen in binning to provide a continuous surface of expected points per shot taken.

  • Less susceptible to noise, captures the broad spatial trends of a defense.

We can use GAMs to create a new metric, EPx, representing the Expected Points a defense allows per shot taken at a point x.

The Code

We use the mgcv package in R to fit our GAMs based on the score_value (0, 2, or 3) of any shot taken as a function of its x and y coordinates on the half court. We use play-by-play data accessed via hoopR:

Code
shot_data <- hoopR::load_nba_pbp(seasons = 2024) %>%
    filter(shooting_play == TRUE)

league_avg_gam <- gam(
          score_value ~ s(coordinate_x_raw, abs(coordinate_y_raw)),
          data = shot_data)

Using this GAM, we can create a heatmap for the league-average EPx at any location on the court.

League Average Plot (2023-24)

2023-24 League-Average EPx heatmap. Yellow: most efficient, Purple: least efficient

Historical Comparison Plots: 2024 vs. 2002

2023-24 Season

2001-02 Season

Were offenses worse or defenses better in 2001-02?

Team-by-Team Comparisons

We can also create Comparison GAMs by running a model for each team defense in the NBA, and then subtracting the league average from each team’s map.

  • Red = Worse than Avg. Defense (Vulnerable Area)
  • Blue = Better than Avg. Defense (Strong Area)

These heatmaps are useful for seeing at a glance where a team has weaker than league average defense.

Team-by-Team Comparison Heatmaps

(Red = Vulnerable Area, Blue = Strong Area.)

Zonal Analysis

Let us define a number of specific zones on the court to compare defenses on:

  • Around the rim

  • Left/Right Corner 3s

  • Left/Right Wing 3s

  • Left/Right Midranges

  • The Parking Lot

Gray areas are not assigned to a zone.

Zonal Analysis (cont.)

Now let us take a look at the Team EPx - League EPx for our defined zones.

Note that Team EPx - League EPx being a negative value means a team allows that many fewer points on average per shot taken in the zone!

Zonal Analysis Table

Team EPx vs. League Average by Zone in 2023-24 (ΔTeam = Team EPx - League EPx)
Zone League Avg EPx Dallas EPx Δ DAL Houston EPx Δ HOU Milwaukee EPx Δ MIL
Rim 1.362 1.384 0.023 1.292 -0.069 1.403 0.041
L Corner 3 1.171 1.177 0.006 1.267 0.096 1.147 -0.023
R Corner 3 1.203 1.263 0.059 1.061 -0.142 1.153 -0.050
L Wing 3 1.133 1.157 0.024 1.065 -0.068 1.063 -0.069
R Wing 3 1.145 1.087 -0.058 1.037 -0.108 1.025 -0.120
L Midrange 0.906 0.956 0.050 0.924 0.018 0.958 0.052
R Midrange 0.887 0.903 0.016 0.957 0.069 0.897 0.009
Parking Lot 0.262 0.606 0.344 0.843 0.581 0.339 0.077

(Compare with Comparison Heatmaps)

(Red = Vulnerable Area, Blue = Strong Area.)

Corner 3 Defense Scatter Plot

Comparison of 2023-24 Zonal EPx on Left vs. Right Corner 3s

Final Thoughts

How Teams Can Use EPx Today:

  • Opponent Scouting

  • Self-Scouting

  • Player Evaluation

Current Limitations:

  • Defender Context

  • Game State

  • Foul/Possession Data

Future Steps:

  1. Incorporate Tracking/Possession Data
  2. Player-Level Analysis

Thank you for listening! Questions?