Suppose \(Y_1,...,Y_n \stackrel{i.i.d.}{\sim} N(\mu,\sigma^2 = 36)\). We want to test:
\[H_0: \mu = 3\]\[H_a: \mu > 3\]
We will reject \(H_0\) using the test statistic:
\[T = \frac{\bar Y -3}{\sigma/\sqrt{n}}\]
and will reject when \(T > c\).
A. Suppose we want to set \(c\) such that \(\alpha = 0.05\). Find \(c\).
B. Find an expression for the power as a function of \(n\) and the “effect size”, \(d=(\mu_a - \mu_0)/\sigma\).
C. Consider an effect size of \(d=1\). Determine the sample size necessary to achieve a power of at least 0.8.
D. Plot the analytic power function as a function of the effect size \(d\) for \(n = 20\).
E. Plot the analytic power function as a function of \(n\) if \(d = 1\).
F. Although not necessary, use a simulation study to approximate the values of \(c\) for each \(n\in \{5,10,...,50\}\). Compare the simulated values of \(c\) to their analytic counterparts.
G. Simulate the rejection rates of this test using the analytic rejection regions for \(\mu\in\{3,3.5,4,4.5\}\). Plot the rejection rates as a function of \(n\) faceted by the effect size \(d\).
Problem 1
Suppose \(Y_1,...,Y_n\) are an i.i.d. \(UNIF(0,\theta)\) sample. Consider two different tests of \(H_0: \theta = 1\) versus \(H_a: \theta > 1\).
Test 1 rejects \(H_0\) if \(Y_{(n)}> c_1\).
Test 2 rejects \(H_0\) if \(\bar Y> c_2\).
We want both tests to have 5% type-I error rate.
A. Show that \(c_1\) can be found analytically to be \(0.95^{1/n}\).
Find a general expression for the power function of Test 1 as a function of \(n\) and \(\theta_a\). Plot curve as a function of \(n\) for \(\theta = 1.2.\)
n_vals <-seq(5, 50, by =5)power_test1_theta12 <-1-0.95/ (1.2^n_vals)plot( n_vals, power_test1_theta12, type ="b", pch =19, xlab ="n", ylab ="Power", main =expression("Power of Test 1 for "* theta ==1.2) )
C. Explain why an exact value of \(c_2\) cannot be found analytically and must be simulated.
c2 is harder to get exactly because it depends on the distribution of YˉYYˉ, not the maximum. Under H0H_0H0, YˉYYˉ is the average of uniform random variables, and there is not a simple formula to directly solve for the 95th percentile for each nnn. Because of that, simulation is used to estimate the cutoff value that gives a 5% type-I error rate
D. Simulate values of \(c_2\) that yield 5% type-I error rates for Test 2, for \(n \in \{5,10,...,50\}\).
E. Use a simulation study to compare the sizes and the power curves of the two tests as a function of \(n\) for \(\theta_{true} \in \{1,1.1,1.2,1.3\}.\) Use analytic rejection regions for \(Y_{(n)}\) and simulated rejection regions for \(\bar Y\), but simulate the rejection probabilities for both. Plot the simulated Type-I error rate/power as a function of \(n\) for each \(\theta_{true}\). Discuss the properties of these tests: does one seem preferable?
At θ=1=1θ=1, both tests should stay close to 0.05 since that is the target size. As θincreases, both rejection probabilities increase, but Test 1 usually increases faster because the maximum reacts more directly when the upper endpoint gets larger.