bc {resde}R Documentation

Box-Cox transformation

Description

These functions calculate the Box-Cox transformation, its inverse, and derivative.

Usage

bc(x, lambda)

bc_inv(y, lambda)

bc_prime(y, lambda)

Arguments

x, y

Numeric vector (x must be >= 0).

lambda

Numeric scalar, power parameter.

Details

bc() uses expm1(), wich is more accurate for small lambda than a more "obvious" alternative like

  if (abs(lambda) < 6e-9) log(y)
 else (y^lambda - 1) / lambda

The difference might be important in optimization applications. See example below. Similarly, bc_inv() uses log1p().

Value

bc(): Returns the transform value(s).

bc_inv(): Computes the inverse of bc().

bc_prime(): Gives the derivative of bc() with respect to y.

Functions

Examples

bc(0.5, 1.5)
bc(1, 0)
obvious <- function(lambda){(0.6^lambda - 1) / lambda} # at y = 0.6
plot(obvious, xlab="lambda", xlim=c(1e-6, 1e-9), log="x")

bc_inv(-0.4, 1.5)
bc_inv(0, 0)

bc_prime(0.5, 1.5)
bc_prime(1, 0)


[Package resde version 1.1 Index]