bestNormalize (version 0.2.2)

orderNorm: Calculate and perform Ordered Quantile normalizing transformation

Description

The Ordered Quantile normalization transformation, orderNorm(), is a rank-based procedure by which the values of a vector are mapped to their percentile, which is then mapped to the same percentile of the normal distribution. Without the presence of ties, this essentially guarantees that the transformation leads to a uniform distribution.

The transformation is: $$g(x) = \Phi ^ {-1} (rank(x) / (length(x) + 1))$$

Where \(\Phi\) refers to the standard normal cdf, rank(x) refers to each observation's rank, and length(x) refers to the number of observations.

Using linear interpolation between these percentiles, the orderNorm becomes a 1-1 transformation. While it is possible to extrapolate beyond the observed values, a warning will occur. This is because outside of the observed domain of x, it is unclear how to extrapolate the transformation. A linear approximation lm(g(x) ~ x) is used to extrapolate beyond the original domain.

This transformation can be performed on new data and inverted via the predict function.

Usage

orderNorm(x)

# S3 method for orderNorm predict(object, newdata = NULL, inverse = FALSE, ...)

# S3 method for orderNorm print(x, ...)

Arguments

x

A vector to normalize

object

an object of class 'orderNorm'

newdata

a vector of data to be (reverse) transformed

inverse

if TRUE, performs reverse transformation

...

additional arguments

Value

A list of class orderNorm with elements

x.t

transformed original data

x

original data

n

number of nonmissing observations

warn_status

indicator if ties are present

fit

fit to be used for extrapolation, if needed

norm_stat

Pearson's P / degrees of freedom

The predict function returns the numeric value of the transformation performed on new data, and allows for the inverse transformation as well.

See Also

boxcox, lambert, bestNormalize, yeojohnson

Examples

Run this code
# NOT RUN {
x <- rgamma(100, 1, 1)

orderNorm_obj <- orderNorm(x)
orderNorm_obj
p <- predict(orderNorm_obj)
x2 <- predict(orderNorm_obj, newdata = p, inverse = TRUE)

all.equal(x2, x)

# }

Run the code above in your browser using DataLab