R代码:
x <- c(9, 5, 9 ,10, 13, 8, 8, 13, 18, 30)
y <- c(10, 6, 9, 8, 11, 4, 1, 3, 3, 10)
library(exactRankTests)
wilcox.exact(y,x, paired = TRUE, alternative = "two.sided")
结果:V = 3,p值= 0.01562
SAS代码:
data aaa;
set aaa;
diff=x-y;
run;
proc univariate;
var diff;
run;
结果:S = 19.5 Pr> = | S | 0.0156
如何在R中获取统计数据?
如果n <= 20,则SAS和R中的确切P相同,但如果n> 20,则结果不同。
x <- c(9, 5, 9 ,10, 13, 8, 8, 13, 18, 30,9, 5, 9 ,10, 13, 8, 8, 13, 18, 30,9,11,12,10)
y <- c(10, 6, 9, 8, 11, 4, 1, 3, 3, 10,10, 6, 9, 8, 11, 4, 1, 3, 3, 10,10,12,11,12)
wilcox.exact(y,x,paired=TRUE, alternative = "two.sided",exact = FALSE)
结果:V = 34,p值= 0.002534
SAS结果:S = 92.5 Pr> = | S | 0.0009
如何在SAS和R中获得相同的统计S和P值?谢谢!