我正在尝试在R和python的scipy.stats包中运行Wilcoxon测试。但是我可以得到不同的结果吗?
我的代码在R
> des2
[1] 6.2151308 4.7956451 4.7473738 5.4695828 6.3181463 2.8617239
[7] -0.8105824 3.9456856 4.6735000 4.1067193 5.7656002 2.2237666
[13] 1.0354143 4.9547707 5.3156348 4.8163154 3.4024776 4.2876854
[19] 6.1227500
> wilcox.test(des2, mu=0, conf.int = T)
Wilcoxon signed rank test
data: des2
V = 189, p-value = 7.629e-06
alternative hypothesis: true location is not equal to 0
95 percent confidence interval:
3.485570 5.160925
sample estimates:
(pseudo)median
4.504883
我在Python中的代码:
test = [6.2151308, 4.7956451, 4.7473738, 5.4695828, 6.3181463, 2.8617239, -0.8105824, 3.9456856, 4.6735000, 4.1067193, 5.7656002, 2.2237666, 1.0354143, 4.9547707, 5.3156348, 4.8163154, 3.4024776, 4.2876854, 6.1227500]
z_statistic, p_value = wilcoxon(np.array(test) - np.log(1.0))
print "one-sample wilcoxon-test", p_value
one-sample wilcoxon-test 0.000155095772796
即使它们的p值足够低以拒绝零假设,p值也有3个数量级的差异,我无法理解为什么