The Net and the Interval
Test whether a new fishing net cuts bycatch, check the answer against a confidence interval, then test five fish species at once. You'll use R.
Assumes: standard error, t-based confidence intervals for a mean, and the steps of a hypothesis test (null and alternative hypotheses, t-score, p-value, significance level α, Type I error). In R you'll change one line at a time.
1. Did the new net cut bycatch?
Bycatch is fish a boat catches by accident. A long study of one fishing region (over 1,000 boats) found an average of 9,500 kg of bycatch per boat. A new net is meant to cut that. In a random sample of 60 boats using the new net, the mean bycatch was 9,100 kg, with a standard deviation of 2,210 kg.
The test, at significance level α = 0.01, where μ is the mean bycatch per boat if every boat used the new net:
- H0: μ = 9,500 kg (the new net changes nothing)
- HA: μ < 9,500 kg (it cuts bycatch). One-sided: only a decrease counts.
Press Run to store the numbers in R.
Predict
Before any calculation: will the p-value be low or high?
Locked in. Step 2 computes the p-value.
2. Is the drop significant?
The t-score counts how many standard errors the sample mean sits from the null value: t = (x̄ − μ0) ÷ SE, where SE = s ÷ √n. In R these are xbar, mu0 and se.
Your task: replace the NA with the t-score.
- Press Run as it is:
t_scoreandpareNA. - Replace
NA, then Run again.
Hint 1
Put the subtraction in brackets before dividing:(… - …) / se.Hint 2
The line should readt_score <- (xbar - mu0) / se.pt(t_score, df = n - 1) is the area under the t curve with n − 1 = 59 degrees of freedom to the left of the t-score: the chance, if H0 is true, of a sample mean this far below 9,500 or further.
Your prediction
You predicted a high p-value, and it is: SE = 2,210 ÷ √60 ≈ 285 kg, t ≈ −1.40, p ≈ 0.083, above 0.01. A drop of 400 kg sounds large, but bycatch varies a lot from boat to boat, so 400 kg is only 1.4 standard errors. One step further: with 240 boats (four times as many) and the same mean and SD, the SE halves to 143 kg, t ≈ −2.80 and p ≈ 0.003: significant.
You predicted a low p-value. A drop of 400 kg sounds large, but bycatch varies a lot from boat to boat (SD 2,210 kg): SE = 2,210 ÷ √60 ≈ 285 kg, so the drop is only t ≈ −1.40 standard errors, and p ≈ 0.083, above 0.01. One step further: with 240 boats (four times as many) and the same mean and SD, the SE halves to 143 kg, t ≈ −2.80 and p ≈ 0.003: then it would be significant.
p ≈ 0.083 and α = 0.01. What do you conclude?
3. Does the 99% interval contain 9,500?
A 99% confidence interval for μ from the same 60 boats is x̄ ± t* × SE, where t* ≈ 2.66 is the t value for 99% confidence with 59 degrees of freedom. It reaches 2.66 standard errors on each side of 9,100.
Before building it: will the 99% interval contain 9,500 kg, the null value?
Your task: replace the NA with the upper end, x̄ + t* × SE. Then Run.
Hint 1
Copy thelower line and change one sign.Hint 2
The line should readupper <- xbar + t_star * se.Your prediction
You predicted 9,500 would be outside. The interval runs from about 8,341 to 9,859 kg, so 9,500 is inside.
You predicted you couldn't tell without building it. That's a natural view: the test and the interval are different calculations. The interval runs from about 8,341 to 9,859 kg, with 9,500 inside.
Some people predict “yes” without building anything: “Step 2's t-score already says how far 9,100 is from 9,500, in standard errors.”
Why could they tell? Compare step 2's t-score (≈ −1.40) with t* ≈ 2.66.
Why you can tell in advance. The t-score says 9,100 is 1.40 standard errors below 9,500. The 99% interval reaches 2.66 standard errors either side of 9,100. 1.40 is less than 2.66, so 9,500 is inside. Both views agree: 9,500 is still a plausible value of μ.
Try it on a new case: another sample of 60 boats gives t = −3.1. Is 9,500 inside its 99% interval? No: 3.1 standard errors is further than 2.66.
You predicted yes, and the interval runs from about 8,341 to 9,859 kg, with 9,500 inside.
Some people say you can't know without building it: “the test and the interval are different calculations, so one can't tell you the other's answer.”
How would you show them, using step 2's t-score (≈ −1.40) and t* ≈ 2.66, that you could tell in advance?
Why you can tell in advance. Both use the same SE. The t-score says 9,100 is 1.40 standard errors below 9,500; the 99% interval reaches 2.66 standard errors either side of 9,100. 1.40 is less than 2.66, so 9,500 is inside. Both views agree: 9,500 is still a plausible value of μ.
Try it on a new case: another sample of 60 boats gives t = −3.1. Is 9,500 inside its 99% interval? No: 3.1 standard errors is further than 2.66.
The 99% interval and the null value μ0
4. Where does p cross 0.01?
What if the old nets' average had been some other number? Slide μ0. The interval stays put: it comes from the sample alone. The t-score and p-value change, because they measure how far x̄ is from μ0.
The p-value here is two-sided (a difference in either direction), because a confidence interval is two-sided; that's when the match between them is exact. At μ0 = 9,500 it is 0.166, double step 2's one-sided 0.083. With a one-sided test the match can break, so compare intervals with two-sided tests.
Slide until the two-sided p-value is as close to 0.01 as you can get. Where is μ0?
5. Predict without computing
The rule from step 4, for a two-sided test at α and a (1 − α) confidence interval from the same sample: μ0 inside the interval ⇔ p ≥ α ⇔ don't reject H0. A 95% interval goes with α = 0.05; a 99% interval with α = 0.01.
A 95% confidence interval for a city's mean commute is 31 to 38 minutes. A two-sided test of H0: μ = 40 minutes at α = 0.05, on the same sample, gives a p-value that is…
Say it in your own words
In 2–3 sentences: in what way do a confidence interval and a hypothesis test give the same information, and what does each tell you that the other doesn't?
One way to say it. Both give the same verdict: a two-sided test at α rejects μ0 exactly when μ0 is outside the (1 − α) confidence interval. The p-value adds how surprising the sample would be if H0 were true (for the net, two-sided p = 0.166, well above 0.01). The interval adds the range of plausible values for μ and how precise the estimate is (8,341 to 9,859 kg: the net might cut bycatch by over 1,000 kg, or raise it a little).
Compare with yours: did you say what the interval adds, beyond “contains μ0 or not”? That's the part most often left out.
R simulates 4,000 studies in a world where the net does nothing for any species. Once you have locked in your prediction, pick k, the number of species each study tests:
| Species per study (k) | Studies with at least one false alarm |
|---|
Each row is 4,000 simulated studies, so its percentages wobble by about a percentage point.
6. What happens with many tests?
Now test the net separately for each of several fish species, each test at α = 0.01. Suppose the net does nothing for any of them. Then every “significant” result is a false alarm: a Type I error, rejecting an H0 that is true. Each test alone has a 1% chance of one.
With 20 species, the chance that at least one comes out significant anyway is about…
You predicted about 1%. Each test's own false-alarm rate is 1%, but the chances build up: try k = 20 and the table shows about 18% of studies with at least one false alarm. One step further: with 100 species it's about 63%: more likely than not.
You predicted about 20%. Try k = 20: the table shows about 18% of studies with at least one false alarm, though each test's own rate is 1%. One step further: with 100 species it's about 63%: more likely than not.
You predicted over 90%. The chances do build up, but slowly at 1% each: try k = 20 and the table shows about 18%. One step further: with 100 species it's about 63%: more likely than not, but still not 90%.
The chance of at least one false alarm across a whole study is the family-wise error rate. It grows with the number of tests, while each test's own Type I error rate stays at α.
The Bonferroni correction holds the family-wise rate to α: with k tests, test each one at α ÷ k.
7. Which species pass the correction?
The study tests the new net on five species, A to E, and wants a family-wise error rate of 1% (α = 0.01). Each species gets its own one-sided test for a decrease.
Your task: replace the NA with the Bonferroni-corrected level for each test. Then Run: TRUE marks a species whose p-value is below it.
Hint 1
Use the namesalpha and n_tests.Hint 2
The line should readalpha_each <- alpha / n_tests.All five p-values are below 0.01. After the correction, for how many species is the decrease significant?
In 2–3 sentences: what do you conclude about the new net, species by species?
One way to say it. For species C and E, p is below 0.002: strong evidence that the new net cuts their bycatch. For A, B and D, p is below 0.01 but above 0.002, so after correcting for five tests we fail to reject H0: not enough evidence of a decrease, which is not the same as evidence that the net does nothing for them.
Compare with yours: for A, B and D, did you say “not enough evidence” rather than “the net doesn't work”?
8. Check yourself
A team compares 8 tutoring programs, each with its own test, and wants a family-wise error rate of 0.05. One program's test gives p = 0.01. Using the Bonferroni correction, is that result significant?
How sure were you?
You should now be able to:
- run a one-sample t-test in R and state the conclusion without “accepting” H0 (step 2);
- say, without computing, whether a confidence interval contains the null value from a test's result, and the other way round (steps 3–5);
- explain why many tests raise the chance of a false alarm, and apply the Bonferroni correction α ÷ k (steps 6–7).
If one of these isn't clear yet, go back to the step in brackets.
Welcome back: two quick questions
A two-sided test of H0: μ = 12 at α = 0.05 gives p = 0.30. Does the 95% confidence interval from the same sample contain 12?
A study runs 4 tests and wants a family-wise error rate of 0.01. With the Bonferroni correction, each p-value is compared with…
Assumptions
- dataThe bycatch numbers (old mean 9,500 kg; 60 boats, mean 9,100 kg, SD 2,210 kg) and the five p-values are from a practice problem, not a real study. The species are unnamed (A to E).
- simplificationThe 60 boats are a random sample of boats in the region, with independent catches; with n = 60, the t procedures apply.
- parameterSteps 1–2: one-sided test for a decrease at α = 0.01. Steps 3–4: 99% interval, t* = qt(0.995, 59) ≈ 2.66; step 4's p-value is two-sided. Step 6: 4,000 simulated studies per k (set.seed(k)); each species' t-score drawn from a t distribution with 59 degrees of freedom, as if the net did nothing; tests independent.
- interpretationThe match “μ0 inside the (1 − α) interval ⇔ p ≥ α” is exact for two-sided tests on the same sample. Bonferroni: with k tests, each is tested at α ÷ k.
Left out: the formula for the family-wise error rate, tests for proportions, and Type II errors and power.