############################################ #MATH 5301 Nonparametric Statistics # #Quade permutation test #Lotion Example y = matrix(c( 5, 4, 7, 10, 12, 1, 3, 1, 0, 2, 16, 12, 22, 22, 35, 5, 4, 3, 5, 4, 10, 9, 7, 13, 10, 19, 18, 28, 37, 58, 10, 7, 6, 8, 7), nrow = 7, byrow = TRUE, dimnames = list(Store = as.character(1:7), Brand = LETTERS[1:5])) quade.test(y) #Permutation Test quade.permutation=function(x,num.replicates){ n=nrow(x) p=ncol(x) F.obs=quade.test(x)$statistic F.vect=rep(0,num.replicates) temp = x for(i in 1:num.replicates){ for(j in 1:nrow(x)){ index=sample(p,p) temp[j,]=x[j,index] } F.vect[i]=quade.test(temp)$statistic } p.value=mean(F.obs<=F.vect) plot(density(F.vect)) return(p.value) } quade.permutation(y,100000) quade.test(y) x.index=seq(from=0,to=8,length=1000) y.index=df(x.index,df1=4,df2=24) lines(x.index,y.index,col="red")