boxcoxR: Transform data using a boxcox transformation
Description
This function takes a variable as input, computes the
optimal lambda using a boxcox transformation, then
returnes a transformed version of the variable.
Usage
boxcoxR(x, minval = 0.01, ...)
Arguments
x
a numerical vector
minval
before a transformation is performed, the
variables must often be positive. This tells R what the
minimum value should be. Defaults to .01.
...
additional parameters to be used in the model
fitting.
Details
The MASS package has a function that computes the
optimal lambda value for a particular regression
equation. However, it currently (as of version 7.3-23)
returns a lambda vector rather than the boxcox
transformed variable. This function is a wrapper for
boxcox that actually returns a vector that
is a transformed version of the original variable.
References
Venables, W. N. & Ripley, B. D. (2002) Modern Applied
Statistics with S. Fourth Edition. Springer, New York.
ISBN 0-387-95457-0
x = rnorm(100)^2### use original boxcox functionboxcox(x~1, plot=FALSE) ## returns a vector of lambda values and their likelihoods### use boxcoxR functionboxcoxR(x)