liveBook · Manning

Streak

As explained in Statistics Slam Dunk

A streak is a sequence of consecutive events sharing a specified outcome or property.

A streak counts consecutive events with the same outcome or property. In free-throw analysis, it measures how many prior attempts formed an uninterrupted run of makes, while resetting at each game. section 16.4.1

A practical R workflow builds and analyzes streaks:

  • Group attempts by date so a run cannot carry from one game into the next. section 16.4.1
  • Use dplyr::lag() with runner::streak_run() inside mutate() to calculate the running streak. section 16.4.1
  • Group by streak length, count makes and misses, and calculate the percentage of makes for each run length. section 16.4.1

Giannis Antetokounmpo’s free throws

A 707-record data set contains 442 made free throws. After grouping by game and calculating streaks, the first attempt receives a streak value of 1, the next attempt reflects the preceding result, and the streak resets when the date changes. Percentages can then be plotted against consecutive makes to investigate a possible hot-hand pattern. section 16.4.1

giannis %>%
 group_by(date) %>%
 mutate(streak = streak_run(lag(points))) -> giannis_final

head(giannis_final, n = 10)
## # A tibble: 10 × 7
## # Groups:   date [1]
##    date       event_type player                points result            
##    <date>     <fct>      <chr>                  <dbl> <fct>
##  1 2019-10-24 free throw Giannis Antetokounmpo      0 missed 
##  2 2019-10-24 free throw Giannis Antetokounmpo      1 made   
##  3 2019-10-24 free throw Giannis Antetokounmpo      0 missed 
##  4 2019-10-24 free throw Giannis Antetokounmpo      0 missed 
##  5 2019-10-24 free throw Giannis Antetokounmpo      0 missed 
##  6 2019-10-24 free throw Giannis Antetokounmpo      1 made   
##  7 2019-10-24 free throw Giannis Antetokounmpo      1 made   
##  8 2019-10-24 free throw Giannis Antetokounmpo      1 made   
##  9 2019-10-24 free throw Giannis Antetokounmpo      1 made   
## 10 2019-10-24 free throw Giannis Antetokounmpo      1 made   
##    type              streak
##    <fct>              <int>
##  1 Free Throw 1 of 2      0
##  2 Free Throw 2 of 2      1
##  3 Free Throw 1 of 2      1
##  4 Free Throw 2 of 2      1
##  5 Free Throw 1 of 2      2
##  6 Free Throw 2 of 2      3
##  7 Free Throw 1 of 1      1
##  8 Free Throw 1 of 2      2
##  9 Free Throw 2 of 2      3
## 10 Free Throw 1 of 2      4

Inspect the grouped mutate() pipeline and its first ten calculated observations. section 16.4.1

How Statistics Slam Dunk covers it

How deep it goes
Explains grouping, lagged inputs, streak calculation, summarization, and plotting, but does not develop formal probability theory.
Examples
Uses Giannis Antetokounmpo free throws and simulated coin flips to demonstrate streak construction and maximum-run measurement.
What it assumes
Assumes a sequential outcome data set and basic R data manipulation while demonstrating lagged streak calculation explicitly.
What you can do after
Diagnose consecutive-outcome patterns by creating, summarizing, and plotting streak-based statistics in R.
How it connects
Connects streaks with dplyr, runner, lag(), grouping, the hot hand, and Laplace’s rule of succession.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Slam Dunk. The section links point to the parts of the book it draws on.