I aim to check the robustness of 2 groups t-test when samples come from lightly skewed distributions. To approach the problem I though about performing a Montecarlo based robustness analysis using experimental sample sizes and zero centered means, but, for setting the expected skewnes and variance of each group populations I wonder if it would be right to resampling from sample distributions (bootstrapping strategy) instead of sampling from a expected distribution of the population according to the nature of the variable studied.
An example on sleep R dataset:
plot(extra ~ group, data = sleep)
robust_fun<-function(x,y,iter=10^5, alter="two.sided", welch=F)
{
# Robustness of t.test. Bootstrap from empirical distributions.
# sample sizes
nx<-length(as.numeric(x))
ny<-length(as.numeric(y))
# dsitribution centered in the mean
x<-x-mean(x,na.rm=T)
y<-y-mean(y,na.rm=T)
# resampling with replazment
pval<-replicate(iter, t.test(remp(nx,x),remp(ny,y), var.equal=welch, alternative=alter)$p.val)
mean(pval <= 0.05)
}
sleep_data<-split(sleep$extra,sleep$group)
robust_fun(sleep_data$`1`,sleep_data$`2`,10000)
For 0.05 significance level the result was 0.0521. Is this robustneess analysis trustworthy?
remp
does) and testing the difference between them (which by definition is now 0) using a Student's t-test. Having ~5% of p-values <= .05 is exactly what we'd expect here. If you want a test of the difference that's robust to data from lightly skewed distributions, why not use the regular Welch test and skip the bootstrap? Unless you want something different? $\endgroup$