The Hot Hand

Basketball players who make several baskets in succession are described as having a hot hand. Fans and players have long believed in the hot hand phenomenon, which refutes the assumption that each shot is independent of the next. However, a 1985 paper by Gilovich, Vallone, and Tversky collected evidence that contradicted this belief and showed that successive shots are independent events. This paper started a great controversy that continues to this day, as you can see by Googling hot hand basketball.

We do not expect to resolve this controversy today. However, in this lab we’ll apply one approach to answering questions like this. The goals for this lab are to (1) think about the effects of independent and dependent events, (2) learn how to simulate shooting streaks in R, and (3) to compare a simulation to actual data in order to determine if the hot hand phenomenon appears to be real.

Getting Started

Load packages

In this lab, we will explore and visualize the data using the tidyverse suite of packages. The data can be found in the companion package for OpenIntro labs, openintro.

Let’s load the packages.

library(tidyverse)
library(openintro)

Data

Your investigation will focus on the performance of one player: Kobe Bryant of the Los Angeles Lakers. His performance against the Orlando Magic in the 2009 NBA Finals earned him the title Most Valuable Player and many spectators commented on how he appeared to show a hot hand. The data file we’ll use is called kobe_basket.

glimpse(kobe_basket)
## Rows: 133
## Columns: 6
## $ vs          <fct> ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL, ORL…
## $ game        <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ quarter     <fct> 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3…
## $ time        <fct> 9:47, 9:07, 8:11, 7:41, 7:03, 6:01, 4:07, 0:52, 0:00, 6:35…
## $ description <fct> Kobe Bryant makes 4-foot two point shot, Kobe Bryant misse…
## $ shot        <chr> "H", "M", "M", "H", "H", "M", "M", "M", "M", "H", "H", "H"…

This data frame contains 133 observations and 6 variables, where every row records a shot taken by Kobe Bryant. The shot variable in this dataset indicates whether the shot was a hit (H) or a miss (M).

Just looking at the string of hits and misses, it can be difficult to gauge whether or not it seems like Kobe was shooting with a hot hand. One way we can approach this is by considering the belief that hot hand shooters tend to go on shooting streaks. For this lab, we define the length of a shooting streak to be the number of consecutive baskets made until a miss occurs.

For example, in Game 1 Kobe had the following sequence of hits and misses from his nine shot attempts in the first quarter:

\[ \textrm{H M | M | H H M | M | M | M} \]

You can verify this by viewing the first 9 rows of the data in the data viewer.

Within the nine shot attempts, there are six streaks, which are separated by a “|” above. Their lengths are one, zero, two, zero, zero, zero (in order of occurrence).

1. What does a streak length of 1 mean, i.e. how many hits and misses are in a streak of 1? What about a streak length of 0?

A streak length of 1 mean that one hit scored followed by oen miss in [ ] This shows that there are 6 misses, and 3 hits in a streak of 1. A streak lenght of 0 means that miss will occurs after the miss the preceeding streak.

kobe_streak <- calc_streak(kobe_basket$shot)
ggplot(data = kobe_streak, aes(x = length)) +
  geom_bar()

2. Describe the distribution of Kobe’s streak lengths from the 2009 NBA finals. What was his typical streak length? How long was his longest streak of baskets? Make sure to include the accompanying plot in your answer.

The distribution of Kobe's streak length is skewed to the right due to high volume at 0. The volume of streak is typically at 0, while the longest streak of baskets is 4 which occur around 1 one.
coin_outcomes <- c("heads", "tails")
sample(coin_outcomes, size = 1, replace = TRUE)
## [1] "heads"
sim_fair_coin <- sample(coin_outcomes, size = 100, replace = TRUE)
sim_fair_coin
##   [1] "heads" "tails" "heads" "tails" "heads" "tails" "tails" "tails" "heads"
##  [10] "tails" "tails" "heads" "heads" "heads" "heads" "heads" "heads" "tails"
##  [19] "heads" "heads" "tails" "heads" "heads" "heads" "tails" "tails" "heads"
##  [28] "heads" "heads" "heads" "heads" "heads" "tails" "heads" "tails" "heads"
##  [37] "heads" "heads" "tails" "heads" "tails" "tails" "tails" "heads" "heads"
##  [46] "tails" "tails" "heads" "heads" "tails" "tails" "tails" "heads" "heads"
##  [55] "heads" "heads" "heads" "tails" "tails" "heads" "heads" "heads" "heads"
##  [64] "heads" "tails" "heads" "heads" "heads" "tails" "heads" "tails" "heads"
##  [73] "tails" "tails" "heads" "heads" "heads" "heads" "heads" "tails" "heads"
##  [82] "heads" "tails" "tails" "tails" "heads" "heads" "heads" "tails" "tails"
##  [91] "tails" "tails" "tails" "tails" "heads" "tails" "heads" "heads" "tails"
## [100] "tails"
table(sim_fair_coin)
## sim_fair_coin
## heads tails 
##    58    42

Since there are only two elements in coin_outcomes, the probability that we “flip” a coin and it lands heads is 0.5. Say we’re trying to simulate an unfair coin that we know only lands heads 20% of the time. We can adjust for this by adding an argument called prob, which provides a vector of two probability weights.

3. In your simulation of flipping the unfair coin 100 times, how many flips came up heads? Include the code for sampling the unfair coin in your response.Since the markdown file will run the code, and generate a new sample each time you Knit it, you should also “set a seed” before you sample. Read more about setting a seed below.

sim_unfair_coin <- sample(coin_outcomes, size = 100, replace = TRUE, 
                          prob = c(0.2, 0.8))
table(sim_unfair_coin)
## sim_unfair_coin
## heads tails 
##    23    77

I use the code table(sim_unfair_coin) to set stimulation of flipping the unfair coin 100 times.

?sample

Simulating the Independent Shooter

Simulating a basketball player who has independent shots uses the same mechanism that you used to simulate a coin flip. To simulate a single shot from an independent shooter with a shooting percentage of 50% you can type

shot_outcomes <- c("H", "M")
sim_basket <- sample(shot_outcomes, size = 1, replace = TRUE)
sim_basket
## [1] "H"

To make a valid comparison between Kobe and your simulated independent shooter, you need to align both their shooting percentage and the number of attempted shots.

#4. What change needs to be made to the sample function so that it reflects a shooting percentage of 45%? Make this adjustment, then run a simulation to sample 133 shots. Assign the output of this simulation to a new object called sim_basket`.

coin_outcomes <- c("H", "M")
sim_basket <- sample(coin_outcomes, size = 133, replace = TRUE, prob = c(0.45, 0.55))
sim_basket
##   [1] "M" "H" "M" "H" "M" "H" "H" "M" "H" "H" "M" "H" "M" "H" "M" "H" "M" "H"
##  [19] "M" "M" "M" "H" "M" "M" "M" "M" "M" "M" "M" "M" "M" "H" "M" "H" "H" "H"
##  [37] "M" "H" "M" "M" "M" "H" "H" "H" "M" "M" "H" "H" "H" "M" "H" "M" "M" "H"
##  [55] "M" "H" "M" "M" "M" "M" "H" "H" "H" "H" "H" "M" "M" "H" "M" "H" "H" "M"
##  [73] "M" "H" "H" "H" "M" "M" "M" "H" "H" "H" "M" "M" "H" "H" "M" "M" "M" "H"
##  [91] "M" "M" "M" "H" "M" "H" "M" "M" "H" "M" "H" "H" "M" "M" "M" "M" "H" "H"
## [109] "M" "M" "H" "M" "H" "M" "H" "H" "M" "M" "H" "H" "M" "H" "M" "H" "H" "H"
## [127] "H" "M" "H" "M" "H" "M" "H"
table(sim_basket)
## sim_basket
##  H  M 
## 63 70

I use the probabiltiy c(“H”, “M”) and set the sample size to 133. I also set the Hit probability to 0.45 or 45% and 1-.45 = .55 or 55% miss. This code should give us the overview of 133 shots with a 45% rate of sucess.

More Practice

Comparing Kobe Bryant to the Independent Shooter

#5. Using calc_streak, compute the streak lengths of sim_basket, and save the results in a data frame called sim_streak.

sim_streak <- calc_streak(sim_basket)
glimpse(sim_streak)
## Rows: 71
## Columns: 1
## $ length <dbl> 0, 1, 1, 2, 2, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, …

#6.Describe the distribution of streak lengths. What is the typical streak length for this simulated independent shooter with a 45% shooting percentage?How long is the player’s longest streak of baskets in 133 shots? Make sureto include a plot in your answer.

barplot(table(sim_streak), col ="red")

Based on the graph above, the data is skewing to the right. This is a positive-skew distribution where the long tail is in the positive direction on the number line. In a total of 133 shots there is less than or equal to 1 shot for 4 streak shots.

#7. If you were to run the simulation of the independent shooter a second time, how would you expect its streak distribution to compare to the distribution from the question above? Exactly the same? Somewhat similar? Totally different? Explain your reasoning.

I think if the stimulation of the independent shooter is ran a 2nd time, the distribution will be similar to the 1st stimulation.

#8. How does Kobe Bryant’s distribution of streak lengths compare to the distribution of streak lengths for the simulated shooter? Using this comparison, do you have evidence that the hot hand model fits Kobe’s shooting patterns? Explain.

Kobe Bryant’s distribution of the independent shooter have fewer shorter streak compare to the indepdent streak. Kobe bryant has similar 2 and 3rd streak while the indepdent shooter has higher 2 streaks than 3 streaks. * * *