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?
What I am finally interested in is to determine the sample size for a future experiment. I like to take $n$ samples from an industrial process, analyse them and show that the process is well within its specification limits. This allows me to produce the product without measuring each part.
There are many subtle difficulties involved in the hypothesis test. That's why I setup the following toy model to focus the attention on the above described "numeric vs. ranked" question. Here is what I do:
I draw $n$ random numbers from two distributions $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 $0.5$ 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 set the producer risk to $\alpha \le 5\%$ and calculate the consumer risk (target value set to $\beta \le 20\%$). The producer risk defines a cutoff, which I obtain by utilising the quantile function. The consumer risk it calculated by counting how many elements drawn from the alternative distribution are "beyond" the cutoff.
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?