I believed that the most powerful hypothesis test for comparing two normal distributions with different mean values, but a common standard deviation, uses the average value as test statistics. However, I tried to calculate the sample size using a Monte Carlo simulation and compared the two cases: (a) using the numeric average value as test statistic, and (b) transforming the data first to ranks and then calculating the average value. What I found is that the ranked data yields a smaller sample size. How is that possible?
Here is what I do:
I draw $n$ random numbers from each distribution $N(\mu_0, \sigma_0)$, and $N(\mu_1, \sigma_1)$, where $\mu_0 = 0$, $\mu_1 = 1$, and $\sigma_1=\sigma_0 = 1$. [I also checked $\mu_1 = 0.25$ and obtain a similar result.]
I calculate the test statistic (average value).
I repeat step 1+2 "many" times (10 000) to obtain a reliable answer.
I calculate the producer and consumer risk and check whether they satisfy
- producer risk (type I error) $\alpha \le 5\%$ and simultaneously
- consumer risk (type II error) $\beta \le 20\%$.
- If the conditions in step 4 are not satisfied, I return to step 1, but increase the sample size $n$.
The hypothesis test I performed is two-sided. If I use the numeric values of the random numbers the conditions (step 4) are satisfied for the sample size $n=8$. This is fine and consistent with analytic calculations. However, if I transform the random numbers to ranks,
Example: (0.0590, 0.5607, 0.1573, 0.5472) becomes (1, 4, 2, 3)
and then calculate the test statistic (again the average value) the sample size is only $n = 5$.
Intuitively, I understand that the ranking increases the separation of the samples. However, it also does so if the random number drawn from $N(\mu_0, \sigma_0)$ is accidentally larger than the random number drawn from $N(\mu_1, \sigma_1)$. What am I missing? Is it just a bug in my program? What is the most powerful test for the described case?