library(tidyverse)
# In your own class folder this path is just "Data/resumes-2.csv"
resumes <- read_csv("../Slides/Data/resumes-2.csv", show_col_types = FALSE) |>
mutate(cb = as.numeric(call == "yes")) # 1 = callback, 0 = no callbackYou Try Answers: Hypothesis Testing
POSC 8410
You Try
Question 3 involves a random subsample, so your numbers for that question will differ from mine. I use set.seed(8410) so this document gives the same numbers every time it renders. Questions 1 and 2 use the full data, so those should match exactly.
1. Run t.test(cb ~ quality, data = resumes). What are \(H_0\), the test statistic, and the \(p\)-value?
tt_q <- t.test(cb ~ quality, data = resumes)
tt_q
Welch Two Sample t-test
data: cb by quality
t = 1.8038, df = 4843.8, p-value = 0.07132
alternative hypothesis: true difference in means between group high and group low is not equal to 0
95 percent confidence interval:
-0.00122070 0.02933557
sample estimates:
mean in group high mean in group low
0.08748978 0.07343234
Reading the output:
- The null hypothesis. \(H_0\): high- and low-quality résumés have the same callback rate in the population, \(\mu_{\text{high}} - \mu_{\text{low}} = 0\). The alternative is two-sided: the rates differ, in either direction. R states the alternative on the line that begins
alternative hypothesis. - The estimate. High-quality résumés got callbacks 8.7% of the time and low-quality ones 7.3%, a gap of 1.4 percentage points. R subtracts in alphabetical order, so here it is
highminuslow. - The test statistic. \(t =\) 1.80. The observed gap is 1.8 standard errors from zero.
- The \(p\)-value. \(p =\) 0.071. If résumé quality truly made no difference, we would see a gap at least this large, in either direction, in about 7% of studies like this one.
2. Does résumé quality significantly predict callbacks overall? Compare that to the race gap.
tt_r <- t.test(cb ~ ethnicity, data = resumes)
tibble(comparison = c("quality: high minus low", "race: white minus Black names"),
gap_pts = 100 * c(tt_q$estimate[1] - tt_q$estimate[2],
tt_r$estimate[2] - tt_r$estimate[1]),
se_pts = 100 * c(tt_q$stderr, tt_r$stderr),
t = abs(c(tt_q$statistic, tt_r$statistic)),
p = c(tt_q$p.value, tt_r$p.value)) |>
knitr::kable(digits = c(0, 2, 2, 2, 5))| comparison | gap_pts | se_pts | t | p |
|---|---|---|---|---|
| quality: high minus low | 1.41 | 0.78 | 1.80 | 0.07132 |
| race: white minus Black names | 3.20 | 0.78 | 4.11 | 0.00004 |
No, not at the conventional 5% level. With \(p =\) 0.071, we fail to reject the null that quality makes no difference. The race gap, by contrast, is more than four standard errors from zero.
This does not show that quality is irrelevant. The quality gap is positive, in the expected direction, and \(p = 0.07\) is close to the cut-off. A fair summary is that the evidence for a quality effect is weak, not that there is none (see question 4).
3. Take a random subsample of 200 résumés and rerun the race comparison. Is it still significant? Why might it not be?
set.seed(8410)
sub <- slice_sample(resumes, n = 200)
table(sub$ethnicity)
afam cauc
100 100
t.test(cb ~ ethnicity, data = sub)
Welch Two Sample t-test
data: cb by ethnicity
t = -1.5656, df = 176.76, p-value = 0.1192
alternative hypothesis: true difference in means between group afam and group cauc is not equal to 0
95 percent confidence interval:
-0.13563039 0.01563039
sample estimates:
mean in group afam mean in group cauc
0.05 0.11
In my subsample, no: \(p =\) 0.12. Your subsample will differ, and you may get either answer, but most of you should get a non-significant result.
The effect did not go away. We are drawing from the same experiment, in which the gap is real. What changed is the standard error. With 200 résumés instead of 4,870, the standard error is about \(\sqrt{4870/200} \approx\) 4.9 times larger, so a 3-point gap is now well under two standard errors from zero.
How often would a study of 200 résumés detect the gap? Repeat the subsampling many times:
set.seed(8410)
sims <- replicate(5000, {
s <- slice_sample(resumes, n = 200)
tt <- t.test(cb ~ ethnicity, data = s)
c(gap = unname(tt$estimate[2] - tt$estimate[1]), p = tt$p.value)
})
signif <- sims["p", ] < 0.05 # which subsamples reached significance
c(power = mean(signif), # share significant
avg_gap_if_significant = 100 * mean(abs(sims["gap", signif])), # points
true_gap = 100 * unname(tt_r$estimate[2] - tt_r$estimate[1])) power avg_gap_if_significant true_gap
0.125400 9.292481 3.203285
A study of 200 résumés finds a significant race gap only about 13% of the time. Its power is low. This matches the slides’ simulation, where 100 résumés per group gave power of 0.13.
The second number is the exaggeration problem from class. When the small study does reach significance, its estimate averages 9.3 points, far above the full-sample 3.2. Only unusually large gaps clear the bar with this much noise.
4. A colleague says “\(p = 0.30\), so there is no effect.” Rewrite that sentence correctly.
A better version:
“We cannot reject the null hypothesis of no effect at conventional levels (\(p = 0.30\)). The data are consistent with no effect, but also with effects of meaningful size.”
The original sentence makes two mistakes:
- Failing to reject is not accepting. A \(p\)-value of 0.30 says the data would not be unusual if there were no effect. It does not say there is no effect.
- It says nothing about size. The useful follow-up is: what effect sizes can the data rule out? That is what a confidence interval answers (next class). If the interval is narrow and centered near zero, you can say that any effect is small. If it is wide, the best conclusion is that the study cannot tell.
The general principle: absence of evidence is not evidence of absence, unless the study had enough power to find the effect if it were there.