Skip to contents

The Yeo-Johnson power transformation and its inverse, plus maximum-likelihood estimation of the transformation exponent lambda. Unlike box_cox(), it accepts zero and negative values.

Usage

yeo_johnson_lambda(x)

yeo_johnson(x, lambda)

yeo_johnson_inverse(x, lambda)

Arguments

x

numeric vector of observations.

lambda

the transformation exponent.

Value

yeo_johnson_lambda() returns the fitted exponent. yeo_johnson() and yeo_johnson_inverse() return the transformed vector.

Examples

d <- distribution("Normal", c(0, 2))
x <- dist_random(d, 100, seed = 11)
lambda <- yeo_johnson_lambda(x)
y <- yeo_johnson(x, lambda)
all.equal(yeo_johnson_inverse(y, lambda), x)
#> [1] TRUE