# Box-Cox Transformation

Box-Cox transformation is a power transformation that involves logs and powers. It transforms data into normal distributions.

The Box-Cox transformation is defined as

$$ y_i^{(\lambda)} = \begin{cases} \lambda ^{-1} (y_i^\lambda - 1) & \quad \text{if } \lambda \neq 0\\ \log(y_i) & \quad \text{if } \lambda = 0. \end{cases} $$

By selecting a proper $\lambda$, we get a Guassian distributed data, with a variable mean. The transformation take $y$ to

$$ \rho(y^{(\lambda)}) =\frac{ \exp{\left( -(y^{(\lambda)} - \beta X)^{T} (y^{(\lambda)} - \beta X)/(2\sigma^2) \right) }}{(\sqrt{2\pi \sigma^2})^n} \prod_{i=1}^n \left\lvert \frac{d y_i^{(\lambda )}}{ dy_i } \right\rvert. $$

The term

$$ \prod_{i=1}^n \left\lvert \frac{d y_i^{(\lambda )}}{ dy_i } \right\rvert = \lvert J \rvert $$

is the Jacobian as we are establishing the relations between the pdf of the data before and after the transfomation.

To find the proper $\lambda$, we write down the likelihood and maximize it. The likelihood is determined by the Gaussian distribution

$$ L(\lambda, \beta, \sigma) = \rho(y^{(\lambda)}). $$

- Box GEP, Cox DR. An analysis of transformations. J R Stat Soc. 1964;26: 211–243. doi:10.1111/j.2517-6161.1964.tb00553.x
- Vélez JI, Correa JC, Marmolejo-Ramos F. A new approach to the Box–Cox transformation. Frontiers in Applied Mathematics and Statistics. 2015;1: 12. doi:10.3389/fams.2015.00012
- How to Use Power Transforms for Time Series Forecast Data with Python

`cards/statistics/box-cox`

Links to:LM (2021). 'Box-Cox Transformation', Datumorphism, 07 April. Available at: https://datumorphism.leima.is/cards/statistics/box-cox/.