Skip to contents

The Box-Cox power transformation and its inverse, plus maximum-likelihood estimation of the transformation exponent lambda.

Usage

box_cox_lambda(x)

box_cox(x, lambda)

box_cox_inverse(x, lambda)

Arguments

x

numeric vector of (positive) observations.

lambda

the transformation exponent.

Value

box_cox_lambda() returns the fitted exponent (searched over [-5, 5]). box_cox() and box_cox_inverse() return the transformed vector.

Examples

d <- distribution("LogNormal", c(3, 0.5))
x <- dist_random(d, 100, seed = 11)
lambda <- box_cox_lambda(x)
y <- box_cox(x, lambda)
all.equal(box_cox_inverse(y, lambda), x)
#> [1] TRUE