There Really is Only One Test
Issues of Significance
set.seed(42)
score_distributions <-
tibble(
observed = rnorm(50, mean = 105, sd = 15),
null = rnorm(50, mean = 100, sd = 15)
) |>
tidyr::pivot_longer(
cols = everything(), names_to = "dist", values_to = "value"
)
score_distributions |>
ggplot(aes(value, fill = dist)) +
geom_density(alpha = 0.6) +
labs(
title = "IQ Scores Observed & Null Distributions (n = 50)",
x = "IQ Score", y = NULL
) +
scwplot::scale_fill_qualitative(palette = "scw")
statistic | p_value | estimate | lower_ci | upper_ci |
---|---|---|---|---|
1.83 | 0.07 | 104.46 | 99.56 | 109.37 |
set.seed(42)
score_distributions <-
tibble(
observed = rnorm(75, mean = 105, sd = 15),
null = rnorm(75, mean = 100, sd = 15)
) |>
tidyr::pivot_longer(
cols = everything(), names_to = "dist", values_to = "value"
)
score_distributions |>
ggplot(aes(value, fill = dist)) +
geom_density(alpha = 0.6) +
labs(
title = "IQ Scores Observed & Null Distributions (n = 75)",
x = "IQ Score", y = NULL
) +
scwplot::scale_fill_qualitative(palette = "scw")
statistic | p_value | estimate | lower_ci | upper_ci |
---|---|---|---|---|
2.83 | 0.01 | 105.36 | 101.59 | 109.12 |
t <-
smaller_sample |>
specify(response = iq_score) |>
calculate(stat = "mean")
null <-
smaller_sample |>
specify(response = iq_score) |>
hypothesize(null = "point", mu = 100) |>
generate(reps = 1000, type = "bootstrap") |>
calculate(stat = "mean")
p <- null |> get_p_value(obs_stat = t, direction = "two-sided")
null |>
visualize() +
shade_p_value(t, direction = "two-sided") +
annotate(
"text", x = 95, y = 125,
label = paste0("t = ", round(t, 2), "\n p = ", round(p, 2)),
size = rel(6), color="grey30"
) +
labs(x = "IQ Score", y = NULL, title = NULL)
t <-
larger_sample |>
specify(response = iq_score) |>
calculate(stat = "mean")
null <-
larger_sample |>
specify(response = iq_score) |>
hypothesize(null = "point", mu = 100) |>
generate(reps = 1000, type = "bootstrap") |>
calculate(stat = "mean")
p <- null |> get_p_value(obs_stat = t, direction = "two-sided")
null |>
visualize() +
shade_p_value(t, direction = "two-sided") +
annotate(
"text", x = 95, y = 125,
label = paste0("t = ", round(t, 2), "\n p = ", round(p, 2)),
size = rel(6), color="grey30"
) +
labs(x = "IQ Score", y = NULL, title = NULL)
Contact:
Code & Slides:
Paul Johnson // Simulation-Based Hypothesis Testing // Jan 24, 2025