ts_fil_fft: FFT Filter

View source: R/ts_fil_fft.R

ts_fil_fftR Documentation

FFT Filter

Description

Frequency-domain low-pass smoothing using the Fast Fourier Transform (FFT), reflected boundary padding, and a smooth cosine roll-off.

Usage

ts_fil_fft(threshold = 0.9, pad_pct = 0.25, taper_pct = 0.15)

Arguments

threshold

Cumulative non-constant spectral energy threshold to retain. Larger values keep more frequency components.

pad_pct

Fraction of the series length used for reflected boundary padding.

taper_pct

Width of the cosine transition band relative to the cutoff index.

Details

The implementation ignores the constant component when selecting the cutoff. This prevents a large mean level from dominating the energy criterion and collapsing the output into an almost flat series. It keeps the lowest frequencies that explain the requested share of non-constant spectral energy, applies a cosine roll-off after the cutoff to reduce ringing, and reconstructs the original-length series after removing the reflected boundary padding.

Value

A ts_fil_fft object.

References

  • J. W. Cooley and J. W. Tukey (1965). An algorithm for the machine calculation of complex Fourier series. Math. Comput.

Examples

# Frequency-domain smoothing via FFT low-pass reconstruction
# Load package and example data
library(daltoolbox)
library(tspredit)
x <- seq(0, 4 * pi, length.out = 128)
y <- sin(x) + 0.25 * sin(12 * x)

# Fit FFT-based filter and reconstruct the low-frequency signal
filter <- ts_fil_fft()
filter <- daltoolbox::fit(filter, y)
yhat <- transform(filter, y)

# Compare original vs frequency-smoothed series
plot_ts_pred(y = y, yadj = yhat)

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