alpha <- 0.05
n_values <- c(5, 10, 15, 20)
sigma2_grid <- seq(1, 10, length.out = 100)
q8_results <- expand_grid(
n = n_values,
sigma2_a = sigma2_grid
) %>%
mutate(
sigma_a = sqrt(sigma2_a),
chi_cutoff = qchisq(1 - alpha, df = n),
power_phi1 = 1 - pchisq(chi_cutoff / sigma2_a, df = n),
z_cutoff = qnorm(1 - alpha),
power_phi2 = 1 - pnorm(z_cutoff / sigma_a)
) %>%
pivot_longer(
cols = c(power_phi1, power_phi2),
names_to = "test",
values_to = "rejection_rate"
)
ggplot(q8_results, aes(x = sigma2_a, y = rejection_rate, color = test)) +
geom_line(linewidth = 1) +
facet_wrap(~ n) +
labs(
title = "Analytic Rejection Rates for Question 5",
x = expression(sigma[a]^2),
y = "Rejection Rate",
color = "Test"
) +
theme_minimal()