box_cox | R Documentation |
Creates a specification for the Box Cox transformation.
box_cox(lambda = NA, lower = 0, upper = 1.5, multivariate = FALSE, ...)
lambda |
the power parameters. If NA then it will automatically
calculate the optimal parameter using the method of Guerrero (for univariate
case) else for the multivariate case, the method of Velilla (1993) which
is implemented in the |
lower |
optional parameter lower bound for cases when it is calculated. |
upper |
optional parameter upper bound for cases when it is calculated. |
multivariate |
flag for the multivariate case. If lambda is a single parameter, then that is applied to all series (including NA which results in the multivariate transformation described above). |
... |
not currently used. |
The function returns a list of 2 functions called “transform” and “inverse” which can be called with a data object and a frequency to calculate the transformed values. The auto_lambda function uses the method of Guerrero(1993).
A list with the transform and inverse functions.
The returned transform function will take additional argument “frequency” which determines whether a series is seasonal or not. When estimating lambda (when setting this to NA), a series with frequency > 1 will first be de-seasonalized using an STL decomposition.
Alexios Galanos for the BoxCox function.
John Fox for the
powerTransform function used in the multivariate case.
Box1964tsaux
\insertRefVelilla1993tsaux
\insertRefGuerrero1993tsaux
y = cumprod(c(1, 1 + rnorm(100,0.01, 0.005)))
B = box_cox(lambda = NA)
yt = B$transform(y, frequency = 1)
lambda = attr(yt,"lambda")
ye = B$inverse(yt, lambda)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.