Comparing groups

Research Methods — Week 7

Recap

Where we are

Last week: t-tests for two groups. The base rate fallacy.

This week: what happens when you have more than two groups — and more than one test.

Questions?

Submit questions anonymously:

PollEv.com/geol

text geol to 07480 781235

Why not just do lots of t-tests?

🎓 Concept block 1

The problem

Three groups (e.g., wind farms in three regions).

You could run three pairwise t-tests: A vs B, A vs C, B vs C.

Each test has a 5% false positive rate.

Three tests: P(at least one false positive) = 1 − 0.95³ ≈ 14%

Ten tests: 40%

Twenty tests: 64%

The escalation

Number of tests P(≥1 false positive)
1 5%
3 14%
10 40%
20 64%
100 99.4%

Run enough tests and you’re guaranteed to “find” something.

HolmesCo’s mineral survey

“Geological Solutions Since 2019”

Press Release — Multi-Element Anomaly Discovered!

“We tested soil samples from 20 sites for enrichment in 20 elements. We found statistically significant enrichment (p < 0.05) for three elements at one site!”

If there’s truly nothing there, how many significant results would you expect by chance?

The answer

20 × 20 = 400 tests at α = 0.05

Expected false positives: 20

HolmesCo found 3.

That’s fewer than expected by chance. The “discovery” is noise.

How many tests?

💬 Exercise 1

Your project

How many comparisons are you planning to make?

If you run all of them at α = 0.05, what’s your family-wise false positive rate?

Formula: 1 − (1 − α)k where k = number of tests

ANOVA

🎓💻 Concept block 2

One test for multiple groups

ANOVA (Analysis of Variance) asks:

“Does any group differ from the others?”

Without specifying which.

The logic

  1. Total variation = between groups + within groups
  2. If between-group variation is large relative to within-group → at least one group is different
  3. The F-statistic captures this ratio
  4. The p-value tells you how surprising this F is under the null

Live demo

model <- aov(output ~ region, data = wind_df)
summary(model)

If significant → which pairs differ?

TukeyHSD(model)

Corrections for multiple comparisons

Method How When
Tukey’s HSD All pairwise, designed for ANOVA After a significant ANOVA
Bonferroni Divide α by number of tests Simple, conservative, any context

Both reduce the false positive rate by being stricter about what counts as significant.

Run an ANOVA

✏️💻 Exercise 2

In WebR

Provided dataset: wind farm output in four regions.

  1. Visualise with boxplots
  2. Run aov()
  3. Is it significant?
  4. Run TukeyHSD() — which pairs differ?
  5. Write a one-sentence conclusion

Effect sizes

🎓 Concept block 3

“Significant” ≠ “important”

A p-value tells you whether an effect is detectable.

It does not tell you whether it’s big enough to matter.

The HolmesCo temperature problem

“Geological Solutions Since 2019”

Two boreholes, 1,000 readings each.

Mean difference: 0.02°C. p-value: 0.001.

“Highly significant temperature anomaly detected!”

Is 0.02°C meaningful for any practical purpose?

Cohen’s d

A standardised measure of how far apart two groups are:

d Interpretation
0.2 Small
0.5 Medium
0.8 Large
effectsize::cohens_d(y ~ group, data = df)

For ANOVA: η² (eta-squared)

Proportion of variance explained by the grouping variable.

η² Interpretation
0.01 Small
0.06 Medium
0.14 Large

Always report both the p-value and an effect size.

A policy-maker needs to know “how big?” — not just “is it real?”

HolmesCo’s report card

✏️💬 Integrative exercise

Three test results

“Geological Solutions Since 2019”

Technical Summary

  1. Test A: p = 0.002, Cohen’s d = 1.2
  2. Test B: p = 0.04, Cohen’s d = 0.08
  3. Test C: p = 0.08, 95% CI = [−0.3, 6.1]

For each: should we act on this? Why or why not?

Wrap-up

Key points

  1. Multiple tests inflate false positives — correct for them
  2. ANOVA compares multiple groups in one test; TukeyHSD finds which differ
  3. Significance ≠ importance — always report effect sizes
  4. “Is that a big number?” now has a formal answer

Next time

Application session: “Deepening your analysis”

Apply ANOVA or refine your t-test with effect sizes and assumption checks.