boxCox | R Documentation |
Functions for transforming and back-transforming data using the Box-Cox power transform, with options to preserve the measurement units.
boxCox(x, lambda = 1, GM, alpha = 0) IboxCox(x, lambda = 1, GM, alpha = 0)
x |
a numeric vector to be transformed by |
lambda |
the power term in the Box-Cox transformation. The value of 1 is a linear transform, the value of 0 results in a natural log transform. |
GM |
the value to use for the geometric mean of |
alpha |
an offset value for |
If x
contains missing values, then GM
is computed after
omitting the missing values and the output vector has a missing value
wherever x
has a missing value.
The function boxCox
computes the forward transform and the function
IboxCox
computes the inverse [boxCox] transform, or back-transform.
A numeric vector of the transformed or back-transformed values in
x
with an attribute "GM" of the geometric mean.
The original power transform described by Box and Cox (1964) is adjusted by a power transform of the geometric mean to retain the correct dimensional units of the original data as described in section 13.2 by Draper and Smith (1998).
Box, G.E.P., and Cox, D.R., 1964, An analysis of transformations:
Journal of the Royal Statistical Society, v. 26, Series B, p. 211–243.
Draper, N.R., and Smith, H., 1998, Applied regression analysis: New York,
John Wiley and Sons, 706 p.
hyperbolic
X.test <- c(1,4,9,16,25,36,49) boxCox(X.test) boxCox(X.test, lambda=0) IboxCox(boxCox(1:3, lambda=0), lambda=0) # verify the back-transform ## Should return # [1] 1 2 3 # attr(,"GM") # [1] 1.817121
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.