bctrans {alr3} | R Documentation |
Estimates multivariate power transformations to multinormality by a maximum likelihood-like method. The univariate case is obtained when only one variable is specified.
bctrans(formula, data = NULL, subset, na.action = na.omit, ...) ## Use when you have a matrix or data.frame: bctrans1(X, Y = NULL, start = NULL, family = "box.cox", call=NULL,...) ## S3 methods for class 'bctrans' lrt.bctrans(object, lrt=NULL, ones=TRUE, zeroes=TRUE)
formula |
A formula, giving the variables to be transformed.
The formula can be one-sided,
of the form |
data |
a data.frame (or list) from which the variables in the formula should be taken. |
subset |
an optional vector specifying a subset of observations to be used. |
na.action |
If set to na.omit, the default, missing values are permitted. If set to na.fail, missing values are not permitted. |
... |
In bctrans, these are additional arguments passed to |
X |
A vector, matrix, or data frame whose columns are to be transformed. |
Y |
If present this vector will be part of the object created, and will be used in drawing plots. It is not used for finding transformations. |
start |
Starting values for the power transformation parameters; if NULL (the default), univariate transformations will be computed and used as the start values. |
family |
The family of transformations. The most common is |
object |
In |
lrt |
In the |
ones |
In |
zeroes |
In |
call |
Not to be set by the user. |
Given a matrix X with columns X1, ..., Xp, this routine selects transformation parameters lambda1,...,lambdap from a one-parameter family of transformations such that the transformed variables psi(X1,lambda1),…,psi(Xp,lambdap) are as close to multivariate normal as possible.
The function uses the family of transformation you specify.
If you use the family box.cox
to select a transformation,
it is usual to use standard power transformations in further calculations.
bctrans
returns an object of class bctrans
,
which may be printed or summarized. It is a list with components X
containing
the input data, family
the family used, start
the starting values, and,
optim
, the
results from a call to optim
, the function optimizer used in the
routine.
A substantial part of this code is borrowed from the function
box.cox.powers
in the car
package, written by John Fox, and documented in
Fox (2002). It is based on a similar function in Arc; see Cook and Weisberg (1999).
It was modified by Sanford Weisberg, sandy@stat.umn.edu and renamed
bctrans
.
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. (2002). R and S-Plus Companion to Applied Regression. Sage.
Velilla, S. (1993). A note on the multivariate Box-Cox transformation to normality. Statistics and Probability Letters, 17, 259-263.
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.
powtran
,
optim
,
pairs
,
inv.res.plot
,
plot.bctrans
data(highway) b <- highway[,c(8,1,2,10,5)] # select interesting columns summary(ans <- bctrans1(b,family="yeo.johnson")) # zeros ==> use yeo.johnson # or, compute using a formula and get the same answer. summary(ans2 <- bctrans(~Len+ADT+Trks+Shld+Sigs,data=highway,family="yeo.johnson")) # or, first fit an lm, and extract the formula m1 <- lm(Rate~Len+ADT+Trks+Shld+Sigs,data=highway) summary(ans3 <- bctrans(m1,data=highway,family="yeo.johnson")) # work with the response b$Sigs <- (round(b$Sigs*b$Len)+1)/b$Len # redefine so no zeroes summary(ans <- bctrans1(b)) # fit with box.cox lrt.bctrans(ans,lrt=list(c(0,0,-1,1,0))) plot(ans,family="power") # plot, but use ordinary powers b <- cbind(b,powtran(ans)) # add transformed variables to data frame