## Nonparametric tests for matched pairs and randomized block designs ############################# # sign test and Friedman test ############################# y1<-c(8.4,12.8,9.6,9.8,8.4,8.6,8.9,7.9) y2<-c(9.4,15.2,9.1,8.8,8.2,9.9,9.0,8.1) y<-cbind(y1,y2) help(friedman.test) > friedman.test(y) Friedman rank sum test data: y Friedman chi-squared = 0.5, df = 1, p-value = 0.4795 ########################### # Wilcoxon signed-rank test ########################### > help(wilcox.test) > wilcox.test(y1,y2,paired=T,correct=F) Wilcoxon signed rank test data: y1 and y2 V = 12.5, p-value = 0.4406 alternative hypothesis: true mu is not equal to 0 Warning message: Cannot compute exact p-value with ties in: wilcox.test.default(y1, y2, paired = T, correct = F) > y1-y2 [1] -1.0 -2.4 0.5 1.0 0.2 -1.3 -0.1 -0.2 > rank(abs(y1-y2)) [1] 5.5 8.0 4.0 5.5 3.0 7.0 1.0 2.0 # not sure why the two values of "0.2" get ranks of 2 and 3, instead of 2.5 # for both > wilcox.test(y1,y2,paired=T) Wilcoxon signed rank test with continuity correction data: y1 and y2 V = 12.5, p-value = 0.4833 alternative hypothesis: true mu is not equal to 0 Warning message: Cannot compute exact p-value with ties in: wilcox.test.default(y1, y2, paired = T) ## exact test y<-c(-4,2,7,6) > wilcox.test(y) Wilcoxon signed rank test data: y V = 8, p-value = 0.375 alternative hypothesis: true mu is not equal to 0 ## exact=T is the default > 3/16 [1] 0.1875 > (3/16)*2 [1] 0.375