3.5.2.60 yeojohnson


Contents

Description

This function takes a vector and transforms it into approximately normal distributed one by using Yeo-Johnson power transformation method. Different from Box-Cox transformation, Yeo-Johnson transformation works for any data, positive, negative and zero.

The Yeo-Johnson transform is formulated as following:

\[ Y'=\left\{ \begin{array}{ll} \frac{(Y+1)^\lambda - 1}{\lambda} & ~~~~~~\lambda \neq 0,Y\ge0\cr \ln(Y+1) & ~~~~~~\lambda = 0,Y\ge0\cr -\frac{(-Y+1)^{2-\lambda}-1}{2-\lambda} & ~~~~~~\lambda \neq 2,Y < 0\cr -\ln(-Y+1) & ~~~~~~\lambda = 2,Y < 0 \end{array} \right. \]

See detaied algorithm on this page.

Syntax

vector yeojohnson (vector vd[, double lambda])

Parameter

vd

The input vector (column) to be transformed. vd can include positive, negative and zero numbers.

lambda

Optinal. Perform the Yeo-Johnson transformation with the specified lambda. Default lambda is not a number (NANUM, i.e. “0/0”). In this case, the function will estimate the optimal lambda that maximizes the log-likelihood function before transformation, and lambda will be restricted in the range of [-5, 5].

Return

Yeo-Johnsonn power transformed vector (column).

Example

EX1

newbook;
col(A) = data(0.1, 1.1, 0.002);
col(B) = yeojohnson(col(A));

See Also

boxcox, jtrans