Last chance! 50% off unlimited learning
Sale ends in
Perform a Box-Cox transformation and center/scale a vector to attempt normalization
boxcox(x, standardize = TRUE, ...)# S3 method for boxcox
predict(object, newdata = NULL, inverse = FALSE, ...)
# S3 method for boxcox
print(x, ...)
A list of class boxcox
with elements
transformed original data
original data
mean after transformation but prior to standardization
sd after transformation but prior to standardization
estimated lambda value for skew transformation
number of nonmissing observations
Pearson's P / degrees of freedom
was the transformation standardized
The predict
function returns the numeric value of the transformation
performed on new data, and allows for the inverse transformation as well.
A vector to normalize with Box-Cox
If TRUE, the transformed values are also centered and scaled, such that the transformation attempts a standard normal
Additional arguments that can be passed to the estimation of the lambda parameter (lower, upper, epsilon)
an object of class 'boxcox'
a vector of data to be (reverse) transformed
if TRUE, performs reverse transformation
boxcox
estimates the optimal value of lambda 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.
Box, G. E. P. and Cox, D. R. (1964) An analysis of transformations. Journal of the Royal Statistical Society B, 26, 211-252.
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