Learn R Programming

car (version 0.8-4)

box.cox: Box-Cox Family of Transformations

Description

Compute the Box-Cox power transformation of a variable.

Usage

box.cox(x, p, start=0)

bc(x, p)

Arguments

x
numeric vector to transform.
p
power (0 = log).
start
constant to be added to each value of x prior to transformation.

Value

  • a vector of transformed values.

Warning

These functions do not compute the maximum-likelihood estimate for a Box-Cox normalizing transformation. See box.cox.powers for estimating unconditional univariate and multivariate Box-Cox transformations, and boxcox in the MASS package for estimating the Box-Cox transformation of the response in a linear model.

Details

Computes $x^{\prime }=(x^p-1)/p$ for $p \neq 0$ and $x^{\prime }=\log x$ for $p=0$. The values of x must all be positive; if not, a start should be added to each value to make all the values positive. The function will automatically compute the start and print a warning, if necessary. bc is just an abbreviation for box.cox.

References

Atkinson, A. C. (1985) Plots, Transformations, and Regression Oxford. Box, G. E. P. and Cox, D. R. (1964) An analysis of transformations. JRSS B 26 211--246. Fox, J. (1997) Applied Regression, Linear Models, and Related Methods. Sage.

See Also

boxcox, box.cox.var, box.cox.powers, box.cox.axis

Examples

Run this code
box.cox(1:10, 2)
## [1]  0.0  1.5  4.0  7.5 12.0 17.5 24.0 31.5 40.0 49.5
box.cox(-5:5, 2)
##  [1]  0.0  1.5  4.0  7.5 12.0 17.5 24.0 31.5 40.0 49.5 60.0
## Warning message: 
## start =  6 added to data prior to transformation in: box.cox(-5:5, 2)
options(digits=4)
box.cox(-5:5, 0, start=6)
##  [1] 0.0000 0.6931 1.0986 1.3863 1.6094 1.7918 1.9459 2.0794 2.1972
## [10] 2.3026 2.3979

Run the code above in your browser using DataLab