outcome: the continuous variable being compared across groups.
2
grouping: the categorical variable defining the groups (must have at least 2 levels).
3
alpha: the significance level; default is 0.05.
Example 1: Sweet Apple Acres
Applejack has come to us: “Between the Red Delicious row, the Honeycrisp row, and that new Zap Apple row Granny Smith insisted on plantin’, I reckon one of ‘em oughta be doin’ better than the others. Can you tell me if they’re really any different, or am I just imaginin’ things?”
row
bushels
Red Delicious Row
42.2
Red Delicious Row
45.3
Red Delicious Row
42.1
We will use the apple_harvest dataset to answer the following question:
Does apple harvest (in bushels) differ across the three orchard rows?
One-way ANOVA
Source df SS MS F p-value
────────────────────────────────────────────
row 2 160.9693 80.4846 2.468 0.095
Residuals 51 1663.4383 32.6164
────────────────────────────────────────────
Hypotheses (row):
H₀: All group means are equal (no effect of row)
H₁: At least one group mean differs (effect of row exists)
Test statistic: F(2, 51) = 2.468
p-value: 0.095
Conclusion: Fail to reject the null hypothesis (p = 0.095 ≥ α = 0.050)
Fail to reject H_0. There is not sufficient evidence to suggest that the production of the rows are different.
Example 2: Rarity’s Boutique
Rarity flits between racks of fabric: “Darling, I need your professional opinion. Between my Canterlot Couture line, my everyday Ponyville Casual line, and my absolutely dazzling Gala Elegance line, I use wildly different amounts of gemstones. Is the difference really as dramatic as I think?”
collection
gem_count
Canterlot Couture
59
Canterlot Couture
57
Canterlot Couture
64
We will use the boutique_gems dataset to answer the following question:
Does the number of gems used per dress differ across the three collections?
Example 2
What are the levels in our factor (collection)?
boutique_gems |>n_pct(collection)
collection
n (pct)
Canterlot Couture
15 (33.3%)
Gala Elegance
15 (33.3%)
Ponyville Casual
15 (33.3%)
Example 2
What are the summary statistics by level of collection?
One-way ANOVA
Source df SS MS F p-value
───────────────────────────────────────────────────
collection 2 35140.5778 17570.2889 311.110 < 0.001
Residuals 42 2372.0000 56.4762
───────────────────────────────────────────────────
Hypotheses (collection):
H₀: All group means are equal (no effect of collection)
H₁: At least one group mean differs (effect of collection exists)
Test statistic: F(2, 42) = 311.11
p-value: < 0.001
Conclusion: Reject the null hypothesis (p = < 0.001 < α = 0.050)
Reject H_0. There is sufficient evidence to suggest that the number of gems are different between the fashion lines.
Example 3: Ponyville Diner
Sunny Skies wipes down the counter after the lunch rush: “Feels like Caramel always walks away with better tips than me and Lyra put together. Before I start complainin’ to the manager, can you check if there’s actually a difference in how much we’re bringing in?”
server
tip_bits
Sunny Skies
4.08
Sunny Skies
6.12
Sunny Skies
0.12
We will use the ponyville_diner_tips dataset to answer the following question:
Does tip amount differ across the three servers?
Example 3
What are the levels in our factor (server)?
ponyville_diner_tips |>n_pct(server)
server
n (pct)
Caramel
22 (33.3%)
Lyra Heartstrings
22 (33.3%)
Sunny Skies
22 (33.3%)
Example 3
What are the summary statistics by level of server?
One-way ANOVA
Source df SS MS F p-value
────────────────────────────────────────────
server 2 109.2923 54.6461 1.356 0.265
Residuals 63 2539.3768 40.3076
────────────────────────────────────────────
Hypotheses (server):
H₀: All group means are equal (no effect of server)
H₁: At least one group mean differs (effect of server exists)
Test statistic: F(2, 63) = 1.356
p-value: 0.265
Conclusion: Fail to reject the null hypothesis (p = 0.265 ≥ α = 0.050)
Kruskal-Wallis test
M[Honeycrisp Row] = 41 (n = 18)
M[Red Delicious Row] = 42 (n = 18)
M[Zap Apple Row] = 38.45 (n = 18)
Hypotheses:
H₀: All group distributions are equal (no effect of row)
H₁: At least one group distribution differs in location (effect of row exists)
Test statistic: H(2) = 5.953
p-value: 0.051
Conclusion: Fail to reject the null hypothesis (p = 0.051 ≥ α = 0.050)
Kruskal-Wallis test
M[Caramel] = 6.03 (n = 22)
M[Lyra Heartstrings] = 2.94 (n = 22)
M[Sunny Skies] = 4.305 (n = 22)
Hypotheses:
H₀: All group distributions are equal (no effect of server)
H₁: At least one group distribution differs in location (effect of server exists)
Test statistic: H(2) = 4.235
p-value: 0.120
Conclusion: Fail to reject the null hypothesis (p = 0.120 ≥ α = 0.050)
Example 3
Hypotheses
H_0: M_{\text{C}} = M_{\text{LH}} = M_{\text{SS}}
H_1: at least one median is different.
Test Statistic and p-Value:
\chi^2_0 = 4.235
p = 0.120
Rejection Region
Reject H_0 if p < \alpha; \alpha = 0.05
Conclusion / Interpretation
Fail to reject H_0. There is not sufficient evidence to suggest that the servers are earning different tips.
Let’s Practice! Wonderbolts Academy
Fleetfoot drops a stack of stopwatch printouts on the table: “Command wants to know if lap times actually differ across our four training squads: Thunderhead, Stormwing, Skybolt, and Downburst.”
squad
lap_seconds
Thunderhead
60.4
Thunderhead
59.6
Thunderhead
62.0
We will use the wonderbolts_laptimes dataset to answer the following question:
Do lap times differ across the four training squads?
Let’s Practice!: Klugetown Bazaar
A weary trader waves you over between haggling matches: “Rustbolt, Glimmering, and Junker each swear their stall pulls in the best prices. I’ve got a season’s worth of sale records — do the three stalls actually sell for different amounts, or is everyone just talkin’ up their own wares?”
stall
sale_price_bits
Rustbolt’s Relics
21.25
Rustbolt’s Relics
18.93
Rustbolt’s Relics
26.79
We will use the klugetown_bazaar dataset to answer the following question:
Does sale price differ across the three market stalls?
Let’s Practice!: Baltimare Harbor
The harbormaster spreads a stack of logbooks across the table: “Four dock crews unload every ship that comes through: Anchor, Tidewater, Saltmarsh, and Driftwood. Some of the sailors have been grumbling that one crew is dragging everyone’s schedule behind. Before I say anything to the crews, I want to know if unloading time actually differs across them.”
crew
unload_minutes
Anchor Crew
1.30
Anchor Crew
2.19
Anchor Crew
5.13
We will use the baltimare_harbor dataset to answer the following question:
Does unloading time differ across the four dock crews?
Wrap Up
This lecture introduced one-way ANOVA.
One-way ANOVA examines the effect of a single factor.
(We will learn about multiple factors in the future!)
One-way ANOVA only allows us to determine if there is an overall, or omnibus, effect.