I just performed simple simulation. Made two "populations" with different means and the same variance. Since I prepared them I know that they: are normal, differs in location and both have the same scale. Then I wrote simple script in R which 1000 times draws samples from the both populations, test them for normality (Shapiro-Wilk), for equal variances (F) and for difference (t). If the assumptions of t-test are met I run t-test.
Well, in fact I run all of them one by one, but combine the results with logical AND operator. So, if IsNormal(A) AND IsNormal(B) AND VarsAreEqual(A, B) AND MeansAreDifferent(A, B), then I count the result. Finally I divide number of TRUE values and divide it by the number of iterations. So, every test of assumption may fail. Shapiro-Wilk may falsely (they ARE normal) reject H0 as well as F test (they HAVE equal variances). And I don't get values near 0.05!
So, my question is: is this an example of the "multiple testing" phenomena (like multiple comparisons)? If so, what about testing for assumptions? Such testing is crucial as if the assumptions are not met, the quantiles of sampling distribution of a given test may be completely different than expected and so given results may be completely useless. But testing for the assumptions clearly changes the alpha. Am I correct?
Perhaps we should use corrections for alpha, like Bonferroni?
data<- data.frame(populA=rnorm(1000, mean=1), populB=rnorm(1000, mean=3))
iternum <- 1000
alpha <- 0.05
nsample <- 50
results <- array(FALSE, iternum);
for(i in 1:iternum) {
sampA <- sample(data$populA, 30);
sampB <- sample(data$populB, 30);
result_t <- t.test(sampA, sampB)$p.value;
result_F <- var.test(sampA, sampB)$p.value;
result_normA <- shapiro.test(sampA)$p.value;
result_normB <- shapiro.test(sampB)$p.value;
results[i] <- (result_normA >= alpha) & (result_normB >= alpha) &
(result_F >= alpha) & (result_t < alpha)
}
> 1-(mean(results))
[1] 0.158