Learn R Programming

limma (version 3.28.14)

zscore: Z-score Equivalents

Description

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

Usage

zscore(q, distribution, ...) zscoreGamma(q, shape, rate = 1, scale = 1/rate) zscoreT(x, df, approx=FALSE) tZscore(x, df) zscoreHyper(q, m, n, k)

Arguments

q, x
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)
df
degrees of freedom (>0 for zscoreT or >=1 for tZscore)
approx
logical, if TRUE then a fast approximation is used to convert t-statistics into z-scores. If FALSE, z-scores will be exact.
m
as for qhyper
n
as for qhyper
k
as for qhyper

Value

Numeric vector giving equivalent deviates from the standard normal distribution. The exception is tZscore which gives deviates from the specified t-distribution.

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 <- zscoreT(x,df=df) then pnorm(z) equals pt(x,df=df).

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, zscoreT and zscoreHyper are specific functions for the gamma, t and hypergeometric distributions respectively.

tZscore is the inverse of zscoreT, and computes t-distribution equivalents for standard normal deviates.

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.

If approx=TRUE, then the approximation from Hill (1970) is used to convert t-statistics to z-scores directly without computing tail probabilities. Brophy (1987) showed this to be most accurate of a variety of possible closed-form transformations.

References

Hill, GW (1970). Algorithm 395: Student's t-distribution. Communications of the ACM 13, 617-620.

Brophy, AL (1987). Efficient estimation of probabilities in the t distribution. Behavior Research Methods 19, 462--466.

See Also

qnorm, pgamma, pt in the stats package.

Examples

Run this code
# First three are 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)

zscoreT(2, df=3)
tZscore(2, df=3)

Run the code above in your browser using DataLab