悬赏 20 个论坛币 未解决
请教大神:
在《R语言实战》中提到可用coin包中的oneway_test函数做置换检验,但怎么提取出里面的P值来?
library(coin)
score <- c(40, 57, 45, 55, 58, 57, 64, 55, 62, 65)
treatment <- factor(c(rep("A", 5), rep("B", 5)))
mydata <- data.frame(treatment, score)
t.test(score ~ treatment, data = mydata, var.equal = TRUE)
fit<-oneway_test(score ~ treatment, data = mydata, distribution = "exact")
fit
Exact Two-Sample Fisher-Pitman Permutation Test
data: score by treatment (A, B)
Z = -1.9147, p-value = 0.07143
alternative hypothesis: true mu is not equal to 0
另外,这里的Z值为-1.9147,但根据Z值来求P值的话:pnorm(-1.9147)*2=0.0555,与上面的P值也不同,但与下面的置换检验(参数 distribution取“asymptotic”)中P值相同,想问一下:为何两个不同的参数,得到同一个Z值,但得到不同的P值,谢谢!
> oneway_test(score ~ treatment, data = mydata, distribution = "asymptotic")
Asymptotic Two-Sample Fisher-Pitman Permutation Test
data: score by treatment (A, B)
Z = -1.9147, p-value = 0.05553
alternative hypothesis: true mu is not equal to 0