# BoxCox - Box-Cox Transform

Returns the Box-Cox transformation of the input data point(s).

## Syntax

BOXCOX(X, Alpha, Lambda, Return_type)

X the real number for which we compute the transformation.

Alpha is the input shift parameter for X. If omitted, the default value is 0.

Lambda is the input power parameter of the transformation, on a scale from 1 to 0. If omitted, the default value of 0 is assumed.

Return_type is a number that determines the type of return value: 1 (or missing)= Box-Cox , 2= Inverse Box-Cox, 3= LLF of Box-Cox.

RETURN_TYPE NUMBER RETURNED
1 or omitted Box-Cox Transform
2 Inverse of Box-Cox transform
3 LLF of Box-Cox transform

## Remarks

1. Box-Cox transform is perceived as a useful data (pre)processing technique used to stabilize variance and make the data more normally distributed.
2. The Box-Cox transformation is defined as follows:

$$T\left ( x_{t}; \lambda, \alpha \right ) = \begin{cases} \dfrac{\left ( x_{t} + \alpha \right )^{\lambda}-1}{\lambda} & \text{ if } \lambda \neq 0 \\ \log \left ( x_t + \alpha \right ) & \text{ if } \lambda= 0 \end{cases}$$

Where:
• $x_{t}$ is the value of the input time series at time $t$
• $\lambda$ is the input scalar value of the Box-Cox transformation
• $\alpha$ is the shift parameter
• $\left(x_t +\alpha \right) \gt 0$ for all t values.
3. The BOXCOX function accepts a single value or an array of values for X.
4. The shift parameter must be large enough to make all the values of X positive.
5. To compute the log-likelihood function (LLF), the BoxCox function assumes a Gaussian distribution which parameters ($\mu,\sigma^2$) are calculated using the maximum-likelihood estimate (MLE) method.

$$LLF_{\textrm{BoxCox}} = \frac{-N}{2}\times\left( \ln\left( 2\pi\hat{\sigma}^2\right)+1\right)$$

$$\hat{\sigma}^2=\frac{\sum_{t=1}^N{\left(y_t-\mu\right )^2}}{N}$$

Where:
• $\hat{\sigma}^2$ is the biased estimate of the variance.
• $N$ is the number of non-missing values in the sample data.
• $y_t$ is the t-th transformed observation.

## Examples

Example 1:

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
A B C D
Date Data
January 10, 2008 -0.30 0.89 -0.30
January 11, 2008 -1.28 0.20 -1.28
January 12, 2008 0.24 1.18 0.24
January 13, 2008 1.28 1.63 1.28
January 14, 2008 1.20 1.60 1.2
January 15, 2008 1.73 1.80 1.73
January 16, 2008 -2.18 -0.97 -2.18
January 17, 2008 -0.23 0.93 -0.23
January 18, 2008 1.10 1.56 1.1
January 19, 2008 -1.09 0.36 -1.09
January 20, 2008 -0.69 0.65 -0.69
January 21, 2008 -1.69 -0.20 -1.69
January 22, 2008 -1.85 -0.40 -1.85
January 23, 2008 -0.98 0.45 -0.98
January 24, 2008 -0.77 0.60 -0.77
January 25, 2008 -0.30 0.89 -0.3
January 26, 2008 -1.28 0.20 -1.28
January 27, 2008 0.24 1.18 0.24
January 28, 2008 1.28 1.63 1.28
January 29, 2008 1.20 1.60 1.2
January 30, 2008 1.73 1.80 1.2
January 31, 2008 -2.18 -0.97 -2.81
February 1, 2008 -0.23 0.93 -0.23
February 2, 2008 1.10 1.56 1.1
February 3, 2008 -1.09 0.36 -1.09
February 4, 2008 -0.69 0.65 -0.69
February 5, 2008 -1.69 -0.20 -1.69
February 6, 2008 -1.85 -0.40 -1.85
February 7, 2008 -0.98 0.45 -0.98

Formula Description (Result)
=BOXCOX($B$2:$B$30,3,0.5,3) LLF Boxcoc (-33.35)