| yeo.johnson | R Documentation |
Computes the Yeo-Johnson transformation, which is a normalizing transformation. The code and
documentation is taken from the VGAM package
(see function yeo.johnson) with some slight modifications, e.g. NA's are kept and
do not produce an error.
yeo.johnson( y, lambda, derivative = 0, epsilon = sqrt(.Machine$double.eps), inverse = FALSE )
y |
numeric: a vector or matrix. |
lambda |
numeric: It is recycled to the same length as |
derivative |
non-negative integer: the default is the ordinary function evaluation,
otherwise the derivative with respect to |
epsilon |
numeric and positive value: the tolerance given to values of |
inverse |
logical: return the inverse transformation? (default: |
The Yeo-Johnson transformation can be thought of as an extension of the Box-Cox transformation. It handles both positive and negative values, whereas the Box-Cox transformation only handles positive values. Both can be used to transform the data so as to improve normality.
The Yeo-Johnson transformation or its inverse, or its derivatives with respect to
lambda, of y.
If inverse = TRUE then the argument derivative = 0 is required.
Yeo, I.-K. and Johnson, R. A. (2000). A new family of power transformations to improve normality or symmetry. Biometrika, 87, 954–959.
VGAM::yeo.johnson, boxcox.
y <- seq(-4, 4, len = (nn <- 200))
ltry <- c(0, 0.5, 1, 1.5, 2) # Try these values of lambda
lltry <- length(ltry)
psi <- matrix(as.numeric(NA), nn, lltry)
for (ii in 1:lltry)
psi[, ii] <- yeo.johnson(y, lambda = ltry[ii])
matplot(y, psi, type = "l", ylim = c(-4, 4), lwd = 2, lty = 1:lltry,
ylab = "Yeo-Johnson transformation", col = 1:lltry, las = 1,
main = "Yeo-Johnson transformation with some values of lambda")
abline(v = 0, h = 0)
legend(x = 1, y = -0.5, lty = 1:lltry, legend = as.character(ltry),
lwd = 2, col = 1:lltry)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.