I am having sales volume data for 100 stock-keeping units (SKUs). Is there a statistical way of identifying seasonal time series?
-
2$\begingroup$ Perhaps it's too obvious to mention but I'd always start with plotting data against time of year (for the usual meaning of seasonality), and time of month, time of week, time of day as suitable. Telling us about your time unit (sales are measured hourly, daily, weekly or what?) and about you want to do with your data would allow expanded answers. $\endgroup$– Nick CoxCommented Feb 7, 2018 at 10:26
2 Answers
Seasonality is a periodic signal in the data. The most basic tool for detecting periodic signals is to transform your data into the frequency domain using a Discrete Fourier Transform (DFT). In the frequency domain, periodic signals show up as frequency 'spikes' (usually with harmonics at multiples of that frequency), which are generally easy to see unless there is too much noise.
If you are looking to progress further to statistical modelling of the signal, you can add a seasonal component (a number of sine waves) to your time-series model and use your model-fitting to estimate the parameters of the signal (number of sine waves, amplitude, frequency, phase-shift). If you do this you will automatically have a non-seasonal model built in, which is the special case when the number of signals is zero. You can use this fact to do a hypothesis test to see whether there are signals in the data.
If you would like a specific example of a test for seasonal components in a time-series, you can have a look at the permutation-spectrum test in O'Neill (2020) and the accompanying function spectrum.text
in the ts.extend
package in R
. This test uses the maximum Fourier intensity as its test statistic and it tests this against its simulated null distribution computed by permuting the elements of the input time-series vector. The test can detect periodic signals in noise with reasonable power and it does not require any assumption for the distribution of the noise part of the input. The linked paper explains the test and shows how to implement it.
One possibility would be to fit both a nonseasonal and a seasonal exponential smoothing model to each SKU's time series. Note each model's AICc. SKUs where the seasonal model yields a lower AICc are "more seasonal".
The absolute difference in AICc measures the strength of the evidence (to a degree). As a rule of thumb, Burnham & Anderson suggest that a difference in AICc of about 2 constitutes weak evidence, a difference of 5 constitutes clear evidence and a difference of 10 constitutes strong evidence that the model with the lower AICc describes the data better.
Alternatively, use a holdout sample for each time series. Fit seasonal and nonseasonal models to the initial data, forecast into the holdout sample and check whether a seasonal or a nonseasonal model provides better forecasts. If you need a statistical test as to whether the forecast improvement is significant, you can use the diebold-mariano test.
Look at ets
in the forecast
package for R. While you are there, look at the seasonplot
command to visualize seasonality.