# BoxCox - Box-Cox Transform

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

## Syntax

BOXCOX(X, Lo, Hi, $\lambda$, Return)

X
is the real value(s) for which we compute the transformation of a single value or a one-dimensional array of cells (e.g., rows or columns)).
Lo
is the x-domain lower limit. If missing, Lo is assumed to be 0.
Hi
is the x-domain upper limit. If missing, Hi is assumed to be infinity.
$\lambda$
is the input power parameter of the transformation ($\lambda\in[0,1)$). If omitted, the default value of 0 is assumed.
Return
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 Description
0 or omitted Box-Cox transform
1 The inverse of Box-Cox transform
2 Log-likelihood function of the transform

## Remarks

1. BOXCOX() transform function converts a one-bound domain (e.g., $x\in(a,\infty)$, $x\in(-\infty, b)$) into an unbounded $(-\infty,\infty)$ domain.
2. If both values of Lo and Hi arguments are given, the BOXCOX() returns #VALUE!.
3. Box-Cox transform is perceived as a useful data (pre)processing technique used to stabilize variance and make the data more normally distributed.
4. 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 input 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.
5. Using the negative values of \{x_t\}, we can use the Box-Cox transform for a domain with an upper bound.
$$F(x_t;\lambda,b)=\begin{matrix}\frac{(b-x)^\lambda-1}{\lambda}&\lambda\neq0\\\ln{(b-x_t)}&\lambda=0\\\end{matrix}$$
6. To calculate the inverse of the BoxCox transform:
• Domain with lower bound (a):
$$x=a+e^\frac{\ln{(\lambda y+1)}}{\lambda}$$
• Domain with upper bound (b):
$$x=b-e^\frac{\ln{(\lambda y+1)}}{\lambda}$$
7. To compute the log-likelihood function (LLF), the Box-Cox function assumes a Gaussian distribution in which parameters ($\mu,\sigma^2$) are calculated using the maximum-likelihood estimate (MLE) method.
$$LLF_{\textit{BoxCox}} = \frac{-N}{2}\times( \ln( 2\pi\hat{\sigma}^2)+1)$$ $$\hat{\sigma}^2=\frac{\sum_{t=1}^N{(y_t-\mu)^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 BOXCOX Inv-BOXCOX
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 BoxCox (-33.35)