z-score計算方法爲:
Z =(x-μ)/ σ
μ爲均值,σ爲標準差。
以下是R中將z-score轉爲p.value的方法:
pnorm(q, mean = 0, sd = 1, lower.tail = TRUE)
q就是z-score;
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).