| ts_fil_gabor | R Documentation |
Smooth a time series with a one-dimensional Gabor kernel, which combines a Gaussian envelope with a cosine carrier to perform localized frequency-aware smoothing.
ts_fil_gabor(window_size = 3, central_frequency = 0.1)
window_size |
Positive numeric value. Standard deviation of the Gaussian envelope, in observations. Larger values use a wider local window. |
central_frequency |
Numeric value in |
The filter builds a symmetric kernel
g(t) = exp(-t^2 / (2 * window_size^2)) * cos(2 * pi * central_frequency * t)
over a finite window of radius 3 * window_size. The kernel is normalized
to preserve the local level when its sum is non-zero, then applied by
centered convolution with reflected boundary padding. The reflected padding
reduces edge artifacts without changing the output length.
This implementation is intended for offline smoothing. Because it uses a
centered window, values near time t depend on observations on both sides of
t. Use it before fitting a forecasting model, not as a causal real-time
filter.
A ts_fil_gabor object.
D. Gabor (1946). Theory of communication. Journal of the Institution of Electrical Engineers - Part III: Radio and Communication Engineering, 93, 429-457.
# Gabor smoothing on a noisy seasonal signal
library(daltoolbox)
library(tspredit)
x <- seq(0, 6 * pi, length.out = 120)
y <- sin(x) + 0.3 * sin(8 * x)
filter <- ts_fil_gabor(window_size = 3, central_frequency = 0.05)
filter <- daltoolbox::fit(filter, y)
yhat <- transform(filter, y)
plot_ts_pred(y = y, yadj = yhat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.