R语言z-score转p.valueR语言z-score转p.value

2021-09-07 16:42:05 浏览数 (1)

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).

0 人点赞