box_cox {fabletools} | R Documentation |
Box Cox Transformation
Description
box_cox()
returns a transformation of the input variable using a Box-Cox
transformation. inv_box_cox()
reverses the transformation.
Usage
box_cox(x, lambda)
inv_box_cox(x, lambda)
Arguments
x |
a numeric vector. |
lambda |
a numeric value for the transformation parameter. |
Details
The Box-Cox transformation is given by
f_\lambda(x) =\frac{x^\lambda -
1}{\lambda}
if \lambda\ne0
. For \lambda=0
,
f_0(x)=\log(x)
.
Value
a transformed numeric vector of the same length as x.
Author(s)
Rob J Hyndman & Mitchell O'Hara-Wild
References
Box, G. E. P. and Cox, D. R. (1964) An analysis of transformations. JRSS B 26 211–246.
Examples
library(tsibble)
library(dplyr)
airmiles %>%
as_tsibble() %>%
mutate(box_cox = box_cox(value, lambda = 0.3))
[Package fabletools version 0.4.2 Index]