Skip to contents

Create a win probability graph for a match

Usage

vs_match_win_probability(
  pbp,
  so,
  go_to = 25,
  go_to_tiebreak = 15,
  max_sets = 5,
  show_plot = TRUE,
  home_color = "blue",
  visiting_color = "darkred"
)

Arguments

pbp

data frame: a data frame containing the set number, home team, visiting team, serving team, point-winning team, home team score, and visiting team score at the end of each point, easiest to obtain by subsetting the plays component of a datavolley object as returned by datavolley::dv_read() to only include rows where point == TRUE

so

integer: a two-element vector of sideout rates for the home team and visiting team, easiest to obtain using vs_estimate_rates()

go_to

integer: the minimum score that must be reached to end a non-tiebreaker set (typically 25 for indoor volleyball in sets 1 to 4, or 21 in beach volleyball)

go_to_tiebreak

integer: the minimum score that must be reached to end a tiebreaker set (typically 15)

max_sets

integer: the maximum number of sets that can be played, either 3 or 5

show_plot

logical: if TRUE, produce a graph showing the home team's win probability at each point in the match

home_color

string: the color used to indicate points in the match where the home team is favored to win

visiting_color

string: the same as home_color, but for the visiting team

Value

A data frame containing the home team's probability of winning the set (set_probs) and match (match_probs) at each point in the set. The first row of the data frame refers to the start of the match (0-0, Set 1).

Examples

if (FALSE) {
  library(datavolley)
  x <- dv_read(vs_example_file())
  sideout_rates <- vs_estimate_rates(x, target_team = "each")$sideout
  play_by_play <- subset(plays(x), point)
  
  vs_match_win_probability(play_by_play, sideout_rates)  ## data frame is not printed to console
  ## but can be stored in a variable
  match_win_probs <- vs_match_win_probability(play_by_play, sideout_rates)
}