calculate_expected_points: Compute expected points

View source: R/ep_wp_calculators.R

calculate_expected_pointsR Documentation

Compute expected points

Description

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

Usage

calculate_expected_points(pbp_data)

Arguments

pbp_data

Play-by-play dataset to estimate expected points for.

Details

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

Value

The original pbp_data with the following columns appended to it:

ep

expected points.

no_score_prob

probability of no more scoring this half.

opp_fg_prob

probability next score opponent field goal this half.

opp_safety_prob

probability next score opponent safety this half.

opp_td_prob

probability of next score opponent touchdown this half.

fg_prob

probability next score field goal this half.

safety_prob

probability next score safety this half.

td_prob

probability text score touchdown this half.

Examples


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)


nflfastR documentation built on Nov. 10, 2022, 5:41 p.m.