Skip to contents

Turns the ESPN-processed plays of one or many games into six tidy frames that explain the result: the winner's edges in expected points, the play that swung the game, the score by quarter, each side's longest unanswered run and each side's top performer. It returns the same frames, column for column, as sportsdataverse-py's cfb_game_story() (the play id is character here), and a parity test replays that function's output on real games.

Each side's value for an edge is the sum of its offense's EPA over the edge's plays, so a defense's work shows as the other offense's lower EPA. points_worth is the winner's points less the loser's.

  • Accounting edges cover every play with an EPA once: passing (pass scrimmage plays), rushing (rush scrimmage plays), special_teams (kickoffs, punts and field goals) and other (penalties without a play, kneels, conversions). Their sum is the net EPA, which telescopes to the margin less the expected points that halves start and end with: close to it, not equal.

  • Splits are overlapping cuts: turnovers (plays the offense turned over), explosive_plays (EPA_explosive), red_zone (scrimmage plays from 20 yards out or closer), late_downs (third and fourth down) and success_rate. The success rate's value is each offense's rate on scrimmage plays (EPA_success); its points are (rate - game rate) * plays * (e_s - e_f): the successes above the game's pooled rate, priced at the game's own mean EPA of a successful play less an unsuccessful one.

The moment is the play with the largest absolute wpa, turned to the home side (earliest on ties). A game with no wpa falls back to the winner's first score after the last play it was level or behind after, so the winner leads on every play from there to the end. The top performer is the player with the most EPA as passer, rusher or receiver combined (a target credits both the passer and the receiver; ties go to touchdowns, then the smaller id).

The final score is the release's homeFinalScore / awayFinalScore where present, else the last running score. The quarters are rebuilt from the running score, so periods_agree is FALSE when the plays end on another score than the official final. A tie has no winner: winner_team_id and loser_team_id are NA and the edges read from the home side's view.

Usage

cfb_game_story(pbp)

Arguments

pbp

The ESPN-processed plays of one or many games, as returned by load_espn_cfb_pbp() (a data.frame, tibble or data.table). Needs game_id, id, game_play_number, period.number, clock.displayValue, text, pos_team_id (or pos_team holding the team id), homeTeamId, awayTeamId, homeScore, awayScore, EPA, wpa, scrimmage_play, pass, rush, type.text, is_pos_team_turnover, EPA_explosive, EPA_success, start.yardsToEndzone and late_down. The passer_*, rusher_* and receiver_* _player_id / _player_name pairs, pass_td, rush_td, homeFinalScore and awayFinalScore are used where present. Plays without a game_id are dropped with a warning.

Value

A named list of six tibbles, each sorted by game_id. A game whose final is missing is dropped; a game without plays has no periods, runs or moment rows, and one without an EPA has no edges or performers rows. Without wpa, a tie has no moment row, nor does a game whose plays end with the winner level or behind or whose winner never scores again after it was last level or behind. Integer ids are R integers except the play id, which is character (ESPN play ids pass 2^53), as in load_espn_cfb_pbp().

summary: one row per game.

col_nametypesdescription
game_idintegerThe game's ESPN game id.
home_team_idintegerHome team's ESPN team id.
away_team_idintegerAway team's ESPN team id.
home_scoreintegerHome team's official final score.
away_scoreintegerAway team's official final score.
winner_team_idintegerWinning team's id; NA on a tie.
loser_team_idintegerLosing team's id; NA on a tie.
marginintegerWinner's final score less the loser's; 0 on a tie.
decidedlogicalTRUE when the game has a winner (FALSE on a tie).
periods_agreelogicalTRUE when the quarter sums (from the running score) equal the official final; FALSE flags plays that end on another score.
n_periodsintegerPeriods played, overtimes included.
overtimelogicalTRUE when the game went past regulation.

edges: one row per game and edge, ranked.

col_nametypesdescription
game_idintegerThe game's ESPN game id.
winner_team_idintegerWinning team's id (NA on a tie, where the edges read from the home side's view).
loser_team_idintegerLosing team's id (NA on a tie).
edgecharacterEdge name. Accounting: passing, rushing, special_teams, other. Splits: turnovers, explosive_plays, success_rate, red_zone, late_downs.
kindcharacteraccounting for the edges that partition the game's EPA, split for overlapping cuts.
unitcharacterAlways points: expected points, the unit the edges are priced in.
winner_valuedoubleWinner's value for the edge: its offense's EPA, or its success rate for success_rate.
loser_valuedoubleLoser's value for the edge, in the same unit as winner_value.
points_worthdoubleThe winner's edge in points: the winner's points from the edge less the loser's. Positive favours the winner.
rankintegerRank of the edge within the game by points_worth, 1 = largest; equal worths keep the edge list's order.

moment: the play that decided each game.

col_nametypesdescription
game_idintegerThe game's ESPN game id.
play_idcharacterESPN play id of the deciding moment.
orderintegerThe play's game_play_number.
periodintegerQuarter of the play (5 and up: overtime).
clockcharacterGame clock of the play as ESPN shows it.
team_idintegerThe offense's team id.
textcharacterPlay description as ESPN writes it.
wpadoubleHome win probability after the play less before it.
winner_wpadoubleThe same change from the winner's side (NA on a tie).
home_scoreintegerHome score after the play.
away_scoreintegerAway score after the play.
rulecharactermax_abs_wpa: the play with the largest absolute win-probability change (earliest on ties); deciding_score where no play has one: the winner's first score after it was last level or behind, so it leads from there to the end.

periods: one row per game and quarter.

col_nametypesdescription
game_idintegerThe game's ESPN game id.
periodintegerPeriod number, from 1; overtimes follow regulation.
period_labelcharacterQ1-Q4, then OT, OT2, ...
is_overtimelogicalTRUE for a period after regulation.
home_ptsintegerHome points in the period: its last running score less the previous period's.
away_ptsintegerAway points in the period.
home_cumintegerHome running score at the end of the period.
away_cumintegerAway running score at the end of the period.

runs: each side's largest unanswered run (home first).

col_nametypesdescription
game_idintegerThe game's ESPN game id.
team_idintegerTeam that made the run.
pointsintegerPoints the side scored in a row with no score by the other side (a score correction stays in the run and counts against its side; both sides scoring on one play ends any run). Earliest on ties.
start_orderintegerPlay order of the run's first score.
end_orderintegerPlay order of the run's last score.
start_periodintegerPeriod of the run's first score.
end_periodintegerPeriod of the run's last score.
home_score_afterintegerHome score at the end of the run.
away_score_afterintegerAway score at the end of the run.

performers: each side's top player.

col_nametypesdescription
game_idintegerThe game's ESPN game id.
team_idintegerTeam of the top performer.
player_idintegerESPN athlete id of the side's top performer.
player_namecharacterPlayer's display name.
metriccharacterAlways epa: the expected points added the performer is chosen by.
valuedoubleThe player's EPA as passer, rusher and receiver combined.

See also

load_espn_cfb_pbp() for the plays.

Examples

# Downloads a whole season of play-by-play (about 500 columns).
pbp <- load_espn_cfb_pbp(2024)
story <- cfb_game_story(pbp[pbp$game_id == 401628333, ])
story$summary
#> # A tibble: 1 × 12
#>     game_id home_team_id away_team_id home_score away_score winner_team_id
#>       <int>        <int>        <int>      <int>      <int>          <int>
#> 1 401628333          238          259         34         27            238
#> # ℹ 6 more variables: loser_team_id <int>, margin <int>, decided <lgl>,
#> #   periods_agree <lgl>, n_periods <int>, overtime <lgl>
head(story$edges, 3)
#> # A tibble: 3 × 10
#>     game_id winner_team_id loser_team_id edge         kind  unit   winner_value
#>       <int>          <int>         <int> <chr>        <chr> <chr>         <dbl>
#> 1 401628333            238           259 red_zone     split points       12.5  
#> 2 401628333            238           259 turnovers    split points        0    
#> 3 401628333            238           259 success_rate split points        0.516
#> # ℹ 3 more variables: loser_value <dbl>, points_worth <dbl>, rank <int>
story$moment[, c("text", "winner_wpa")]
#> # A tibble: 1 × 2
#>   text                                                                winner_wpa
#>   <chr>                                                                    <dbl>
#> 1 Kyron Drones pass complete to Ali Jennings for 62 yds for a TD (Jo…     -0.288