R语言 非参数检验:Mann-Whitney检验和Wilcoxon检验

参数检验非参数检验
分布特征正态分布非正态分布或未知分布
独立样本独立t检验Mann-Whitney检验
成对样本配对t检验Wilcoxon秩和检验paired

两独立样本t检验的假设条件是样本分布需要符合正态性。

但是,当样本分布非正态,且经过一定的数值转换尝试后,仍然无法满足正态性要求时,两独立样本的Wilcoxon秩和检验成为备选方法,它将两独立样本组的非正态样本值进行比较。它是一种非参数样本检验,基于样本的秩次排列,而非平均值。

注意,当数据呈非正态分布时,选择Wilcoxon检验。可以使用Shapiro-Wilk test进行检查。

非正态分布的独立样本
data <- read.csv(file = file.choose(),header = TRUE)
attach(data)
head(data)
tail(data)
wilcox.test(scores~methods,paired=FALSE)##Mann-Whitney U Test
> head(data)
  scores methods
1     70       A
2     61       A
3     63       A
4     77       A
5     51       A
6     70       A
> tail(data)
   scores methods
45     87       B
46     88       B
47     79       B
48     96       B
49     70       B
50     89       B
> wilcox.test(scores~methods,paired=FALSE)##Mann-Whitney U Test

	Wilcoxon rank sum test with
	continuity correction

data:  scores by methods
W = 39.5, p-value = 1.149e-07
alternative hypothesis: true location shift is not equal to 0

可得出结论:两个班级的平均成绩有显著差异 (W = 39.5, df = 48, p<0.001)

非正态分布的成对样本
data <- read.csv(file = file.choose(),header = TRUE)
attach(data)
head(data)
tail(data)
wilcox.test(test1,test2,paired=TRUE)  ## Wilcoxon Test
> head(data)
  test1 test2
1    81    87
2    63    67
3    75    77
4    67    80
5    64    70
6    65    68
> tail(data)
   test1 test2
21    66    68
22    74    89
23    77    89
24    76    88
25    67    76
26    75    89
> wilcox.test(test1,test2,paired=TRUE)  ## Wilcoxon Test

	Wilcoxon signed rank test with
	continuity correction

data:  test1 and test2
V = 12.5, p-value = 0.0001412
alternative hypothesis: true location shift is not equal to 0

可得出结论:两个班级的平均成绩有显著差异 (V = 12.5, df = 25, p<0.001)

  • 1
    点赞
  • 49
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Cachel wood

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值