# Generate seasonal data
t <- seq(0, 20, length.out = 400)
X <- matrix(sin(2 * pi * t / 2) + 0.1 * rnorm(400), nrow = 1)
fd <- fdata(X, argvals = t)
# Default (SAZED) - most robust
result <- detect.period(fd)
print(result$period)
# Autoperiod with custom settings
result <- detect.period(fd, method = "autoperiod", n_candidates = 10)
# CFDAutoperiod for trended data
X_trend <- matrix(0.3 * t + sin(2 * pi * t / 2), nrow = 1)
fd_trend <- fdata(X_trend, argvals = t)
result <- detect.period(fd_trend, method = "cfd")
# Simple FFT for speed
result <- detect.period(fd, method = "fft")
Run the code above in your browser using DataLab