9.6 For Individual Teams

# retrieve team that is on offense (at bat)
retro2016_complete <- retro2016_complete |>
  mutate(home_team_id = str_sub(game_id, 1, 3),
         batting_team = if_else(bat_home_id == 0, away_team_id, home_team_id))

# tally states by team
T_team <- retro2016_complete |> group_by(batting_team, state, new_state) |>  count()

9.6.1 Toward NOBLETIGER

NOBL <- retro2016_complete |> 
  filter(state == "111 0") |>
  group_by(batting_team, state, new_state) |> tally() |> ungroup()
Toward NOBLETIGERs
count: no outs, bases loaded
batting_team NOBL_sum
ANA 32
ARI 15
ATL 31
BAL 22
BOS 28
CHA 23
CHN 17
CIN 29
CLE 20
COL 19
DET 27
HOU 17
KCA 14
LAN 23
MIA 16
MIL 22
MIN 21
NYA 25
NYN 24
OAK 22
PHI 13
PIT 27
SDN 18
SEA 36
SFN 32
SLN 19
TBA 15
TEX 22
TOR 22
WAS 27
table code
NOBL |>
  group_by(batting_team) |>
  mutate(NOBL_sum = sum(n)) |>
  ungroup() |>
  select(batting_team, NOBL_sum) |>
  distinct() |>
  gt() |>
  cols_align(align = "center") |>
  data_color(columns = NOBL_sum,
             palette = "inferno") |>
  tab_header(title = "Toward NOBLETIGERs",
             subtitle = "count: no outs, bases loaded")

For some of the less common transitions, there is much variability in the counts across teams

9.6.2 Smoothing Operation

\[p^{\text{EST}} = \frac{n}{n+K}p^{\text{TEAM}} + \frac{K}{n+K}p^{\text{ALL}}\]

  • \(n\): number of state transitions for TEAM

  • \(K\): smoothing parameter (e.g. \(K = 1274\))

    • dependent of starting state