Project: Comparing Several Means (ANOVA)

Project — Analysis of Variance. Carry out the analysis in Jamovi (or R) and communicate the result. ANOVA asks whether any of several group means differ; the graded skills are framing that question, checking conditions, and interpreting the F-test in context.

The question

In baseball, a player’s on-base percentage (OBP) measures how often they reach base. Do players at different field positions tend to get on base at different rates?

Do mean OBP values differ across infielders, outfielders, and catchers?

The data

mlb_players_18 holds 2018 Major League Baseball players. You’ll use OBP and position. We restrict to position players with regular playing time (at least 100 at-bats) and group positions into Infield, Outfield, and Catcher (pitchers and designated hitters are set aside). The R tab builds that grouping; in Jamovi you would create the same grouped column.

Plan it first

  1. Variables. Identify the numerical response and the categorical explanatory variable, and how many groups it has.
  2. Hypotheses. State \(H_0\) (all group means equal) and \(H_A\) (at least one differs). Why is \(H_A\) not “all means are different”?
  3. Procedure. One numerical outcome across three groups → one-way ANOVA (the F-test), not a pile of \(t\)-tests. Why not just run all the pairwise \(t\)-tests?
  4. After ANOVA. If F is discernible, what additional step tells you which positions differ?

Do the analysis

  1. Open mlb_players_18.csv; filter to AB >= 100 and create a pos_group column (Infield / Outfield / Catcher).
  2. ANOVA → One-Way ANOVA. Dependent variable: OBP; Grouping variable: pos_group.
  3. Request the F-test, descriptives, a homogeneity (Levene) check, and post-hoc comparisons (Tukey).
  4. Read off the group means, the F-statistic and p-value, and which pairs the post-hoc test flags.

(Jamovi screenshots to be added.)

library(infer)
library(dplyr)
library(ggplot2)
library(openintro)
data(mlb_players_18)

# Regular position players, grouped into Infield / Outfield / Catcher
infield  <- c("1B", "2B", "3B", "SS")
outfield <- c("LF", "CF", "RF")
d <- mlb_players_18 |>
  filter(position %in% c(infield, outfield, "C"), AB >= 100) |>
  mutate(pos_group = case_when(
    position %in% infield  ~ "Infield",
    position %in% outfield ~ "Outfield",
    TRUE                   ~ "Catcher"))

# Group means and sizes
d |>
  group_by(pos_group) |>
  summarize(mean_OBP = mean(OBP), sd = sd(OBP), n = n())
# A tibble: 3 × 4
  pos_group mean_OBP     sd     n
  <chr>        <dbl>  <dbl> <int>
1 Catcher      0.302 0.0382    64
2 Infield      0.318 0.0379   205
3 Outfield     0.320 0.0426   160
# Observed F statistic, then a randomization (permutation) F distribution
obs_F <- d |> specify(OBP ~ pos_group) |> calculate(stat = "F")
obs_F
Response: OBP (numeric)
Explanatory: pos_group (factor)
# A tibble: 1 × 1
   stat
  <dbl>
1  5.08
set.seed(145)
null_F <- d |>
  specify(OBP ~ pos_group) |>
  hypothesize(null = "independence") |>
  generate(reps = 1000, type = "permute") |>
  calculate(stat = "F")

null_F |> get_p_value(obs_stat = obs_F, direction = "greater")
# A tibble: 1 × 1
  p_value
    <dbl>
1   0.006
ggplot(d, aes(pos_group, OBP, fill = pos_group)) +
  geom_boxplot(show.legend = FALSE) +
  labs(x = "Position group", y = "On-base percentage") +
  theme_minimal(base_size = 13)

Boxplots of on-base percentage for Catcher, Infield, and Outfield groups; the medians are close, with catchers slightly lower.

On-base percentage by position group for regular MLB position players in 2018.

Your deliverable

Submit a short report containing all of:

  1. Graphic — labeled boxplots of OBP by position group.
  2. Numerical result — the group means, the F-statistic, and the p-value.
  3. Conditions — one sentence on the ANOVA conditions (independent groups, roughly normal, similar spreads).
  4. Conclusion in context — 3–4 sentences: is there discernible evidence that mean OBP differs by position group? If so, note that ANOVA alone doesn’t say which groups differ, and report what the post-hoc comparison found (if you ran it).
  5. One limitation — e.g., position grouping is a simplification; 2018 only.

How it’s graded

Criterion What we look for
Appropriate, labeled graphic boxplots by group, axes labeled
Procedure & conditions one-way ANOVA identified; conditions addressed
Correct numerical result group means, F, p-value reported correctly
Conclusion in context discernibility + “F doesn’t say which pair” + post-hoc if used
Communication clear, correct interpretation

Warm up first. Build intuition for between- vs. within-group variation in the ANOVA tool before writing your report.