Consider Question 5. Plot the analytic rejection rates of ϕ_1 and ϕ_2 on the same panel faceted by sample size assuming α=0.05 over a grid of σ^2∈[1,10] for n∈{5,10,15,20}. Verify that the tests have the same size and that ϕ_1 is uniformly more powerful than ϕ_2.
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.2 ✔ tibble 3.3.0
✔ lubridate 1.9.4 ✔ tidyr 1.3.1
✔ purrr 1.1.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
ggplot(power_df) +geom_line(aes(x = sigma2_true, y = power_phi1, color ="ϕ1: sum of squares")) +geom_line(aes(x = sigma2_true, y = power_phi2, color ="ϕ2: mean")) +facet_wrap(~n, labeller = label_both) +geom_hline(yintercept = alpha, linetype =2) +theme_classic() +labs(x =expression(sigma^2),y ="Power / P(reject H0)",color ="" )
Consider Question 7. Let ϕ_1 represent the uniformly most powerful size-α test, and ϕ_2 a second size-α test that rejects the null when Y ‾>k for some constant k. Note that neither of these test statistics have closed-form analytic sampling distributions! For each n∈{5,10,15,20}:
Find the simulated rejection regions for ϕ_1 and ϕ_2, using 10,000 replications per n, for α=0.05;
Simulate the rejection probabilities for ϕ_1 and ϕ_2 over a length-20 grid of θ∈[0.2,1];
Plot the rejection probabilities of ϕ_1 and ϕ_2 versus θ, faceted by n, to verify that both tests have the same size and that ϕ_1 is indeed uniformly more powerful than ϕ_2.