# Signal that starts non-seasonal, becomes seasonal, then stops
t <- seq(0, 30, length.out = 600)
X <- ifelse(t < 10, rnorm(sum(t < 10), sd = 0.3),
ifelse(t < 20, sin(2 * pi * t[t >= 10 & t < 20] / 2),
rnorm(sum(t >= 20), sd = 0.3)))
X <- matrix(X, nrow = 1)
fd <- fdata(X, argvals = t)
# Detect changes
changes <- detect.seasonality.changes(fd, period = 2)
print(changes$change_points) # Should show onset ~10, cessation ~20
Run the code above in your browser using DataLab