box_cox {tsaux} | R Documentation |
Box-Cox transform specification
Description
Creates a specification for the Box Cox transformation.
Usage
box_cox(lambda = NA, lower = 0, upper = 1.5, multivariate = FALSE, ...)
Arguments
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. |
Details
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).
Value
A list with the transform and inverse functions.
Note
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.
Author(s)
Alexios Galanos for the BoxCox function.
John Fox for the
powerTransform function used in the multivariate case.
References
Box GE, Cox DR (1964).
“An analysis of transformations.”
Journal of the Royal Statistical Society Series B: Statistical Methodology, 26(2), 211–243.
Velilla S (1993).
“A note on the multivariate Box–Cox transformation to normality.”
Statistics & Probability Letters, 17(4), 259–263.
Guerrero VM (1993).
“Time-series analysis supported by power transformations.”
Journal of forecasting, 12(1), 37–48.
Examples
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)