boxCox

0th

Percentile

Box-Cox Transformations for Linear Models

Computes and optionally plots profile log-likelihoods for the parameter of the Box-Cox power transformation. This is a slight generalization of the boxcox function in the MASS package that allows for families of transformations other than the Box-Cox power family.

Keywords
regression
Usage
boxCox(object, ...)

## S3 method for class 'default':
boxCox(object, lambda = seq(-2, 2, 1/10), plotit = TRUE,
       interp = (plotit && (m < 100)), eps = 1/50, 
       xlab = expression(lambda),
       ylab = "log-Likelihood", family="bcPower", grid=TRUE, ...)

## S3 method for class 'formula':
boxCox(object, lambda = seq(-2, 2, 1/10), plotit = TRUE,
       interp = (plotit && (m < 100)), eps = 1/50, 
       xlab = expression(lambda),
       ylab = "log-Likelihood", family="bcPower", ...)

## S3 method for class 'lm':
boxCox(object, lambda = seq(-2, 2, 1/10), plotit = TRUE,
       interp = (plotit && (m < 100)), eps = 1/50, 
       xlab = expression(lambda),
       ylab = "log-Likelihood", family="bcPower", ...)
Arguments
object
a formula or fitted model object. Currently only lm and aov objects are handled.
lambda
vector of values of lambda, with default (-2, 2) in steps of 0.1, where the profile log-likelihood will be evaluated.
plotit
logical which controls whether the result should be plotted; default TRUE.
interp
logical which controls whether spline interpolation is used. Default to TRUE if plotting with lambda of length less than 100.
eps
Tolerance for lambda = 0; defaults to 0.02.
xlab
defaults to "lambda".
ylab
defaults to "log-Likelihood".
family
Defaults to "bcPower" for the Box-Cox power family of transformations. If set to "yjPower" the Yeo-Johnson family, which permits negative responses, is used.
grid
If TRUE, the default, a light-gray background grid is put on the graph.
...
additional parameters to be used in the model fitting.
Details

This routine is an elaboration of the boxcox function in the MASS package. All arguments except for family and grid are identical, and if the arguments family = "bcPower", grid=FALSE is set it gives an identical graph. If family = "yjPower" then the Yeo-Johnson power transformations, which allow nonpositive responses, will be used.

Value

  • A list of the lambda vector and the computed profile log-likelihood vector, invisibly if the result is plotted. If plotit=TRUE plots log-likelihood vs lambda and indicates a 95lambda. If interp=TRUE, spline interpolation is used to give a smoother plot.

References

Box, G. E. P. and Cox, D. R. (1964) An analysis of transformations. Journal of the Royal Statisistical Society, Series B. 26 211-46. Cook, R. D. and Weisberg, S. (1999) Applied Regression Including Computing and Graphics. Wiley. Fox, J. (2008) Applied Regression Analysis and Generalized Linear Models, Second Edition. Sage. Fox, J. and Weisberg, S. (2011) An R Companion to Applied Regression, Second Edition, Sage. Weisberg, S. (2005) Applied Linear Regression, Third Edition. Wiley. Yeo, I. and Johnson, R. (2000) A new family of power transformations to improve normality or symmetry. Biometrika, 87, 954-959.

See Also

boxcox, yjPower, bcPower, powerTransform

Aliases
  • boxCox
  • boxCox.lm
  • boxCox.default
  • boxCox.formula
Examples
boxCox(Volume ~ log(Height) + log(Girth), data = trees,
       lambda = seq(-0.25, 0.25, length = 10))

boxCox(Days ~ Eth*Sex*Age*Lrn, data = quine,
       lambda = seq(-0.05, 0.45, len = 20), family="yjPower")
Documentation reproduced from package car, version 2.0-11, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.