yeoJohnson() applies the Yeo-Johnson transformation to a numeric
vector. yeoJohnsonInv() reverses the transformation.
Details
The Yeo-Johnson transformation extends the Box-Cox transformation to allow for zero and negative values. It is defined piecewise:
$$f_\lambda(x) = \frac{(x+1)^\lambda - 1}{\lambda}$$ for \(x \ge 0\) and \(\lambda \ne 0\),
$$f_\lambda(x) = \log(x+1)$$ for \(x \ge 0\) and \(\lambda = 0\),
$$f_\lambda(x) = -\frac{(-x+1)^{2-\lambda} - 1}{2-\lambda}$$ for \(x < 0\) and \(\lambda \ne 2\), and
$$f_\lambda(x) = -\log(-x+1)$$ for \(x < 0\) and \(\lambda = 2\).
The transformation is defined for all real-valued inputs and is continuous and differentiable for all \(x\). It is commonly used as an alternative to the Box-Cox transformation when the data include zero or negative values.
The transformation is strictly increasing and maps 0 to 0, so the sign of the transformed value identifies the branch to be inverted.
The inverse transformation recovers the original data (up to numerical
precision) when the same lambda and tol are used. For
\(\lambda < 0\) the image of the transformation is bounded above by
\(-1/\lambda\) (and correspondingly for \(\lambda > 2\) below); values
outside that range have no preimage and are reported as an error.
References
Yeo, I.-K. and Johnson, R. A. (2000). A new family of power transformations to improve normality or symmetry. Biometrika, 87(4), 954–959.
See also
Other transform:
boxCox(),
boxCoxLambda(),
logSt(),
scaleX()
