Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

zscore

Transform non-normal random deviates to standard normal


Description

Compute z-score equivalents of non-normal random deviates.

Usage

zscore(q, distribution, ...)
zscoreGamma(q, shape, rate = 1, scale = 1/rate) 
zscoreHyper(q, m, n, k)

Arguments

q

numeric vector or matrix giving deviates of a random variable

distribution

character name of probabability distribution for which a cumulative distribution function exists

...

other arguments specify distributional parameters and are passed to the cumulative distribution function

shape

gamma shape parameter (>0)

rate

gamma rate parameter (>0)

scale

gamma scale parameter (>0)

m

as for qhyper

n

as for qhyper

k

as for qhyper

Details

These functions compute the standard normal deviates which have the same quantiles as the given values in the specified distribution. For example, if z <- zscoreGamma(x, shape, rate) then pnorm(z) equals pgamma(x, shape, rate).

zscore works for any distribution for which a cumulative distribution function (like pnorm) exists in R. The argument distribution is the name of the cumulative distribution function with the "p" removed.

zscoreGamma and zscoreHyper are specific functions for the gamma and hypergeometric distributions respectively.

The transformation to z-scores is done by converting to log tail probabilities, and then using qnorm. For numerical accuracy, the left or right tail is used, depending on which is likely to be smaller.

Value

Numeric vector or matrix of equivalent deviates from the standard normal distribution.

Author(s)

Gordon Smyth

See Also

zscoreNBinom in the edgeR package.

qnorm in the stats package.

Examples

# These are all equivalent
zscore(c(1,2.5), dist="gamma", shape=0.5, scale=2)
zscore(c(1,2.5), dist="chisq", df=1)
zscoreGamma(c(1,2.5), shape=0.5, scale=2)

limma

Linear Models for Microarray Data

v3.46.0
GPL (>=2)
Authors
Gordon Smyth [cre,aut], Yifang Hu [ctb], Matthew Ritchie [ctb], Jeremy Silver [ctb], James Wettenhall [ctb], Davis McCarthy [ctb], Di Wu [ctb], Wei Shi [ctb], Belinda Phipson [ctb], Aaron Lun [ctb], Natalie Thorne [ctb], Alicia Oshlack [ctb], Carolyn de Graaf [ctb], Yunshun Chen [ctb], Mette Langaas [ctb], Egil Ferkingstad [ctb], Marcus Davy [ctb], Francois Pepin [ctb], Dongseok Choi [ctb]
Initial release
2020-10-19

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.