# What type of model can be used to detect changes in periodic behavior?

Imagine we have a data sequence centered around 0 with small fluctuations +/- 1, but approximately every 100 observations it jumps to 10.

If this behavior changed and it started jumping to 5 every 50 observations, what type of model could be used to detect this as early as possible?

If you know the original periodicity of the pulses, a simple approach would be to use any seasonal time series forecasting algorithm with this seasonal frequency. Fit the model to your data, holding out the last (say) 10 observations. Forecast, and calculate prediction intervals to a specified level for the holdout data. Compare the holdout to the prediction intervals. If "enough" observations fall outside the PIs, raise a flag on the series.

You would need to calibrate this a little, especially with respect to the PI level (80%, 95%, 99%, whatever) and the number of holdout data points. If the original frequency varies, you may want to cut off the older observations.

Here is a simulated example with 80% and 95% prediction intervals in dark and light gray, calculated with a simple canned seasonal decomposition method. Any observation falling outside these bands would be an indication that your process has changed. A single such observation may be enough to investigate, or only a number of them in a row.

R code:

set.seed(1)
series <- ts(round(rnorm(1000)),frequency=100)
index <- abs((seq_along(series)%%100)-20)<=4
series[index] <- round(rnorm(sum(index),10,2))
library(forecast)
model <- stlf(series)
plot(forecast(model,h=200),las=1)