ts_norm_an: Adaptive Normalization

View source: R/ts_norm_an.R

ts_norm_anR Documentation

Adaptive Normalization

Description

Transform data to a common scale while adapting to changes in distribution over time (optionally over a trailing window).

Usage

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
)

Arguments

outliers

Indicate outliers transformation class. NULL can avoid outliers removal.

nw

integer: window size.

average

Character. Adaptive reference statistic: "mean" or "ema".

operation

Character. Adaptive normalization operator: "divide", "subtract", "softdivide", or "asinh".

scale

Character. Local scale estimator used by the hybrid operators: "sd", "mad", or "none".

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.

Details

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.

Value

A ts_norm_an object.

References

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

Examples

# 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)

tspredit documentation built on Sept. 9, 2026, 9:08 a.m.