z-score计算方法为: Z =(x-μ)/ σ μ为均值,σ为标准差。
以下是R中将z-score转为p.value的方法:
pnorm(q, mean = 0, sd = 1, lower.tail = TRUE) q就是z-score;
代码语言:javascript复制zscore = 12.7
# Left-tailed test
pnorm(q=zscore, lower.tail=TRUE)
# Right-tail test
pnorm(q=zscore, lower.tail=FALSE)
# Two-tailed test
2*pnorm(q=zscore, lower.tail=FALSE)
个人最常用的是双边检验(two-tailed test).