Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

BoxCoxTrans

Box-Cox and Exponential Transformations


Description

These classes can be used to estimate transformations and apply them to existing and future data

Usage

BoxCoxTrans(y, ...)

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

## S3 method for class 'BoxCoxTrans'
print(x, newdata, digits = 3, ...)

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

Arguments

y

a numeric vector of data to be transformed. For BoxCoxTrans, the data must be strictly positive.

...

for BoxCoxTrans: options to pass to boxcox. plotit should not be passed through. For predict.BoxCoxTrans, additional arguments are ignored.

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

newdata

a numeric vector of values to transform.

digits

minimal number of significant digits.

object

an object of class BoxCoxTrans or expoTrans.

Details

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.

Value

Both functions returns a list of class of either BoxCoxTrans or expoTrans with elements

lambda

estimated transformation value

fudge

value of fudge

n

number of data points used to estimate lambda

summary

the results of summary(y)

ratio

max(y)/min(y)

skewness

sample skewness statistic

BoxCoxTrans also returns:

fudge

value of fudge

The predict functions returns numeric vectors of transformed values

Author(s)

Max Author

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. Manly, B. L. (1976) Exponential data transformations. The Statistician, 25, 37 - 42.

See Also

Examples

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

manly <- expoTrans(ratio)
manly

caret

Classification and Regression Training

v6.0-86
GPL (>= 2)
Authors
Max Kuhn [aut, cre], Jed Wing [ctb], Steve Weston [ctb], Andre Williams [ctb], Chris Keefer [ctb], Allan Engelhardt [ctb], Tony Cooper [ctb], Zachary Mayer [ctb], Brenton Kenkel [ctb], R Core Team [ctb], Michael Benesty [ctb], Reynald Lescarbeau [ctb], Andrew Ziem [ctb], Luca Scrucca [ctb], Yuan Tang [ctb], Can Candan [ctb], Tyler Hunt [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.