R語言z-score轉p.value

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章