# Bootstrap and hypothesis test

#### rogojel

##### TS Contributor
Hi,
I have to decide whether two groups have the same variance or not. My sample size is less then impressive, 13 data points per group. I ran Bartletts test and got a p-value of 0.09 - but I suspected that the relatively high value might be due to the small sample size.

So, I ran a bootstrap - sampled with replacement 15 points per group and ran the Bartlett test 100 times. I get a p value that is lower then 0.05 in 50% of the runs.

Could I conclude that probably there is a systematic difference between the two groups?

regards

#### gianmarco

##### TS Contributor
Maybe I am wrong....I had just 5 minutes to play around with some R code....
I was thinking about calculating the permuted distribution of the difference between the two samples' standard deviations.
The distribution will be centered about 0, and then you should gauge where your observed difference lies.

Example, with two samples draw from a normal distribution with differet mean AND with different standard deviations:
Code:
a <- rnorm(100, 10,5)
b <- rnorm(100,20,3)
pooledData <- c(a, b)
size.sample1 <- length(a)
size.sample2 <- length(b)
size.pooled <- size.sample1+size.sample2
nIter <- 1000
stDiff <- numeric(nIter+1)
stDiff <- sd(a)-sd(b)
for(i in 2:length(stDiff)){
index <- sample(1:size.pooled, size=size.sample1, replace=F)
sample1.perm <- pooledData[index]
sample2.perm <- pooledData[-index]
stDiff[i] <- sd(sample1.perm) - sd(sample2.perm)
}
p.value <- round(mean(abs(stDiff) >= abs(stDiff)), digits=4)
p.value
plot(density(stDiff))
abline(v=stDiff, lty=2, col="red")

#### hlsmith

##### Less is more. Stay pure. Stay poor.
rogojel, I may wonder what type of results you get when using n=13 in your bootstrap? Also, what does the empirical distributions of the two groups look like, can you post that as well?