boxCox  R Documentation 
Computes and optionally plots profile loglikelihoods for the parameter of the
BoxCox power family, the YeoJohnson power family, or for either of the parameters in a bcnPower family. This is a slight generalization of the
boxcox
function in the MASS package that allows for families of
transformations other than the BoxCox power family. the boxCox2d
function
produces a contour
plot of the twodimensional likelihood profile for the bcnPower family.
boxCox(object, ...)
## Default S3 method:
boxCox(object,
lambda = seq(2, 2, 1/10), plotit = TRUE,
interp = plotit, eps = 1/50,
xlab=NULL, ylab=NULL, main= "Profile Loglikelihood",
family="bcPower",
param=c("lambda", "gamma"), gamma=NULL,
grid=TRUE, ...)
## S3 method for class 'formula'
boxCox(object, lambda = seq(2, 2, 1/10), plotit = TRUE, family = "bcPower",
param = c("lambda", "gamma"), gamma = NULL, grid = TRUE,
...)
## S3 method for class 'lm'
boxCox(object, lambda = seq(2, 2, 1/10), plotit = TRUE, ...)
boxCox2d(x, ksds = 4, levels = c(0.5, 0.95, 0.99, 0.999),
main = "bcnPower Loglikelihood", grid=TRUE, ...)
object 
a formula or fitted model object of class 
lambda 
vector of values of 
plotit 
logical which controls whether the result should be plotted; default 
interp 
logical which controls whether spline interpolation is used. Default to

eps 
Tolerance for lambda = 0; defaults to 0.02. 
xlab 
defaults to 
ylab 
defaults to 
family 
Defaults to 
param 
Relevant only to 
gamma 
For use when the 
grid 
If TRUE, the default, a lightgray background grid is put on the graph. 
... 
additional arguments passed to 
x 
An object created by a call to 
ksds 
Contour plotting of the loglikelihood surface will cover plus of minus 
levels 
Contours will be drawn at the values of levels. For example, 
main 
Title for the contour plot or the profile loglikelihood plot 
The boxCox
function is an elaboration of the boxcox
function in the
MASS package. The first 7 arguments are the same as in boxcox
, and if the argument family="bcPower"
is used, the result is essentially identical to the function in MASS. Two additional families are the yjPower
and bcnPower
families that allow a few values of the response to be nonpositive.
The bcnPower family has two parameters: a power \lambda
and a start or location parameter \gamma
, and the boxCox
function can be used to obtain a profile loglikelihood for either parameter with \lambda
as the default. Alternatively, the boxCox2d
function can be used to get a contour plot of the profile loglikelihood.
Both functions ae designed for their side effects of drawing a graph. The boxCox
function returns a list of the lambda (or possibly, gamma) vector and the computed profile loglikelihood vector,
invisibly if the result is plotted. If plotit=TRUE
plots loglikelihood vs
lambda and indicates a 95% confidence interval about the maximum observed value of
lambda. If interp=TRUE
, spline interpolation is used to give a smoother plot.
Sanford Weisberg, <sandy@umn.edu>
Box, G. E. P. and Cox, D. R. (1964) An analysis of transformations. Journal of the Royal Statisistical Society, Series B. 26 21146.
Cook, R. D. and Weisberg, S. (1999) Applied Regression Including Computing and Graphics. Wiley.
Fox, J. (2016) Applied Regression Analysis and Generalized Linear Models, Third Edition. Sage.
Fox, J. and Weisberg, S. (2019) An R Companion to Applied Regression, Third Edition, Sage.
Hawkins, D. and Weisberg, S. (2017) Combining the BoxCox Power and Generalized Log Transformations to Accomodate Nonpositive Responses In Linear and MixedEffects Linear Models South African Statistics Journal, 51, 317328.
Weisberg, S. (2014) Applied Linear Regression, Fourth Edition, Wiley.
Yeo, I. and Johnson, R. (2000) A new family of power transformations to improve normality or symmetry. Biometrika, 87, 954959.
boxcox
, yjPower
, bcPower
, bcnPower
,
powerTransform
, contour
with(trees, boxCox(Volume ~ log(Height) + log(Girth), data = trees,
lambda = seq(0.25, 0.25, length = 10)))
data("quine", package = "MASS")
with(quine, boxCox(Days ~ Eth*Sex*Age*Lrn,
lambda = seq(0.05, 0.45, len = 20), family="yjPower"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.