boxcoxR: Transform data using a boxcox transformation

Description Usage Arguments Details Note Author(s) References Examples

View source: R/boxcoxR.R

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

1
boxcoxR(x, minval = 0.01, lam = F, ...)

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.

lam

Should the lambda value be returned?

...

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.

Note

This function calls the boxcox function in the MASS package. To avoid loading the package, I have branched the function directly into the fifer package.

Author(s)

Dustin Fife fife.dustin@gmail.com.

References

Venables, W. N. & Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth Edition. Springer, New York. ISBN 0-387-95457-0

Examples

1
2
3
4
5
x = rnorm(100)^2
### use original boxcox function
boxcox(x~1, plot=FALSE) ## returns a vector of lambda values and their likelihoods
### use boxcoxR function
boxcoxR(x)

dustinfife/fifer documentation built on Oct. 31, 2020, 3:36 p.m.