DF = data.frame( type=c( rep( 'Snoopy', 6 ), rep( 'Quick', 6 ), rep( 'Mrs. Good', 6 ) ), data=c( 0.5, 7.3, 1.1, 2.7, 5.5, 4.3, 2.5, 1.8, 3.6, 5.2, 1.2, 0.7, 3.3, 1.5, 0.4, 4.8, 2.2, 1.0 ) ) # The classical ANOVA test (from R in Action EPage 234) # fit = aov( data ~ type, data=DF ) print( sprintf("Classical ANOV ") ) print(summary(fit)) # # To study the main effects of brand we will apply a permuation test: # source('utils.R') F = compute_F( DF$type, DF$data ) set.seed(1234) B = 100 # the sumber of bootstraps to run all_Fs = rep( NA, B ) # the bootstrap values of the F for( bi in 1:B ){ all_Fs[bi] = compute_F( DF$type, sample(DF$data) ) } plot( density( all_Fs ), xlab="statistic", main="" ) grid() abline(v=F, col='red') alpha = sum( all_Fs >= F ) / B print( sprintf("main effects for type (B= %d): prob. type I error: %10.6f", B, alpha) )