Skip to contents

calculate_expected_goals_v2() calculates version 2 of the expected goals for all the events (plays) in a play-by-play using a pre-estimated logistic regression model of goal probability on distance, angle, empty net, strength state, rebound, and rush indicators.

Usage

calculate_expected_goals_v2(play_by_play)

calculate_xG_v2(play_by_play)

Arguments

play_by_play

data.frame of play-by-play(s); see gc_play_by_play() and/or wsc_play_by_play() for reference; must be untouched by non-nhlscraper functions; saves time if calculate_distance(), calculate_angle(), strip_situation_code(), flag_is_rebound(), and/or flag_is_rush() have already been called

Value

data.frame with one row per event (play) and added xG_v2 column

Examples

# May take >5s, so skip.
# \donttest{
  test <- gc_play_by_play()
  test <- calculate_expected_goals_v2(test)
# }