These classes can be used to estimate transformations and apply them to existing and future data
BoxCoxTrans(y, ...) # S3 method for default BoxCoxTrans(y, x = rep(1, length(y)), fudge = 0.2, numUnique = 3, na.rm = FALSE, ...) # S3 method for BoxCoxTrans print(x, newdata, digits = 3, ...) # S3 method for BoxCoxTrans predict(object, newdata, ...)
y | a numeric vector of data to be transformed. For |
---|---|
... | for |
x | an optional dependent variable to be used in a linear model. |
fudge | a tolerance value: lambda values within +/-fudge will be coerced to 0 and within 1+/-fudge will be coerced to 1. |
numUnique | how many unique values should |
na.rm | a logical value indicating whether |
newdata | a numeric vector of values to transform. |
digits | minimal number of significant digits. |
object | an object of class |
Both functions returns a list of class of either BoxCoxTrans
or expoTrans
with
elements
estimated transformation value
value of fudge
number of data points used to estimate lambda
the results of summary(y)
max(y)/min(y)
sample skewness statistic
value of fudge
BoxCoxTrans
function is basically a wrapper for the boxcox
function in the MASS library. It can be used to estimate the transformation and apply it to new data.
expoTrans
estimates the exponential transformation of Manly (1976) but assumes a common mean for
the data. The transformation parameter is estimated by directly maximizing the likelihood.
If any(y <= 0)
or if length(unique(y)) < numUnique
, lambda is not estimated and no
transformation is applied.
Box, G. E. P. and Cox, D. R. (1964) An analysis of transformations (with discussion). Journal of the Royal Statistical Society B, 26, 211-252. Manly, B. L. (1976) Exponential data transformations. The Statistician, 25, 37 - 42.
#> Box-Cox Transformation #> #> 208 data points used to estimate Lambda #> #> Input data summary: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.1165 0.6554 1.0204 1.2817 1.6989 5.1552 #> #> Largest/Smallest: 44.3 #> Sample Skewness: 1.46 #> #> Estimated Lambda: 0.2 #>#> [1] 1.2055119 -0.3844183 0.2249118 0.1419784 0.7398778ratio[5] <- NA bc2 <- BoxCoxTrans(ratio, bbbDescr$tpsa, na.rm = TRUE) bc2#> Box-Cox Transformation #> #> 207 data points used to estimate Lambda #> #> Input data summary: #> Min. 1st Qu. Median Mean 3rd Qu. Max. #> 0.1165 0.6538 1.0000 1.2783 1.6905 5.1552 #> #> Largest/Smallest: 44.3 #> Sample Skewness: 1.47 #> #> Estimated Lambda: 0.2 #>manly <- expoTrans(ratio) manly#> Exponential Transformation #> #> 207 data points used to estimate Lambda #> #> Input data summary: #> Min. 1st Qu. Median Mean 3rd Qu. Max. NA's #> 0.1165 0.6538 1.0000 1.2783 1.6905 5.1552 1 #> #> Largest/Smallest: 44.26 #> Sample Skewness: 1.467 #> #> Estimated Lambda: -0.5726 #>