| ts_norm_an | R Documentation |
Transform data to a common scale while adapting to changes in distribution over time (optionally over a trailing window).
ts_norm_an(
outliers = outliers_boxplot(),
nw = 0,
average = c("mean", "ema"),
operation = c("divide", "subtract", "softdivide", "asinh"),
scale = c("sd", "mad", "none"),
lambda = 1,
epsilon = 1e-08
)
outliers |
Indicate outliers transformation class. NULL can avoid outliers removal. |
nw |
integer: window size. |
average |
Character. Adaptive reference statistic: |
operation |
Character. Adaptive normalization operator:
|
scale |
Character. Local scale estimator used by the hybrid operators:
|
lambda |
Numeric. Weight assigned to the adaptive level term inside the hybrid reference scale. |
epsilon |
Numeric. Positive floor used to stabilize near-zero denominators and local scales. |
ts_norm_an() supports a family of adaptive window-wise transformations:
"divide" rescales a window by its adaptive reference level.
"subtract" recenters the window by subtracting the adaptive reference
level.
"softdivide" computes a stabilized relative deviation:
(x - \mu) / \sqrt{s^2 + (\lambda \mu)^2 + \epsilon^2}.
"asinh" applies an inverse-hyperbolic-sine contrast around the adaptive
reference level using the same stabilized scale.
The concrete operators are implemented in tsanutils(), while
ts_norm_an() focuses on estimating the adaptive references and applying
the chosen transformation consistently during fit, transform, and inverse
transform.
In the current contract, the adaptive reference is estimated from the full
supervised window passed to fit() or transform(). So when the input is a
sliding window produced by ts_data(), the terminal t0 position is part of
the same window-wise reference used for the transformation.
The adaptive reference \mu is estimated either by a simple mean or by an
exponentially weighted mean (average = "ema"). The hybrid operators
additionally use a local scale estimate s based on either the standard
deviation or the MAD.
A ts_norm_an object.
Ogasawara, E., Martinez, L. C., De Oliveira, D., Zimbrão, G., Pappa, G. L., Mattoso, M. (2010). Adaptive Normalization: A novel data normalization approach for non-stationary time series. Proceedings of the International Joint Conference on Neural Networks (IJCNN). doi:10.1109/IJCNN.2010.5596746
Huber PJ (1964). Robust Estimation of a Location Parameter. Annals of Mathematical Statistics, 35(1), 73-101. doi:10.1214/aoms/1177703732
Burbidge JB, Magee L, Robb AL (1988). Alternative Transformations to Handle Extreme Values of the Dependent Variable. Journal of the American Statistical Association, 83(401), 123-127.
Bellemare MF, Wichman CJ (2020). Elasticities and the Inverse Hyperbolic Sine Transformation. Oxford Bulletin of Economics and Statistics, 82(1), 50-61. doi:10.1111/obes.12325
# time series to normalize
library(daltoolbox)
library(tspredit)
data(tsd)
# convert to sliding windows
ts <- ts_data(tsd$y, 10)
ts_head(ts, 3)
summary(ts[,10])
# divisive adaptive normalization (default)
preproc <- ts_norm_an()
preproc <- daltoolbox::fit(preproc, ts)
tst <- transform(preproc, ts)
ts_head(tst, 3)
# subtractive adaptive normalization
preproc <- ts_norm_an(operation = "subtract")
preproc <- daltoolbox::fit(preproc, ts)
tst <- transform(preproc, ts)
ts_head(tst, 3)
# EMA-based soft division
preproc <- ts_norm_an(average = "ema", operation = "softdivide", scale = "mad")
preproc <- daltoolbox::fit(preproc, ts)
tst <- transform(preproc, ts)
ts_head(tst, 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.