• R语言
  • 请问4组数如何比较差异

x

2.06

1.08

1.94

1.32

0.75

0.18

0.72

0.22

0.34

y

1.71

2.73

2.29

1.71

2.40

0.45

0.58

0.35

0.63

z

2.47

1.75

2.44

2.50

4.17

2.09

1.77

1.77

b

0.00

0.00

0.01

0.01

0.01

0.20

0.30

0.10

请问我有4组数,要比较它们之间有显著差异的数,用什么方法可以做

1,u need to know whether your 4 groups are paired or unpaired

2,if they are unpaired u can use Kruskal-Wallis-test

3,if they are paired u can use Friedman-test

these are nonparametric tests, all of them u can find in R

回复 第2楼 的 SPSS17: 谢谢 They are unpaired.

但是我做了之后还是有点问题

kruskal.test只能给出:

Kruskal-Wallis chi-squared = 22.5146, df = 3, p-value = 5.097e-05

我想得到的是这几组数里面有显著差异的值,这个有办法么

回复 第3楼 的 camelbbs:as your data are unpaired, u have used KW-test, and p-value is p-value = 5.097e-05 so that means in 4 groups at least there are two groups are significantly different.so "p-value = 5.097e-05" is just 有显著差异的值

回复 第4楼 的 SPSS17:

thanks a lot!!

But can I get which two groups are significantly different.

for sure u can do it with Wilcoxon-Rank-Sum-test for 2 unpaired groups, Wilcoxon-Signed-Rank-test for 2 paired groups, both can be found in R

4 天 后

回复 第1楼 的 camelbbs:用pair.wilcox.test 或者TukeyHSD(不知道拼错没,大概就是这个)都可以进行多重比较。还有pair.t.test估计这些是你想要的组之间的两两比较。

新手,学习中~~

#比较一下4组数据之间是否有显著差异

x=c(2.06,1.08,1.94,1.32,0.75,0.18,0.72,0.22,0.34)

y=c(1.71,2.73,2.29,1.71,2.40,0.45,0.58,0.35,0.63)

z=c(2.47,1.75,2.44,2.50,4.17,2.09,1.77,1.77)

b=c(0.00,0.00,0.01,0.01,0.01,0.20,0.30,0.10)

#各组数据之间不配对的比较方法

kruskal.test(list(x, y, z, b))

#各组数据之间配对的比较方法

friedman.test(as.matrix(cbind(x,y,z,b)))

#找出个组数据间差异的大小

#t检验 两总体方差未知但相同,用以两平均数之间差异显著性的检验。

#适用条件

#(1) 已知一个总体均数;

#(2) 可得到一个样本均数及该样本标准差;

#(3) 样本来自正态或近似正态总体。

#pairwise.t.test这里不适用(不服从正态分布、方差不同)

l=list(x=x,y=y,z=z,b=b)

#方差不同

lapply(l,sd)

#不服从正态分布

qqnorm(c(x,y,z,b));shapiro.test(c(x,y,z,b));

#用法

pairwise.t.test(c(x,y,z,b),c(rep(1:2,each=9),rep(3:4,each=8)))

#The Wilcoxon signed-rank test is a non-parametric statistical hypothesis test

#used when comparing two related samples, matched samples, or repeated

#measurements on a single sample to assess whether their population mean ranks

#differ (i.e. it is a paired difference test). It can be used as an

#alternative to the paired Student's t-test, t-test for matched pairs,

#or the t-test for dependent samples when the population cannot be assumed

#to be normally distributed.

pairwise.wilcox.test(c(x,y,z,b),c(rep(1:2,each=9),rep(3:4,each=8)))

Pairwise comparisons using Wilcoxon rank sum test

data: c(x, y, z, b) and c(rep(1:2, each = 9), rep(3:4, each = 8))

1 2 3

2 0.2891 - -

3 0.0135 0.0965 -

4 0.0068 0.0036 0.0045

P value adjustment method: holm

#结论:第4组和其他三组都有显著差异,第3组和第1组有显著差异

另:

上面SPSS17 的回复"....and p-value is p-value = 5.097e-05 so that means in 4 groups at least there are two groups are significantly different."为什么从p-value的取值就可以判断出至少有两组有显著区别? 不理解阿~