This function implements an anomaly detection method that uses the Fast Fourier Transform (FFT)
combined with an automatic frequency cutoff strategy based on the AMOC (At Most One Change)
algorithm. The model analyzes the power spectrum of the time series and detects the optimal
cutoff frequency — the point where the frequency content significantly changes — using
a changepoint detection method from the changepoint
package.
All frequencies below the cutoff are removed from the spectrum, and the inverse FFT reconstructs a filtered version of the original signal that preserves only high-frequency components. The resulting residual signal is then analyzed to identify anomalous patterns based on its distance from the expected behavior.
This function extends the HARBINGER framework and returns an object of class hanr_fft_amoc
.
Examples
library(daltoolbox)
#loading the example database
data(examples_anomalies)
#Using simple example
dataset <- examples_anomalies$simple
head(dataset)
#> serie event
#> 1 1.0000000 FALSE
#> 2 0.9689124 FALSE
#> 3 0.8775826 FALSE
#> 4 0.7316889 FALSE
#> 5 0.5403023 FALSE
#> 6 0.3153224 FALSE
# setting up time series fft detector
model <- hanr_fft_amoc()
# fitting the model
model <- fit(model, dataset$serie)
detection <- detect(model, dataset$serie)
# filtering detected events
print(detection[(detection$event),])
#> idx event type
#> 50 50 TRUE anomaly