-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong posteam on kickoffs with penalties #199
Comments
I just realized that I think the only penalty that causes this bug is 'delay of game'. You might want to use str_detect(desc,"Delay of Game") in the fix. |
In the most recent example, the problem is that |
I just ran the code below today: 3/7/21 9:30am PST and verified that there is still one more instance of this happening in the current data because it was a different penalty (Unnecessary Roughness). pbp <- nflfastR::load_pbp(2011:2020, qs = TRUE)
pbp %>% filter(game_id == '2014_02_ATL_CIN', between(play_id, 3450, 3600)) %>% select(home_team, away_team, posteam, desc, ep, epa) %>% View This is how I'm currently hardcoding a fix: epapp_game <- pbp %>%
filter(!is.na(posteam),!is.na(ep),quarter_end==0) %>%
group_by(game_id,game_half) %>%
mutate(
epa = if_else(is.na(epa), -ep, epa),
posteam = if_else((game_id == '2014_02_ATL_CIN')&(play_id==3498),home_team,posteam),
kickoff_attempt = if_else((game_id == '2014_02_ATL_CIN')&(play_id==3498),1,kickoff_attempt),
epa = if_else((game_id == '2014_02_ATL_CIN')&(play_id==3498),lead(ep)-ep,epa),
) |
The posteam of line 3 in the photo below should be JAX since they were the receiving team when the penalty was incurred. Because of this, the epa in line 3 should be (0.02529127) - (0.09028234) = -0.06499107 instead of
-(0.02529127) - (0.09028234) = -0.11557361
I'm pretty sure this is the same bug, there is a penalty during a kickoff but the posteam doesn't change for the line where the penalty was incurred causing the epa to be -2*(the ep of the kickoff).
So it seems like the posteam has a bug where it says it is the kicking team if there is a penalty when it should be the receiving team. This in turn affects the epa.
The text was updated successfully, but these errors were encountered: