Learn R Programming

caret (version 4.92)

BoxCoxTrans.default: Box-Cox Transformations

Description

This class can be used to estimate a Box-Cox transformation and apply it to existing and future data

Usage

BoxCoxTrans(y, ...)

## S3 method for class 'default': BoxCoxTrans(y, x = rep(1, length(y)), fudge = 0.2, numUnique = 3, na.rm = FALSE, ...)

## S3 method for class 'BoxCoxTrans': predict(object, newdata, ...)

Arguments

y
a strictly positive numeric vector of data to be transformed
x
an optional dependent variable to be used in a liner 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 y have to estimate the transformation?
na.rm
a logical value indicating whether NA values should be stripped from y and x before the computation proceeds.
...
for BoxCoxTrans: options ot pass to boxcox. plotit should not be passed through. For predict.BoxCoxTrans, additional arguments are ignored.
object
an object of class BoxCoxTrans
newdata
a numeric vector of values to transform

Value

  • BoxCoxTrans returns a list of class BoxCoxTrans with elements
  • lambdaestimated transformation value
  • fudgevalue of fudge
  • nnumber of data points used to estimate lambda
  • summarythe results of summary(y)
  • ratiomax(y)/min(y)
  • skewnesssample skewness statistic
  • predict.BoxCoxTrans returns a numeric vector of transformed values

Details

This 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.

If any(y <= 0)<="" code=""> or if length(unique(y)) < numUnique, lambda is not estimated and no transformation is applied.

References

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.

See Also

boxcox, preProcess

Examples

Run this code
data(BloodBrain)

ratio <- exp(logBBB)
bc <- BoxCoxTrans(ratio)

bc

predict(bc, ratio[1:5])


ratio[5] <- NA
bc2 <- BoxCoxTrans(ratio, bbbDescr$tpsa, na.rm = TRUE)
bc2

Run the code above in your browser using DataLab