View source: R/ep_wp_calculators.R

calculate_win_probability | R Documentation |

for provided plays. Returns the data with probabilities of winning the game. The following columns must be present: receive_h2_ko (1 if game is in 1st half and possession team will receive 2nd half kickoff, 0 otherwise), home_team, posteam, half_seconds_remaining, game_seconds_remaining, spread_line (how many points home team was favored by), down, ydstogo, yardline_100, posteam_timeouts_remaining, defteam_timeouts_remaining

calculate_win_probability(pbp_data)

`pbp_data` |
Play-by-play dataset to estimate win probability for. |

Computes win probability for provided plays. Returns the data with spread and non-spread-adjusted win probabilities. The following columns must be present:

receive_2h_ko (1 if game is in 1st half and possession team will receive 2nd half kickoff, 0 otherwise)

score_differential

home_team

posteam

half_seconds_remaining

game_seconds_remaining

spread_line (how many points home team was favored by)

down

ydstogo

yardline_100

posteam_timeouts_remaining

defteam_timeouts_remaining

The original pbp_data with the following columns appended to it:

- wp
win probability.

- vegas_wp
win probability taking into account pre-game spread.

library(dplyr) data <- tibble::tibble( "receive_2h_ko" = 0, "home_team" = "SEA", "posteam" = "SEA", "score_differential" = 0, "half_seconds_remaining" = 1800, "game_seconds_remaining" = 3600, "spread_line" = c(1, 3, 4, 7, 14), "down" = 1, "ydstogo" = 10, "yardline_100" = 75, "posteam_timeouts_remaining" = 3, "defteam_timeouts_remaining" = 3 ) nflfastR::calculate_win_probability(data) %>% dplyr::select(spread_line, wp, vegas_wp)

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.