box.cox {car}R Documentation

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, start=0)

Arguments

x numeric vector to transform.
p power (0 = log); if p is a vector then a matrix of transformed values with columns labelled by powers will be returned.
start constant to be added to each value of x prior to transformation.

Details

Computes x' = (x^p - 1)/p for p != 0 and x' = 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.

Value

a vector or matrix 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.

Author(s)

John Fox jfox@mcmaster.ca

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

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(1:5, c(0,2))
##              0    2
## [1,] 0.0000000  0.0
## [2,] 0.6931472  1.5
## [3,] 1.0986123  4.0
## [4,] 1.3862944  7.5
## [5,] 1.6094379 12.0

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

[Package car version 1.1-0 Index]