I need your help!

I want your feedback to make the book better for you and other readers. If you find typos, errors, or places where the text may be improved, please let me know. The best ways to provide feedback are by GitHub or hypothes.is annotations.

You can leave a comment at the bottom of the page/chapter, or open an issue or submit a pull request on GitHub: https://github.com/isaactpetersen/Fantasy-Football-Analytics-Textbook

Hypothesis Alternatively, you can leave an annotation using hypothes.is. To add an annotation, select some text and then click the symbol on the pop-up menu. To see the annotations of others, click the symbol in the upper right-hand corner of the page.

20  Cluster Analysis

20.1 Getting Started

20.1.1 Load Packages

Code
library("petersenlab")
library("nflreadr")
library("mclust")
library("plotly")
library("tidyverse")

20.1.2 Load Data

Code
load(file = "./data/nfl_players.RData")
load(file = "./data/nfl_combine.RData")
load(file = "./data/player_stats_weekly.RData")
load(file = "./data/player_stats_seasonal.RData")
load(file = "./data/nfl_advancedStatsPFR_seasonal.RData")
load(file = "./data/nfl_actualStats_career.RData")

20.1.3 Overview

Whereas factor analysis evaluates how variables do or do not hang together—in terms of their associations and non-associations, cluster analysis evaluates how people are or or not similar—in terms of their scores on one or more variables. The goal of cluster analysis is to identify distinguishable subgroups of people. The people within a subgroup are expected to be more similar to each other than they are to people in other subgroups. For instance, we might expect that there are distinguishable subtypes of Wide Receivers: possession, deep threats, and slot-type Wide Receivers. Possession Wide Receivers tend to be taller and heavier, with good hands who catch the ball at a high rate. Deep threat Wide Receivers tend to be fast. Slot-type Wide Receivers tend to be small, quick, and agile. In order to identify these clusters of Wide Receivers, we might conduct a cluster analysis with variables relating to the players’ height, weight, percent of (catchable) targets caught, air yards received, and various metrics from the National Football League (NFL) Combine, including their times in the 40-yard dash, 20-yard shuttle run, and three cone drill.

There are many approaches to cluster analysis, including model-based clustering, density-based clustering, centroid-based clustering, hierarchical clustering (aka connectivity-based clustering), etc. An overview of approaches to cluster analysis in R is provided by Kassambara (2017). In this chapter, we focus on examples using model-based clustering with the R package mclust (Fraley et al., 2024; Scrucca et al., 2023), which uses Gaussian finite mixture modeling. The various types of mclust models are provided here: https://mclust-org.github.io/mclust/reference/mclustModelNames.html.

20.1.4 Tiers of Prior Season Fantasy Points

20.1.4.1 Prepare Data

Code
recentSeason <- max(player_stats_seasonal$season, na.rm = TRUE) # also works: nflreadr::most_recent_season()
recentSeason
[1] 2024
Code
player_stats_seasonal_offense_recent <- player_stats_seasonal %>% 
  filter(season == recentSeason) %>% 
  filter(position_group %in% c("QB","RB","WR","TE"))

player_stats_seasonal_offense_recentQB <- player_stats_seasonal_offense_recent %>% 
  filter(position_group == "QB")

player_stats_seasonal_offense_recentRB <- player_stats_seasonal_offense_recent %>% 
  filter(position_group == "RB")

player_stats_seasonal_offense_recentWR <- player_stats_seasonal_offense_recent %>% 
  filter(position_group == "WR")

player_stats_seasonal_offense_recentTE <- player_stats_seasonal_offense_recent %>% 
  filter(position_group == "TE")

20.1.4.2 Identify the Optimal Number of Tiers by Position

20.1.4.2.1 Quarterbacks
Code
tiersQB_bic <- mclust::mclustBIC(
  data = player_stats_seasonal_offense_recentQB$fantasyPoints,
  G = 1:9
)

tiersQB_bic
Bayesian Information Criterion (BIC): 
          E         V
1 -982.9038 -982.9038
2 -964.3518 -927.2534
3 -973.0978 -930.5327
4 -971.2212 -912.2067
5 -971.1002 -924.2192
6 -979.8174 -928.6330
7 -974.9956 -949.0362
8 -981.8676 -955.9257
9 -990.5409 -963.9506

Top 3 models based on the BIC criterion: 
      V,4       V,5       V,2 
-912.2067 -924.2192 -927.2534 
Code
summary(tiersQB_bic)
Best BIC values:
               V,4        V,5        V,2
BIC      -912.2067 -924.21918 -927.25337
BIC diff    0.0000  -12.01245  -15.04664
Code
plot(tiersQB_bic)

Code
tiersQB_icl <- mclust::mclustICL(
  data = player_stats_seasonal_offense_recentQB$fantasyPoints,
  G = 1:9
)

tiersQB_icl
Integrated Complete-data Likelihood (ICL) criterion: 
           E         V
1  -982.9038 -982.9038
2  -972.1069 -933.7840
3 -1039.9236 -945.9954
4 -1040.3715 -927.2426
5 -1033.2208 -945.8315
6 -1061.5988 -935.2325
7 -1056.6193 -993.1199
8 -1065.2675 -976.8222
9 -1088.2374 -986.9286

Top 3 models based on the ICL criterion: 
      V,4       V,2       V,6 
-927.2426 -933.7840 -935.2325 
Code
summary(tiersQB_icl)
Best ICL values:
               V,4        V,2         V,6
ICL      -927.2426 -933.78400 -935.232482
ICL diff    0.0000   -6.54137   -7.989849
Code
plot(tiersQB_icl)

Code
tiersQB_boostrap <- mclust::mclustBootstrapLRT(
  data = player_stats_seasonal_offense_recentQB$fantasyPoints,
  modelName = "V") # variable/unequal variance (for univariate data)

numTiersQB <- as.numeric(summary(tiersQB_boostrap)[,"Length"][1]) # or could specify the number of teams manually

tiersQB_boostrap
------------------------------------------------------------- 
Bootstrap sequential LRT for the number of mixture components 
------------------------------------------------------------- 
Model        = V 
Replications = 999 
              LRTS bootstrap p-value
1 vs 2   68.720575             0.001
2 vs 3    9.790787             0.040
3 vs 4   31.396105             0.001
4 vs 5    1.057678             0.632
Code
plot(
  tiersQB_boostrap,
  G = numTiersQB - 1)

20.1.4.2.2 Running Backs
Code
tiersRB_bic <- mclust::mclustBIC(
  data = player_stats_seasonal_offense_recentRB$fantasyPoints,
  G = 1:9
)

tiersRB_bic
Bayesian Information Criterion (BIC): 
          E         V
1 -1888.714 -1888.714
2 -1817.804 -1769.298
3 -1827.956 -1699.724
4 -1817.083 -1701.580
5 -1827.203 -1708.617
6 -1837.331 -1719.106
7 -1817.623 -1721.044
8 -1827.752 -1735.666
9 -1834.919 -1746.427

Top 3 models based on the BIC criterion: 
      V,3       V,4       V,5 
-1699.724 -1701.580 -1708.617 
Code
summary(tiersRB_bic)
Best BIC values:
               V,3          V,4          V,5
BIC      -1699.724 -1701.580264 -1708.616531
BIC diff     0.000    -1.855914    -8.892182
Code
plot(tiersRB_bic)

Code
tiersRB_icl <- mclust::mclustICL(
  data = player_stats_seasonal_offense_recentRB$fantasyPoints,
  G = 1:9
)

tiersRB_icl
Integrated Complete-data Likelihood (ICL) criterion: 
          E         V
1 -1888.714 -1888.714
2 -1823.200 -1793.185
3 -1991.232 -1728.105
4 -1974.495 -1745.695
5 -2074.939 -1750.066
6 -2123.855 -1757.956
7 -2081.524 -1765.455
8 -2133.100 -1796.801
9 -2136.424 -1795.120

Top 3 models based on the ICL criterion: 
      V,3       V,4       V,5 
-1728.105 -1745.695 -1750.066 
Code
summary(tiersRB_icl)
Best ICL values:
               V,3         V,4         V,5
ICL      -1728.105 -1745.69534 -1750.06574
ICL diff     0.000   -17.58998   -21.96037
Code
plot(tiersRB_icl)

Code
numTiersRB <- 3

The model-based bootstrap clustering of Running Backs’ fantasy points is unable to run due to an error:

Code
tiersRB_boostrap <- mclust::mclustBootstrapLRT(
  data = player_stats_seasonal_offense_recentRB$fantasyPoints,
  modelName = "V") # variable/unequal variance (for univariate data)

Thus, we cannot use the following code, which would otherwise summarize the model results, specify the number of tiers, and plot model comparisons:

Code
numTiersRB <- as.numeric(summary(tiersRB_boostrap)[,"Length"][1]) # or could specify the number of teams manually

tiersRB_boostrap
plot(
  tiersRB_boostrap,
  G = numTiersRB - 1)
20.1.4.2.3 Wide Receivers
Code
tiersWR_bic <- mclust::mclustBIC(
  data = player_stats_seasonal_offense_recentWR$fantasyPoints,
  G = 1:9
)

tiersWR_bic
Bayesian Information Criterion (BIC): 
          E         V
1 -2761.531 -2761.531
2 -2703.730 -2574.337
3 -2714.665 -2561.183
4 -2690.946 -2551.896
5 -2701.848 -2559.810
6 -2679.348 -2566.401
7 -2690.252 -2567.887
8 -2693.451 -2579.761
9 -2704.412 -2594.502

Top 3 models based on the BIC criterion: 
      V,4       V,5       V,3 
-2551.896 -2559.810 -2561.183 
Code
summary(tiersWR_bic)
Best BIC values:
               V,4          V,5          V,3
BIC      -2551.896 -2559.809568 -2561.182771
BIC diff     0.000    -7.913781    -9.286984
Code
plot(tiersWR_bic)

Code
tiersWR_icl <- mclust::mclustICL(
  data = player_stats_seasonal_offense_recentWR$fantasyPoints,
  G = 1:9
)

tiersWR_icl
Integrated Complete-data Likelihood (ICL) criterion: 
          E         V
1 -2761.531 -2761.531
2 -2728.952 -2597.147
3 -2967.945 -2623.521
4 -2909.051 -2643.926
5 -3004.434 -2652.681
6 -2995.921 -2665.160
7 -3044.355 -2642.838
8 -3043.060 -2662.966
9 -3081.954 -2680.271

Top 3 models based on the ICL criterion: 
      V,2       V,3       V,7 
-2597.147 -2623.521 -2642.838 
Code
summary(tiersWR_icl)
Best ICL values:
               V,2         V,3         V,7
ICL      -2597.147 -2623.52084 -2642.83833
ICL diff     0.000   -26.37432   -45.69181
Code
plot(tiersWR_icl)

Code
tiersWR_boostrap <- mclust::mclustBootstrapLRT(
  data = player_stats_seasonal_offense_recentWR$fantasyPoints,
  modelName = "V") # variable/unequal variance (for univariate data)

numTiersWR <- as.numeric(summary(tiersWR_boostrap)[,"Length"][1]) # or could specify the number of teams manually

tiersWR_boostrap
------------------------------------------------------------- 
Bootstrap sequential LRT for the number of mixture components 
------------------------------------------------------------- 
Model        = V 
Replications = 999 
               LRTS bootstrap p-value
1 vs 2   203.573535             0.001
2 vs 3    29.532613             0.001
3 vs 4    25.665741             0.001
4 vs 5     8.464976             0.060
Code
plot(
  tiersWR_boostrap,
  G = numTiersWR - 1)

20.1.4.2.4 Tight Ends
Code
tiersTE_bic <- mclust::mclustBIC(
  data = player_stats_seasonal_offense_recentTE$fantasyPoints,
  G = 1:9
)

tiersTE_bic
Bayesian Information Criterion (BIC): 
          E         V
1 -1416.311 -1416.311
2 -1382.530 -1330.306
3 -1392.221 -1305.417
4 -1401.914 -1304.670
5 -1370.398 -1314.375
6 -1380.110 -1322.054
7 -1387.386 -1329.543
8 -1397.037 -1343.259
9 -1406.769 -1349.787

Top 3 models based on the BIC criterion: 
      V,4       V,3       V,5 
-1304.670 -1305.417 -1314.375 
Code
summary(tiersTE_bic)
Best BIC values:
              V,4           V,3          V,5
BIC      -1304.67 -1305.4171376 -1314.374518
BIC diff     0.00    -0.7472878    -9.704669
Code
plot(tiersTE_bic)

Code
tiersTE_icl <- mclust::mclustICL(
  data = player_stats_seasonal_offense_recentTE$fantasyPoints,
  G = 1:9
)

tiersTE_icl
Integrated Complete-data Likelihood (ICL) criterion: 
          E         V
1 -1416.311 -1416.311
2 -1393.104 -1350.405
3 -1524.763 -1331.375
4 -1592.916 -1341.536
5 -1569.134 -1358.678
6 -1611.364 -1360.491
7 -1616.459 -1360.443
8 -1650.436 -1392.210
9 -1687.470 -1383.417

Top 3 models based on the ICL criterion: 
      V,3       V,4       V,2 
-1331.375 -1341.536 -1350.405 
Code
summary(tiersTE_icl)
Best ICL values:
               V,3         V,4         V,2
ICL      -1331.375 -1341.53615 -1350.40527
ICL diff     0.000   -10.16078   -19.02991
Code
plot(tiersTE_icl)

Code
tiersTE_boostrap <- mclust::mclustBootstrapLRT(
  data = player_stats_seasonal_offense_recentTE$fantasyPoints,
  modelName = "V") # variable/unequal variance (for univariate data)

numTiersTE <- as.numeric(summary(tiersTE_boostrap)[,"Length"][1]) # or could specify the number of teams manually

tiersTE_boostrap
------------------------------------------------------------- 
Bootstrap sequential LRT for the number of mixture components 
------------------------------------------------------------- 
Model        = V 
Replications = 999 
               LRTS bootstrap p-value
1 vs 2   100.537455             0.001
2 vs 3    39.421427             0.001
3 vs 4    15.279849             0.010
4 vs 5     4.827893             0.220
Code
plot(
  tiersTE_boostrap,
  G = numTiersTE - 1)

20.1.4.3 Fit the Cluster Model to the Optimal Number of Tiers

20.1.4.3.1 Quarterbacks

In our data, all of the following models are equivalent—i.e., they result in the same unequal variance model with a 4-cluster solution—but they arrive there in different ways.

Code
mclust::Mclust(
  data = player_stats_seasonal_offense_recentQB$fantasyPoints,
  G = numTiersQB,
)

mclust::Mclust(
  data = player_stats_seasonal_offense_recentQB$fantasyPoints,
  G = 4,
)

mclust::Mclust(
  data = player_stats_seasonal_offense_recentQB$fantasyPoints,
)

mclust::Mclust(
  data = player_stats_seasonal_offense_recentQB$fantasyPoints,
  x = tiersQB_bic
)

Let’s fit one of these:

Code
clusterModelQBs <- mclust::Mclust(
  data = player_stats_seasonal_offense_recentQB$fantasyPoints,
  G = numTiersQB,
)

Here are the number of players that are in each of the four clusters (i.e., tiers):

Code
table(clusterModelQBs$classification)

 1  2  3  4 
11 20 26 21 
20.1.4.3.2 Running Backs
Code
clusterModelRBs <- mclust::Mclust(
  data = player_stats_seasonal_offense_recentRB$fantasyPoints,
  G = numTiersRB,
)

Here are the number of players that are in each of the four clusters (i.e., tiers):

Code
table(clusterModelRBs$classification)

 1  2  3 
39 61 58 
20.1.4.3.3 Wide Receivers
Code
clusterModelWRs <- mclust::Mclust(
  data = player_stats_seasonal_offense_recentWR$fantasyPoints,
  G = numTiersWR,
)

Here are the number of players that are in each of the four clusters (i.e., tiers):

Code
table(clusterModelWRs$classification)

 1  2  3  4 
58 51 68 58 
20.1.4.3.4 Tight Ends
Code
clusterModelTEs <- mclust::Mclust(
  data = player_stats_seasonal_offense_recentTE$fantasyPoints,
  G = numTiersTE,
)

Here are the number of players that are in each of the four clusters (i.e., tiers):

Code
table(clusterModelTEs$classification)

 1  2  3  4 
24 32 29 42 

20.1.4.4 Plot the Tiers

We can merge the player’s classification into the dataset and plot each player’s classification.

20.1.4.4.1 Quarterbacks
Code
player_stats_seasonal_offense_recentQB$tier <- clusterModelQBs$classification

player_stats_seasonal_offense_recentQB <- player_stats_seasonal_offense_recentQB %>%
  mutate(
    tier = factor(max(tier, na.rm = TRUE) + 1 - tier)
  )

player_stats_seasonal_offense_recentQB$position_rank <- rank(
  player_stats_seasonal_offense_recentQB$fantasyPoints * -1,
  na.last = "keep",
  ties.method = "min")

plot_qbTiers <- ggplot2::ggplot(
  data = player_stats_seasonal_offense_recentQB,
  mapping = aes(
    x = fantasyPoints,
    y = position_rank,
    color = tier
  )) +
  geom_point(
    aes(
      text = player_display_name # add player name for mouse over tooltip
  )) +
  scale_y_continuous(trans = "reverse") +
  coord_cartesian(clip = "off") +
  labs(
    x = "Projected Points",
    y = "Position Rank",
    title = "Quarterback Fantasy Points by Tier",
    color = "Tier") +
  theme_classic() +
  theme(legend.position = "top")

plotly::ggplotly(plot_qbTiers)
Figure 20.1: Quarterback Fantasy Points by Tier.
20.1.4.4.2 Running Backs
Code
player_stats_seasonal_offense_recentRB$tier <- clusterModelRBs$classification

player_stats_seasonal_offense_recentRB <- player_stats_seasonal_offense_recentRB %>%
  mutate(
    tier = factor(max(tier, na.rm = TRUE) + 1 - tier)
  )

player_stats_seasonal_offense_recentRB$position_rank <- rank(
  player_stats_seasonal_offense_recentRB$fantasyPoints * -1,
  na.last = "keep",
  ties.method = "min")

plot_rbTiers <- ggplot2::ggplot(
  data = player_stats_seasonal_offense_recentRB,
  mapping = aes(
    x = fantasyPoints,
    y = position_rank,
    color = tier
  )) +
  geom_point(
    aes(
      text = player_display_name # add player name for mouse over tooltip
  )) +
  scale_y_continuous(trans = "reverse") +
  coord_cartesian(clip = "off") +
  labs(
    x = "Projected Points",
    y = "Position Rank",
    title = "Running Back Fantasy Points by Tier",
    color = "Tier") +
  theme_classic() +
  theme(legend.position = "top")

plotly::ggplotly(plot_rbTiers)
Figure 20.2: Running Back Fantasy Points by Tier.
20.1.4.4.3 Wide Receivers
Code
player_stats_seasonal_offense_recentWR$tier <- clusterModelWRs$classification

player_stats_seasonal_offense_recentWR <- player_stats_seasonal_offense_recentWR %>%
  mutate(
    tier = factor(max(tier, na.rm = TRUE) + 1 - tier)
  )

player_stats_seasonal_offense_recentWR$position_rank <- rank(
  player_stats_seasonal_offense_recentWR$fantasyPoints * -1,
  na.last = "keep",
  ties.method = "min")

plot_wrTiers <- ggplot2::ggplot(
  data = player_stats_seasonal_offense_recentWR,
  mapping = aes(
    x = fantasyPoints,
    y = position_rank,
    color = tier
  )) +
  geom_point(
    aes(
      text = player_display_name # add player name for mouse over tooltip
  )) +
  scale_y_continuous(trans = "reverse") +
  coord_cartesian(clip = "off") +
  labs(
    x = "Projected Points",
    y = "Position Rank",
    title = "Wide Receiver Fantasy Points by Tier",
    color = "Tier") +
  theme_classic() +
  theme(legend.position = "top")

plotly::ggplotly(plot_wrTiers)
Figure 20.3: Quarterback Fantasy Points by Tier.
20.1.4.4.4 Tight Ends
Code
player_stats_seasonal_offense_recentTE$tier <- clusterModelTEs$classification

player_stats_seasonal_offense_recentTE <- player_stats_seasonal_offense_recentTE %>%
  mutate(
    tier = factor(max(tier, na.rm = TRUE) + 1 - tier)
  )

player_stats_seasonal_offense_recentTE$position_rank <- rank(
  player_stats_seasonal_offense_recentTE$fantasyPoints * -1,
  na.last = "keep",
  ties.method = "min")

plot_teTiers <- ggplot2::ggplot(
  data = player_stats_seasonal_offense_recentTE,
  mapping = aes(
    x = fantasyPoints,
    y = position_rank,
    color = tier
  )) +
  geom_point(
    aes(
      text = player_display_name # add player name for mouse over tooltip
  )) +
  scale_y_continuous(trans = "reverse") +
  coord_cartesian(clip = "off") +
  labs(
    x = "Projected Points",
    y = "Position Rank",
    title = "Tight End Fantasy Points by Tier",
    color = "Tier") +
  theme_classic() +
  theme(legend.position = "top")

plotly::ggplotly(plot_teTiers)
Figure 20.4: Tight End Fantasy Points by Tier.

20.1.5 Types of Wide Receivers

Code
# Compute Advanced PFR Stats by Career
pfrVars <- nfl_advancedStatsPFR_seasonal %>% 
  select(pocket_time.pass:cmp_percent.def, g, gs) %>% 
  names()

weightedAverageVars <- c(
  "pocket_time.pass",
  "ybc_att.rush","yac_att.rush",
  "ybc_r.rec","yac_r.rec","adot.rec","rat.rec",
  "yds_cmp.def","yds_tgt.def","dadot.def","m_tkl_percent.def","rat.def"
)

recomputeVars <- c(
  "drop_pct.pass", # drops.pass / pass_attempts.pass
  "bad_throw_pct.pass", # bad_throws.pass / pass_attempts.pass
  "on_tgt_pct.pass", # on_tgt_throws.pass / pass_attempts.pass
  "pressure_pct.pass", # times_pressured.pass / pass_attempts.pass
  "drop_percent.rec", # drop.rec / tgt.rec
  "rec_br.rec", # rec.rec / brk_tkl.rec
  "cmp_percent.def" # cmp.def / tgt.def
)

sumVars <- pfrVars[pfrVars %ni% c(
  weightedAverageVars, recomputeVars,
  "merge_name", "loaded.pass", "loaded.rush", "loaded.rec", "loaded.def")]

nfl_advancedStatsPFR_career <- nfl_advancedStatsPFR_seasonal %>% 
  group_by(pfr_id, merge_name) %>% 
  summarise(
    across(all_of(weightedAverageVars), ~ weighted.mean(.x, w = g, na.rm = TRUE)),
    across(all_of(sumVars), ~ sum(.x, na.rm = TRUE)),
    .groups = "drop") %>% 
  mutate(
    drop_pct.pass = drops.pass / pass_attempts.pass,
    bad_throw_pct.pass = bad_throws.pass / pass_attempts.pass,
    on_tgt_pct.pass = on_tgt_throws.pass / pass_attempts.pass,
    pressure_pct.pass = times_pressured.pass / pass_attempts.pass,
    drop_percent.rec = drop.rec / tgt.rec,
    rec_br.rec = drop.rec / tgt.rec,
    cmp_percent.def = cmp.def / tgt.def
  )

uniqueCases <- nfl_advancedStatsPFR_seasonal %>% select(pfr_id, merge_name, gsis_id) %>% unique()

uniqueCases %>%
  group_by(pfr_id) %>% 
  filter(n() > 1)
Code
nfl_advancedStatsPFR_seasonal <- nfl_advancedStatsPFR_seasonal %>% 
  filter(pfr_id != "WillMa06" | merge_name != "MARCUSWILLIAMS" | !is.na(gsis_id))


nfl_advancedStatsPFR_career <- left_join(
  nfl_advancedStatsPFR_career,
  nfl_advancedStatsPFR_seasonal %>% select(pfr_id, merge_name, gsis_id) %>% unique(),
  by = c("pfr_id", "merge_name")
)

# Compute Player Stats Per Season
player_stats_seasonal_careerWRs <- player_stats_seasonal %>% 
  filter(position == "WR") %>% 
  group_by(player_id) %>% 
  summarise(
    across(all_of(c("targets", "receptions", "receiving_air_yards")), ~ weighted.mean(.x, w = games, na.rm = TRUE)),
    .groups = "drop")

# Drop players with no receiving air yards
player_stats_seasonal_careerWRs <- player_stats_seasonal_careerWRs %>% 
  filter(receiving_air_yards != 0) %>% 
  rename(
    targets_per_season = targets,
    receptions_per_season = receptions,
    receiving_air_yards_per_season = receiving_air_yards
  )

# Merge
playerListToMerge <- list(
  nfl_players %>% select(gsis_id, display_name, position, height, weight),
  nfl_combine %>% select(gsis_id, vertical, forty, ht, wt),
  player_stats_seasonal_careerWRs %>% select(player_id, targets_per_season, receptions_per_season, receiving_air_yards_per_season) %>% 
    rename(gsis_id = player_id),
  nfl_actualStats_career_player_inclPost %>% select(player_id, receptions, targets, receiving_air_yards, air_yards_share, target_share) %>% 
    rename(gsis_id = player_id),
  nfl_advancedStatsPFR_career %>% select(gsis_id, adot.rec, rec.rec, brk_tkl.rec, drop.rec, drop_percent.rec)
)

merged_data <- playerListToMerge %>% 
  reduce(
    full_join,
    by = c("gsis_id"),
    na_matches = "never")

Additional processing:

Code
merged_data <- merged_data %>% 
  mutate(
    height_coalesced = coalesce(height, ht),
    weight_coalesced = coalesce(weight, wt),
    receptions_coalesced = pmax(receptions, rec.rec, na.rm = TRUE),
    receiving_air_yards_per_rec = receiving_air_yards / receptions
  )

merged_data$receiving_air_yards_per_rec[which(merged_data$receptions == 0)] <- 0

merged_dataWRs <- merged_data %>% 
  filter(position == "WR")

merged_dataWRs_cluster <- merged_dataWRs %>% 
  filter(receptions_coalesced >= 100) %>% # keep WRs with at least 100 receptions
  select(gsis_id, display_name, vertical, forty, height_coalesced, weight_coalesced, adot.rec, drop_percent.rec, receiving_air_yards_per_rec, brk_tkl.rec, receptions_per_season) %>% #targets_per_season, receiving_air_yards_per_season, air_yards_share, target_share
  na.omit()

20.1.5.1 Identify the Number of WR Types

Code
wrTypes_bic <- mclust::mclustBIC(
  data = merged_dataWRs_cluster %>% select(-gsis_id, -display_name),
  G = 1:9
)

wrTypes_bic
Bayesian Information Criterion (BIC): 
        EII       VII       EEI       VEI       EVI       VVI       EEE
1 -8454.016 -8454.016 -5152.072 -5152.072 -5152.072 -5152.072 -5061.963
2 -8048.408 -8016.971 -5158.404 -5133.220 -5107.907 -5097.764 -5091.426
3 -7902.509 -7867.378 -5113.313 -5079.821 -4985.776 -5008.906 -5094.265
4 -7810.730 -7814.913 -5081.823 -5052.165 -5013.736 -5013.465 -5112.015
5 -7698.027 -7678.692 -5097.037 -5069.040 -5069.200 -5033.071 -5075.946
6 -7737.280 -7701.533 -5093.353 -5066.906 -5064.475 -5074.656 -5098.294
7 -7683.895 -7666.122 -5124.703 -5090.771 -5118.641 -5119.460 -5135.785
8 -7708.298        NA -5110.228        NA        NA        NA -5110.070
9 -7774.346        NA -5136.425        NA        NA        NA -5122.346
        VEE       EVE       VVE       EEV       VEV       EVV       VVV
1 -5061.963 -5061.963 -5061.963 -5061.963 -5061.963 -5061.963 -5061.963
2 -5007.572 -4976.592 -4968.094 -5076.718 -5128.228 -5085.093 -5108.094
3 -5034.293 -4920.517 -4971.412 -5142.228 -5204.047 -5200.756 -5207.984
4 -5024.710 -5018.231 -4986.038 -5310.765 -5372.021 -5362.652 -5384.626
5 -5037.345 -4998.579 -5012.025 -5411.801 -5455.265 -5479.829 -5557.317
6        NA        NA        NA -5526.068 -5513.935        NA        NA
7        NA        NA        NA -5607.206 -5644.139        NA        NA
8        NA        NA        NA -5827.743        NA        NA        NA
9        NA        NA        NA -6009.122        NA        NA        NA

Top 3 models based on the BIC criterion: 
    EVE,3     VVE,2     VVE,3 
-4920.517 -4968.094 -4971.412 
Code
summary(wrTypes_bic)
Best BIC values:
             EVE,3       VVE,2       VVE,3
BIC      -4920.517 -4968.09394 -4971.41195
BIC diff     0.000   -47.57727   -50.89529
Code
plot(wrTypes_bic)

Code
wrTypes_icl <- mclust::mclustICL(
  data = merged_dataWRs_cluster %>% select(-gsis_id, -display_name),
  G = 1:9
)

wrTypes_icl
Integrated Complete-data Likelihood (ICL) criterion: 
        EII       VII       EEI       VEI       EVI       VVI       EEE
1 -8454.016 -8454.016 -5152.072 -5152.072 -5152.072 -5152.072 -5061.963
2 -8054.467 -8022.074 -5188.589 -5168.348 -5121.102 -5113.110 -5106.041
3 -7912.142 -7875.762 -5133.949 -5098.692 -5007.408 -5033.036 -5112.127
4 -7819.921 -7826.700 -5102.602 -5076.934 -5038.652 -5031.973 -5139.461
5 -7709.079 -7688.423 -5128.500 -5096.415 -5097.985 -5052.260 -5092.795
6 -7751.195 -7713.392 -5123.927 -5086.934 -5086.074 -5094.807 -5119.475
7 -7697.688 -7677.348 -5158.280 -5109.184 -5137.655 -5136.448 -5163.501
8 -7725.662        NA -5140.532        NA        NA        NA -5137.724
9 -7790.141        NA -5172.862        NA        NA        NA -5146.788
        VEE       EVE       VVE       EEV       VEV       EVV       VVV
1 -5061.963 -5061.963 -5061.963 -5061.963 -5061.963 -5061.963 -5061.963
2 -5008.372 -4986.265 -4980.919 -5079.017 -5142.868 -5087.834 -5113.593
3 -5045.216 -4932.619 -4990.999 -5147.506 -5211.583 -5205.964 -5215.238
4 -5037.849 -5035.341 -4996.453 -5322.424 -5383.665 -5368.753 -5390.619
5 -5047.991 -5008.817 -5026.191 -5415.840 -5459.559 -5486.313 -5563.007
6        NA        NA        NA -5532.165 -5518.187        NA        NA
7        NA        NA        NA -5610.051 -5646.800        NA        NA
8        NA        NA        NA -5830.894        NA        NA        NA
9        NA        NA        NA -6011.256        NA        NA        NA

Top 3 models based on the ICL criterion: 
    EVE,3     VVE,2     EVE,2 
-4932.619 -4980.919 -4986.265 
Code
summary(wrTypes_icl)
Best ICL values:
             EVE,3       VVE,2       EVE,2
ICL      -4932.619 -4980.91857 -4986.26523
ICL diff     0.000   -48.29982   -53.64648
Code
plot(wrTypes_icl)

Based on the cluster analyses, it appears that three clusters are the best fit to the data.

Code
numTypesWR <- 3
Code
wrTypes_boostrap <- mclust::mclustBootstrapLRT(
  data = merged_dataWRs_cluster %>% select(-gsis_id, -display_name),
  modelName = "EVE") # ellipsoidal with equal volume, variable shape, and equal orientation (for multivariate data)

wrTypes_boostrap
plot(
  wrTypes_boostrap,
  G = numTypesWR - 1)

20.1.5.2 Fit the Cluster Model to the Optimal Number of WR Types

Code
clusterModelWRtypes <- mclust::Mclust(
  data = merged_dataWRs_cluster %>% select(-gsis_id, -display_name),
  G = numTypesWR,
)

summary(clusterModelWRtypes)
---------------------------------------------------- 
Gaussian finite mixture model fitted by EM algorithm 
---------------------------------------------------- 

Mclust EVE (ellipsoidal, equal volume and orientation) model with 3 components: 

 log-likelihood   n df       BIC       ICL
      -2242.626 126 90 -4920.517 -4932.619

Clustering table:
 1  2  3 
30 80 16 

20.1.5.3 Plots of the Cluster Model

Code
plot(
  clusterModelWRtypes,
  what = "BIC")

Code
plot(
  clusterModelWRtypes,
  what = "classification")

Code
plot(
  clusterModelWRtypes,
  what = "uncertainty")

Code
plot(
  clusterModelWRtypes,
  what = "density")

20.1.5.4 Interpreting the Clusters

Code
table(clusterModelWRtypes$classification)

 1  2  3 
30 80 16 
Code
merged_dataWRs_cluster$type <- clusterModelWRtypes$classification

merged_dataWRs_cluster %>% 
  group_by(type) %>% 
  summarise(across(
    where(is.numeric),
    ~ mean(., na.rm = TRUE)
    )) %>% 
  t() %>% 
  round(., 2)
                              [,1]   [,2]   [,3]
type                          1.00   2.00   3.00
vertical                     36.32  36.12  35.75
forty                         4.48   4.46   4.47
height_coalesced             73.07  72.54  73.19
weight_coalesced            206.77 197.65 204.62
adot.rec                     10.11  10.58  12.12
drop_percent.rec              0.04   0.05   0.07
receiving_air_yards_per_rec   7.84   9.60   7.26
brk_tkl.rec                  26.60   7.85   0.31
receptions_per_season        79.23  44.51  39.35

Based on this analysis (and the variables included), there appear to be three types of Wide Receivers. Type 1 Wide Receivers includes the Elite WR1s who are strong possession receivers (note: not all players in a given cluster map on perfectly to the typology—i.e., not all Type 1 Wide Receivers are elite WR1s). They tend to have the lowest drop percentage, the shortest average depth of target, and the fewest receiving air yards per reception. They tend to have the most receptions per season and break the most tackles.

Type 2 Wide Receivers includes the consistent contributor, WR2 types. They had fewer receptions and fewer broken tackles than Type 1 Wide Receivers. Their average depth of target was longer than Type 1, and they had more receiving air yards per reception than Type 1.

Type 3 Wide Receivers includes the deep threats. They have the greatest average depth of target and the most receiving yards per reception. However, they also have the fewest receptions, the highest drop percentage, and the fewest broken tackles. Thus, they may be considered the boom-or-bust Wide Receivers.

The tiers were not particularly distinguishable based on their height, weight, vertical jump, or forty-yard dash time.

Type 1 (“Elite/WR1”) WRs:

Code
merged_dataWRs_cluster %>% 
  filter(type == 1) %>% 
  select(display_name)

Type 2 (“Consistent Contributor/WR2”) WRs:

Code
merged_dataWRs_cluster %>% 
  filter(type == 2) %>% 
  select(display_name)

Type 3 (“Deep Threat/Boom-or-Bust”) WRs:

Code
merged_dataWRs_cluster %>% 
  filter(type == 3) %>% 
  select(display_name)

20.2 Conclusion

20.3 Session Info

Code
sessionInfo()
R version 4.5.0 (2025-04-11)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
 [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
 [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
[10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

time zone: UTC
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] lubridate_1.9.4   forcats_1.0.0     stringr_1.5.1     dplyr_1.1.4      
 [5] purrr_1.0.4       readr_2.1.5       tidyr_1.3.1       tibble_3.2.1     
 [9] tidyverse_2.0.0   plotly_4.10.4     ggplot2_3.5.2     mclust_6.1.1     
[13] nflreadr_1.4.1    petersenlab_1.1.3

loaded via a namespace (and not attached):
 [1] gtable_0.3.6       xfun_0.52          htmlwidgets_1.6.4  psych_2.5.3       
 [5] lattice_0.22-6     tzdb_0.5.0         crosstalk_1.2.1    quadprog_1.5-8    
 [9] vctrs_0.6.5        tools_4.5.0        generics_0.1.3     stats4_4.5.0      
[13] parallel_4.5.0     cluster_2.1.8.1    pkgconfig_2.0.3    data.table_1.17.0 
[17] checkmate_2.3.2    RColorBrewer_1.1-3 lifecycle_1.0.4    compiler_4.5.0    
[21] farver_2.1.2       mnormt_2.1.1       mitools_2.4        htmltools_0.5.8.1 
[25] lazyeval_0.2.2     yaml_2.3.10        htmlTable_2.4.3    Formula_1.2-5     
[29] pillar_1.10.2      cachem_1.1.0       Hmisc_5.2-3        rpart_4.1.24      
[33] nlme_3.1-168       lavaan_0.6-19      tidyselect_1.2.1   digest_0.6.37     
[37] mvtnorm_1.3-3      stringi_1.8.7      reshape2_1.4.4     labeling_0.4.3    
[41] fastmap_1.2.0      grid_4.5.0         colorspace_2.1-1   cli_3.6.5         
[45] magrittr_2.0.3     base64enc_0.1-3    pbivnorm_0.6.0     foreign_0.8-90    
[49] withr_3.0.2        scales_1.4.0       backports_1.5.0    timechange_0.3.0  
[53] httr_1.4.7         rmarkdown_2.29     nnet_7.3-20        gridExtra_2.3     
[57] hms_1.1.3          memoise_2.0.1      evaluate_1.0.3     knitr_1.50        
[61] mix_1.0-13         viridisLite_0.4.2  rlang_1.1.6        Rcpp_1.0.14       
[65] xtable_1.8-4       glue_1.8.0         DBI_1.2.3          rstudioapi_0.17.1 
[69] jsonlite_2.0.0     R6_2.6.1           plyr_1.8.9        

Feedback

Please consider providing feedback about this textbook, so that I can make it as helpful as possible. You can provide feedback at the following link: https://forms.gle/LsnVKwqmS1VuxWD18

Email Notification

The online version of this book will remain open access. If you want to know when the print version of the book is for sale, enter your email below so I can let you know.