1
$\begingroup$

Suppose you are trying to measure if the seasonality of a particular event stream is consistent i.e. the events in a time series happen more or less in pattern like fashion. How can you algorithmically measure and extract seasonality?

Currently, I am using autocorrelation to view the clearly seasonal (monthly) data events. I am struggling to figure out how to write an algorithm that could test whether or not something is seasonal by month. The picture below shows the results of the pacf function within the statsmodels.tsa.stattools library. From the graph it is clear, how can I use the array to determine seasonality? Is there a library that would be useful for this?

enter image description here

This question is similar, but did not get any great answers: https://stats.stackexchange.com/questions/225003/test-for-trend-and-seasonality-in-time-series

$\endgroup$
1
  • $\begingroup$ Stupid question: why don‘t you run a linear model with monthly dummies? This should help to identify monthly patterns. $\endgroup$
    – Peter
    Jan 4, 2020 at 13:14

2 Answers 2

0
$\begingroup$

You can try FBProphet for your timeseries analysis. You will be able to check the seasonality, stationarity on your data.

$\endgroup$
0
$\begingroup$

I would reccomend you to try this classical additive or multiplicative decomposition approach from professor Hyndmann ( link to the chapter of his book , where he talks about this specifically https://otexts.com/fpp2/classical-decomposition.html ) ; it is very easy to implement in python.

To summarise the approach (for additive):

  1. Take the Moving average of order Q to extract the trend from your data. trend = MA(Q)
  2. Do y-trend = detrended_y
  3. To estimate the seasonal component for each season, simply average the detrended values for that season. For example, with monthly data, the seasonal component for March is the average of all the detrended March values in the data. These seasonal component values are then adjusted to ensure that they add to zero. The seasonal component is obtained by stringing together these monthly values, and then replicating the sequence for each year of data. This gives the seasonal component.
  4. If you want, get the residual by doing y-trend-seaonsal_component=residual .

If you need some guidance performing the implementation please let me know and I'll post it as well.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.