Learn R Programming

alr3 (version 1.1.12)

powtran: Power transformations

Description

powtran computes members of families of transformations indexed by one parameter, the Box-Cox power family, or the Yeo and Johnson (2000) family, or the basic power family, interpreting zero power as logarithmic. The family can be modified to have Jacobian one, or not, except for the basic power family.

Usage

powtran(U, lambda,family,modified)

## S3 method for class 'default':
powtran(U, lambda,family="box.cox",modified=TRUE)

## S3 method for class 'bctrans':
powtran(U, lambda=coef(U), family=U$family,modified=FALSE)

## S3 method for class 'matrix':
powtran(U, lambda, family="power",modified=FALSE)

## S3 method for class 'data.frame':
powtran(U, lambda, family="power",modified=FALSE)

Arguments

U
U can be a vector, a matrix, a data.frame, or an object of type bctrans. Missing values are permitted. U must be strictly positive unless family=yeo.johnson.
lambda
The transformation parameter, typically a value between -2 and 2. For U of type matrix, data.frame, or bctrans, lambda must be a vector with the same number of elements as U has columns. lambda has no default, except for objects for type bctrans
family
The transformation family to be used. See the details below.
modified
TRUE to divide by the Jacobian, as need to transform the response, FALSE for no division. The default is TRUE except for objects of type bctrans, where the default is FALSE.

Value

  • For U a vector, matrix or data.frame, returns an object of the same type as U of transformed values. For class bctrans, returns an object of the same class and shape as U$X.

Details

The Box-Cox family of scaled power transformations, family="box.cox", equals $(U^{\lambda}-1)/\lambda$ for $\lambda$ $\neq$ zero, and $\log(U)$ if $\lambda =0$. If family="yeo.johnson" then the Yeo-Johnson transformations are used. This is is Box-Cox transformation of $U+1$ for nonnegative values, and of $|U|+1$ with parameter $2-\lambda$ for $U$ negative. The basic power transformation is simply $U^{\lambda}$ if lambda not zero, and $\log(U)$ otherwise. If modified=TRUE, then the scaled transformations are divided by the Jacobian, which is a function of the geometric mean.

References

Weisberg, S. (2005). Applied Linear Regression, third edition. New York: Wiley, Chapter 7. Yeo, In-Kwon and Johnson, Richard (2000). A new family of power transformations to improve normality or symmetry. Biometrika, 87, 954-959.

See Also

inv.tran.plot, bctrans, inv.res.plot,tran.family.

Examples

Run this code
data(ufcwc)
attach(ufcwc)
powtran(Height,lambda=0)
inv.tran.plot(Dbh,Height, lam = c(-1, 0, 1), family="box.cox")
summary(ans <- bctrans1(cbind(Dbh,Height))) # bctrans1 is used for a matrix input
plot(ans)

Run the code above in your browser using DataLab