View source: R/ep_wp_calculators.R
calculate_expected_points | R Documentation |
for provided plays. Returns the data with probabilities of each scoring event and EP added. The following columns must be present: season, home_team, posteam, roof (coded as 'open', 'closed', or 'retractable'), half_seconds_remaining, yardline_100, ydstogo, posteam_timeouts_remaining, defteam_timeouts_remaining
calculate_expected_points(pbp_data)
pbp_data |
Play-by-play dataset to estimate expected points for. |
Computes expected points for provided plays. Returns the data with probabilities of each scoring event and EP added. The following columns must be present:
season
home_team
posteam
roof (coded as 'outdoors', 'dome', or 'open'/'closed'/NA (retractable))
half_seconds_remaining
yardline_100
down
ydstogo
posteam_timeouts_remaining
defteam_timeouts_remaining
The original pbp_data with the following columns appended to it:
expected points.
probability of no more scoring this half.
probability next score opponent field goal this half.
probability next score opponent safety this half.
probability of next score opponent touchdown this half.
probability next score field goal this half.
probability next score safety this half.
probability text score touchdown this half.
try({# to avoid CRAN test problems
library(dplyr)
data <- tibble::tibble(
"season" = 1999:2019,
"home_team" = "SEA",
"posteam" = "SEA",
"roof" = "outdoors",
"half_seconds_remaining" = 1800,
"yardline_100" = c(rep(80, 17), rep(75, 4)),
"down" = 1,
"ydstogo" = 10,
"posteam_timeouts_remaining" = 3,
"defteam_timeouts_remaining" = 3
)
nflfastR::calculate_expected_points(data) %>%
dplyr::select(season, yardline_100, td_prob, ep)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.