Learn R Programming

nflscrapR (version 1.8.3)

calculate_win_probability: Compute win probability for the provided play-by-play dataset.

Description

Given a dataset of plays and the necessary variables, this function returns the original dataset with the win probability from the nflscrapR model.

Usage

calculate_win_probability(pbp_data, half_seconds_remaining,
  game_seconds_remaining, score_differential, quarter, posteam_timeouts_pre,
  oppteam_timeouts_pre, ep)

Arguments

pbp_data

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

half_seconds_remaining

String denoting the name of the column of the pbp_data containing the number of seconds remaining in the current half.

game_seconds_remaining

String denoting the name of the column of the pbp_data containing the number of seconds remaining in the game.

score_differential

String denoting the name of the column of the pbp_data containing the score differential with respect to the possession team.

quarter

String denoting the name of the column of the pbp_data containing the quarter of the play (anything above 4 is considered overtime).

posteam_timeouts_pre

String denoting the name of the column of the pbp_data containing the number of timeouts remaining for the team with possession.

oppteam_timeouts_pre

String denoting the name of the column of the pbp_data containing the number of timeouts remaining for the opposing team.

ep

String denoting the name of the column of the pbp_data containing the expected points with respect to the possession team for the play.

Value

The original pbp_data with a column named wp containing the win probability with respect to the team with possession.