maksimhorowitz / nflscrapR

R Package for Scraping and Aggregating NFL Data
522 stars 139 forks source link

EPA play error in MIN-KC #134

Open guga31bb opened 4 years ago

guga31bb commented 4 years ago

https://twitter.com/benbbaldwin/status/1191504589469704204

Season 2019, home_team=="KC" & away_team=="MIN" & play_id == 1380. For some reason EPA is showing -4.04 when it should be .16

guga31bb commented 4 years ago

Play IDs 188 and 209 in LAC & OAK also have wrong EPA

guga31bb commented 4 years ago

Just going to keep adding to this as I find more stuff....

See below. A lot of these are plays with challenges but not all.

pbp <- read_csv(url("https://github.com/ryurko/nflscrapR-data/raw/master/play_by_play_data/regular_season/reg_pbp_2019.csv"))

pbp%>% select(down,ydstogo,desc,ep,epa,play_type) %>%
  filter(!is.na(down) & epa==0 &  ( play_type=="no_play" | play_type=="pass" | play_type=="run")) %>%
  head(20)

    down ydstogo desc                                                                                     ep   epa play_type
   <dbl>   <dbl> <chr>                                                                                 <dbl> <dbl> <chr>    
 1     1      10 (14:25) M.Trubisky pass short right to T.Gabriel to GB 43 for 15 yards (J.Alexander)~ 3.45      0 pass     
 2     2       7 (6:31) (No Huddle, Shotgun) J.Goff pass incomplete short middle to J.Reynolds (L.Kue~ 2.16      0 pass     
 3     1      10 (:46) (Shotgun) S.Darnold pass short middle to J.Crowder to BUF 27 for 2 yards (T.Jo~ 2.75      0 pass     
 4     3       9 (3:55) (Shotgun) M.Ryan pass incomplete deep right to C.Ridley (T.Waynes). PENALTY o~ 6.25      0 no_play  
 5     3       7 (13:37) (Shotgun) J.Brissett pass incomplete short middle to E.Ebron [M.Ingram]. Ind~ 2.85      0 pass     
 6     1      10 (12:53) (Shotgun) A.Dalton pass incomplete short right to J.Ross III. Cincinnati cha~ 2.50      0 pass     
 7     3       5 (8:55) (Shotgun) A.Dalton pass incomplete short middle to D.Willis. PENALTY on SEA-T~ 5.80      0 no_play  
 8     2      10 (2:02) (No Huddle, Shotgun) K.Murray pass incomplete short left to D.Byrd (D.Slay). ~ 0         0 pass     
 9     3       9 (2:15) (Shotgun) B.Roethlisberger pass short right to D.Johnson to NE 47 for 8 yards~ 0.813     0 pass     
10     3       9 (14:57) (Shotgun) D.Watson pass short left to D.Hopkins to NO 21 for 8 yards (M.Latt~ 0         0 pass     
11     3       6 (9:32) (Shotgun) J.Flacco sacked at OAK 8 for -2 yards (B.Mayowa). Penalty on DEN-G.~ 2.90      0 pass     
12     4       1 (8:40) (Shotgun) C.Newton right end to TB 47 for no gain (J.Whitehead). Carolina cha~ 2.80      0 run      
13     1      10 (2:19) (Shotgun) C.Newton pass incomplete deep right to C.Samuel. Carolina challenge~ 1.58      0 pass     
14     3      17 (1:53) (Shotgun) L.Jackson pass deep middle to M.Andrews to BAL 44 for 26 yards (B.B~ 2.78      0 pass     
15     3      11 (4:00) (Shotgun) L.Jackson pass incomplete short middle to M.Brown (B.Murphy). Balti~ 0.451     0 pass     
16     3       5 (14:56) (Shotgun) B.Roethlisberger pass incomplete deep right to J.Samuels. PENALTY ~ 6.50      0 no_play  
17     3      16 (2:11) (Shotgun) R.Wilson scrambles left guard to PIT 33 for 15 yards (K.Kelly).      1.01      0 run      
18     3       4 (4:49) (Shotgun) K.Cousins pass deep right to A.Thielen to MIN 48 for 30 yards (J.Al~ 2.91      0 pass     
19     1      10 (9:28) (Shotgun) G.Minshew pass deep left to D.Westbrook to HOU 14 for 29 yards (B.R~ 2.36      0 no_play  
20     4       1 (2:19) L.Fournette up the middle to JAX 42 for 1 yard (B.McKinney, Z.Cunningham). Ho~ 0         0 run
guga31bb commented 4 years ago

More examples if it's helpful. A bunch of plays showing up as very negative EPA when they shouldn't be.

pbp <- read_csv(url("https://github.com/ryurko/nflscrapR-data/raw/master/play_by_play_data/regular_season/reg_pbp_2019.csv"))

> pbp %>% mutate(f_ep = lead(ep, n = 1), imputed_epa = f_ep - ep, f_posteam = lead(posteam, n = 1)) %>%
+   filter(round(epa, 2) != round(imputed_epa, 2) & posteam == f_posteam & touchdown == 0 & sack == 0 & epa < 0 & imputed_epa > 0) %>%
+   arrange(desc(abs(epa))) %>% select(down,ydstogo,desc,epa,imputed_epa,ep,f_ep) 
# A tibble: 28 x 7
    down ydstogo desc                                                                                                                                               epa imputed_epa    ep  f_ep
   <dbl>   <dbl> <chr>                                                                                                                                            <dbl>       <dbl> <dbl> <dbl>
 1     2       2 (3:53) S.Michel right end to MIA 4 for 3 yards (X.Howard; C.Harris).                                                                             -4.73       1.43   4.73  6.15
 2     1      10 (6:42) (Shotgun) M.Rudolph sacked at BAL 23 for -7 yards (M.Judon). PENALTY on BAL-P.McPhee, Defensive Offside, 5 yards, enforced at BAL 16 - N~ -4.33       0.322  4.33  4.65
 3     1      10 (5:48) M.Gordon right tackle to TEN 18 for no gain (K.Byard, R.Gilbert).                                                                         -4.20       1.65   4.20  5.84
 4     2       5 (8:32) (Shotgun) M.Moore pass short right to D.Robinson to MIN 16 for 5 yards (H.Smith).                                                         -4.04       0.160  4.04  4.20
 5     1      10 (13:47) K.Johnson left end to KC 36 for 1 yard (D.Wilson).                                                                                       -3.71       0.128  3.71  3.84
 6     2      10 (8:04) (Shotgun) J.Allen pass incomplete deep right to D.Knox. Dropped, receiver near sideline at CIN 5.                                         -3.67       0.741  3.67  4.41
 7     2       8 (5:56) (Shotgun) D.Hodges pass incomplete short left to J.Washington. Coverage 24-Carr.                                                          -3.61       0.858  3.61  4.47
 8     2       6 (3:24) (Shotgun) T.Brady pass incomplete short middle to J.Edelman. Dropped, receiver at BUF 35.                                                 -3.42       2.01   3.42  5.44
 9     3       5 (13:25) (Shotgun) L.Jackson pass incomplete short left to J.Hill.                                                                                -3.26       2.98   3.26  6.24
10     2       3 (8:27) L.Fournette left end pushed ob at CIN 41 for 2 yards (N.Vigil).                                                                           -3.18       2.02   3.18  5.20
# ... with 18 more rows
guga31bb commented 4 years ago

Example of EP being filled wrong on a play with a challenge that wasn't overturned

> pbp %>% filter(game_id==2019092204 & qtr==4 & half_seconds_remaining < 808 & half_seconds_remaining > 770) %>%
+   select(desc,ep,epa,half_seconds_remaining,yardline_100,down, ydstogo,goal_to_go)
# A tibble: 3 x 8
  desc                                                                                                                      ep    epa half_seconds_remai~ yardline_100  down ydstogo goal_to_go
  <chr>                                                                                                                  <dbl>  <dbl>               <dbl>        <dbl> <dbl>   <dbl>      <dbl>
1 (13:25) (Shotgun) L.Jackson pass incomplete short left to J.Hill.                                                       3.26 -3.26                  805           27     3       5          0
2 (13:21) (Shotgun) L.Jackson pass deep right to S.Roberts to KC 2 for 25 yards (K.Fuller) [E.Ogbah]. Kansas City chall~  6.24  0                     801           27     4       5          0
3 (12:52) (Shotgun) M.Ingram up the middle to KC 1 for 1 yard (D.Nnadi).                                                  6.24 -0.101                 772            2     1       2          1