
Errors and power
Covered last time:
Note
✅ Key idea from last lecture
A t-test gives you a p-value and a decision — reject or fail to reject H₀. Today asks the next question: how good is that decision, and how often could it be wrong?

Note
Today’s objectives
Note
📖 Reference
Gotelli & Ellison, A Primer of Ecological Statistics, Ch. 4 — Framing and Testing Hypotheses.

Useful hypotheses rely on specifying:

Together, H₀ and Hₐ encompass all possible outcomes:

Statistical tests assess the likelihood of the null hypothesis being true.

Hypothesis tests are expressed as a p-value (0 = never, 1 = always).
Interpret a p-value as: the probability of obtaining a sample value of the statistic (or a more extreme one) if H₀ is true.

Statistical test results:
Which p-value suggests H₀ is likely false?
At what point do we reject H₀?
p < 0.05 is the conventional “significance threshold” (α = alpha).
p < 0.05 means: if H₀ is true and we repeated the study 100 times, we would get this (or a more extreme) result less than 5 times due to chance.
Note
✅ Key idea
α is chosen before data collection. It’s a policy about how much Type I error risk you’re willing to accept — not something you pick after seeing the p-value.
Traditionally, α = 0.05 is used as the cutoff for rejecting H₀. There is nothing magical about 0.05 — actual p-values should be reported, and α still needs to be decided prior to the study.
| p-value range | Interpretation |
|---|---|
| P > 0.10 | No evidence against H₀ — data appear consistent with H₀ |
| 0.05 < P < 0.10 | Weak evidence against H₀ in favor of Hₐ |
| 0.01 < P < 0.05 | Moderate evidence against H₀ in favor of Hₐ |
| 0.001 < P < 0.01 | Strong evidence against H₀ in favor of Hₐ |
| P < 0.001 | Very strong evidence against H₀ in favor of Hₐ |
A p-value is the probability of observing the sample result (or something more extreme) if the null hypothesis is true.
Common interpretations:
Common misinterpretations:
Note there’s a difference in how the hypotheses are stated for a one-sample vs. a two-sample t-test.


“If p is between 0.1 and 0.9 there is certainly no reason to suspect the hypothesis tested. If it is below 0.02 it is strongly indicated that the hypothesis fails to account for the whole of the facts. We shall not often be astray if we draw a conventional line at .05 …”
— R.A. Fisher, on the p-value as an informal measure of discrepancy between data and H₀

Note
📖 Reference
Gotelli & Ellison, Ch. 4 — the “Errors in Hypothesis Testing” section covers exactly this material.


the dotted line is α = 0.05
When making decisions based on hypothesis tests, two types of errors can occur:
Type I Error (False Positive)
Type II Error (False Negative)
Statistical Power = 1 − β
The farther apart the means, or the lower the variance, the lower the β error — i.e., the higher the power.

When making decisions based on hypothesis tests, two types of errors can occur:
Type I Error (False Positive) — rejecting H₀ when it’s actually true. Probability = α.
Type II Error (False Negative) — failing to reject H₀ when it’s actually false. Probability = β.
Statistical Power = 1 − β — increases with larger sample size, larger effect size, lower variability, higher α level.
The farther apart the means, or the lower the variance, the lower the β error — i.e., the higher the power.

Tip
Practice Exercise: interpreting p-values and errors
Given the following scenarios, identify whether a Type I or Type II error might have occurred:
library(car)
library(patchwork)
library(tidyverse)
library(readxl)
m_df <- read_csv("data/mice_weights.csv") %>%
filter(!is.na(mass_g))
sidney_df <- m_df %>% filter(sampling_site == "Sidney Island")
vancouver_df <- m_df %>% filter(sampling_site == "Vancouver")
n1 <- nrow(sidney_df)
n2 <- nrow(vancouver_df)
sd_pooled <- sqrt((var(sidney_df$mass_g) * (n1-1) +
var(vancouver_df$mass_g) * (n2-1)) /
(n1 + n2 - 2))
# delta = 0.423: the standardized effect size (Cohen's d)
effect_size <- 1 / sd_pooled # Cohen's d
df <- n1 + n2 - 2
alpha <- 0.05
power <- power.t.test(n = min(n1, n2),
delta = effect_size,
sd = 1, # Using standardized effect size
sig.level = alpha,
type = "two.sample",
alternative = "two.sided")
power
Two-sample t test power calculation
n = 28
delta = 0.4231154
sd = 1
sig.level = 0.05
power = 0.3427604
alternative = two.sided
NOTE: n is number in *each* group
pine_switch_df <- read_excel("data/class_pine needle length switched.xlsx")
ps_df <- pine_switch_df %>%
group_by(group, tree_no, tree_char, side) %>%
summarise(length_mm = mean(length_mm, na.rm=TRUE))
ps_shady_df <- ps_df %>% filter(side == "shady")
ps_sunny_df <- ps_df %>% filter(side == "sunny")
pine_alpha <- 0.05
pine_n1 <- nrow(ps_shady_df)
pine_n2 <- nrow(ps_sunny_df)
pine_sd_pooled <- sqrt((var(ps_shady_df$length_mm) * (pine_n1-1) +
var(ps_sunny_df$length_mm) * (pine_n2-1)) /
(pine_n1 + pine_n2 - 2))
cat("Pooled SD:", round(pine_sd_pooled, 2), "mm\n\n")Pooled SD: 2.58 mm
Note
📖 Reference
Whitlock & Schluter, Ch. 14 — Designing Experiments, includes planning the sample size needed for a study.
# More realistic effect sizes to test:
observed_diff <- abs(mean(ps_shady_df$length_mm) - mean(ps_sunny_df$length_mm))
pine_effect_size_observed <- observed_diff / pine_sd_pooled
cat("Effect size for observed", round(observed_diff, 2), "mm difference: Cohen's d =", round(pine_effect_size_observed, 2), "\n")Effect size for observed 1.45 mm difference: Cohen's d = 0.56
Power for observed 1.45 mm difference: 0.182
Statistical power represents the probability of detecting a true effect (rejecting the null hypothesis when it is false). With a power of 97%, there’s a 97% chance of detecting a true difference of X units between the means of the two groups, if such a difference actually exists.
A power analysis like this is typically done for one of these purposes:
Note
✅ Key idea
With 97% power, this test has excellent ability to detect the specified effect size. Generally, 80% power is considered acceptable — so 97% indicates a very well-powered study for detecting a difference of this size between the groups.
Error bars are graphical representations of the variability of data that show:
Common types of error bars:
When interpreting graphs:

Pseudoreplication occurs when measurements that are not independent are analyzed as if they were independent.
Examples of pseudoreplication:
How to avoid pseudoreplication:

Key concepts covered: