3.5.2.3 boxcox
Description
This function takes a positive vector and transforms it into approximately normal distributed one by using Box-Cox power transformation method. The Box-Cox transform is formulated as following:
\[ Y'=\left\{ \begin{array}{ll} Y^\lambda&\lambda \neq 0\cr \ln(Y)&\lambda = 0 \end{array} \right. \]
Syntax
vector boxcox(vector vd[, double lambda, int options, int period])
Parameter
vd
- The input vector (column) to be transformed. vd must be positive dataset.
lambda
- Optional. If specify a number, perform the Box-Cox 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].
options
- Optinal. Specify the Box-Cox transformation method to use.
- options = 0 (Default): use method similar to SciPy’s boxcox function;
- options = 1: use the method in Statistical Process Control;
- options =2: use the method in Time Series Analysis.
period
- If options = 2, when Time Series Analysis method is used, specify period that determines the seasonal period of the original time series. period must be an integer not smaller than 2.
Return
Box-Cox power transformed vector (column).
Example
EX1
newbook; col(A) = data(0.1, 1.1, 0.002); col(B) = boxcox(col(A)); //output results similar to SciPy, with optimal lambda estimated by Origin col(C) = boxcox(col(A),0/0,1); //use SPC method; lambda CANNOT be omitted, default "0/0" means estimating optimal lambda