x1 <- c(0.80, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46) x2 <- c(1.15, 0.88, 0.90, 0.74, 1.21)
> ks.test(x1, x2) Two-sample Kolmogorov-Smirnov test data: x1 and x2 D = 0.6, p-value = 0.1658 alternative hypothesis: two-sided
> wilcox.test(x1, x2) Wilcoxon rank sum test data: x1 and x2 W = 35, p-value = 0.2544 alternative hypothesis: true location shift is not equal to 0
> x1 <- c(1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30) > x2 <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29) > wilcox.test(x1, x2, paired=T) Wilcoxon signed rank test data: x1 and x2 V = 40, p-value = 0.03906 alternative hypothesis: true location shift is not equal to 0
x1 <- c(0.80, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46) x2 <- c(1.15, 0.88, 0.90, 0.74, 1.21) mood.test(x1, x2)
> mood.test(x1, x2) Mood two-sample test of scale data: x1 and x2 Z = 1.3827, p-value = 0.1668 alternative hypothesis: two.sided蠏覓願 讌讌
> kruskal.test(weight ~ group, data=datasets::PlantGrowth) Kruskal-Wallis rank sum test data: weight by group Kruskal-Wallis chi-squared = 7.9882, df = 2, p-value = 0.01842
> library("pgirmess") > kruskalmc(weight ~ group, data=datasets::PlantGrowth) Multiple comparison test after Kruskal-Wallis p.value: 0.05 Comparisons obs.dif critical.dif difference ctrl-trt1 4.40 9.425108 FALSE ctrl-trt2 6.65 9.425108 FALSE trt1-trt2 11.05 9.425108 TRUE
> levels(warpbreaks$wool) [1] "A" "B" > levels(warpbreaks$tension) [1] "L" "M" "H" > kruskal.test(breaks ~ wool*tension, data=warpbreaks) Kruskal-Wallis rank sum test data: breaks by wool by tension Kruskal-Wallis chi-squared = 1.3261, df = 1, p-value = 0.2495
median.test<-function(y1,y2){ z<-c(y1,y2) g <- rep(1:2, c(length(y1),length(y2))) m<-median(z) fisher.test(z<m,g)$p.value } median.test(x1, x2)