bestNormalize (version 0.2.2)

boxcox: Box-Cox Normalization

Description

Perform a Box-Cox transformation and center/scale a vector to attempt normalization

Usage

boxcox(x, ...)

# S3 method for boxcox predict(object, newdata = NULL, inverse = FALSE, ...)

# S3 method for boxcox print(x, ...)

Arguments

x

A vector to normalize with Box-Cox

...

Additional arguments that can be passed to the estimation of the lambda parameter (lower, upper, epsilon)

object

an object of class 'boxcox'

newdata

a vector of data to be (reverse) transformed

inverse

if TRUE, performs reverse transformation

Value

A list of class boxcox with elements

x.t

transformed original data

x

original data

mean

mean of vector post-BC transformation

sd

sd of vector post-BC transformation

lambda

estimated lambda value for skew transformation

n

number of nonmissing observations

norm_stat

Pearson's P / degrees of freedom

The predict function returns the numeric value of the transformation performed on new data, and allows for the inverse transformation as well.

Details

boxcox estimates the optimal value of lamda for the Box-Cox transformation. This transformation can be performed on new data, and inverted, via the predict function.

The function will return an error if a user attempt to transform nonpositive data.

References

Box, G. E. P. and Cox, D. R. (1964) An analysis of transformations. Journal of the Royal Statistical Society B, 26, 211-252.

See Also

boxcox

Examples

Run this code
# NOT RUN {
x <- rgamma(100, 1, 1)

bc_obj <- boxcox(x)
bc_obj
p <- predict(bc_obj)
x2 <- predict(bc_obj, newdata = p, inverse = TRUE)

all.equal(x2, x)
# }

Run the code above in your browser using DataLab