nflverse / nflfastR

A Set of Functions to Efficiently Scrape NFL Play by Play Data
https://www.nflfastr.com/
Other
412 stars 50 forks source link

EPA wrong for sequence: TD, TO, Penalty, XP try #365

Open bkmontgom opened 1 year ago

bkmontgom commented 1 year ago

Examples: 2008_10_SF_ARI play_id's 4080, 4094, 4114 2021_13_LAC_CIN play_id's 1518, 1573, 1538

On the timeout "play" the ep is calculated as if it's a regular play near the goalline. (This is the worst part.) Then there is no epa cost for the penalty.

nflfastR ver 4.4

mrcaseb commented 1 year ago

Good catch! This seems to be a rare case where nflfastR can't recognize a PAT (either 2pt or XP). Since it doesn't know it's PAT, EP is quite high on these PATs. I think the other EP values are affected by this.

pbp <- nflfastR::build_nflfastR_pbp(c("2021_13_LAC_CIN", "2008_10_SF_ARI"))
pbp |> 
  dplyr::filter(
    (game_id == "2008_10_SF_ARI" & dplyr::between(play_id, 4080, 4114)) |
    (game_id == "2021_13_LAC_CIN" & dplyr::between(play_id, 1518, 1573))
  ) |> 
  dplyr::select(game_id, play_id, desc, ep, epa, down, extra_point_attempt, two_point_attempt)
#> ── nflverse play by play ───────────────────────────────────────────────────────
#> ℹ Data updated: 2022-09-27 11:08:52 CEST
#> # A tibble: 7 × 8
#>   game_id         play_id desc                   ep    epa  down extra…¹ two_p…²
#>   <chr>             <dbl> <chr>               <dbl>  <dbl> <dbl>   <dbl>   <dbl>
#> 1 2008_10_SF_ARI     4080 Timeout #2 by SF a… 5.59   0        NA       0       0
#> 2 2008_10_SF_ARI     4094 PENALTY on ARI-69-… 5.59  -4.64     NA       0       0
#> 3 2008_10_SF_ARI     4114 TWO-POINT CONVERSI… 0.947 -0.947    NA       0       1
#> 4 2021_13_LAC_CIN    1518 Timeout #1 by CIN … 5.70   0        NA       0       0
#> 5 2021_13_LAC_CIN    1573 (Run formation) PE… 5.70  -4.82     NA       0       0
#> 6 2021_13_LAC_CIN    1538 2-E.McPherson extr… 0.878 -0.878    NA       1       0
#> 7 2021_13_LAC_CIN    1554 2-E.McPherson kick… 1.33  -0.317    NA       0       0
#> # … with abbreviated variable names ¹​extra_point_attempt, ²​two_point_attempt