Skip to contents

This function calculates p-values from given z-scores using a two-tailed normal distribution. It supports vector input to process multiple z-scores simultaneously.

Usage

z_to_pvalue(z)

Arguments

z

Numeric vector. The z-scores to be converted to p-values.

Value

A numeric vector of p-values corresponding to the input z-scores.

Details

The function uses the following formula to calculate p-values: p-value = 2 * Φ(-|z|) Where Φ is the cumulative distribution function of the standard normal distribution.

Note

This function assumes that the input z-scores are from a two-tailed test and are normally distributed. It calculates two-sided p-values. For extremely large absolute z-scores, the resulting p-values may be computed as zero due to floating-point limitations in R. This occurs when the absolute z-score > 37.

Examples

z <- c(2.5, -1.8, 3.2, 0.7)
pvalues <- z_to_pvalue(z)
print(pvalues)
#> [1] 0.012419331 0.071860638 0.001374276 0.483927304