z2p: Transforms Z-statistic into P-value

Description Usage Arguments Details Value References Examples

View source: R/z2p.R

Description

Takes Z-statistic(s) as input and outputs P-value(s). This function works for absolute Z-statistics up to x

Usage

1
z2p(Z, method = c("pnorm"))

Arguments

Z

Z-statistic, numeric vector.

method

"prnorm" (default), "Rmpfr::pnorm" (from the Rmpfr package)

Details

The usual P value calculation for |Z|-statistics < 38 is pnorm(abs(Z), lower.tail = FALSE) * 2 or, alternatively, exp(pnorm(abs(Z), log.p = TRUE, lower.tail = FALSE)) * 2. For anything that is larger, we can use the R package Rmpfr::pnorm that helps us with small digits.

Value

P P-value, same length as Z.

References

See also this post: https://stackoverflow.com/questions/46416027/how-to-compute-p-values-from-z-scores-in-r-when-the-z-score-is-large-pvalue-muc

Examples

1
2
3
4
5
z2p(c(-1.959964, 1.96))
z2p(20)
z2p(20, method = "Rmpfr::pnorm")
z2p(200, method = "pnorm") # the default
z2p(200, method = "Rmpfr::pnorm")

sinarueeger/GWAS.utils documentation built on July 30, 2019, 5:21 p.m.