Skip to main content
100%

timeline - seasonality detection (II)

✓ Published0🌍 Public
KKcnarf
Last edited Dec 3, 2018
Created on Feb 19, 2016

This interactive D3.v3 visualization demonstrates how to detect seasonality in a time series using a correlogram, showing both the timeline and its autocorrelation coefficients. Users can drag data points to modify the timeline, adjust season length, seasonality magnitude, and trend via controls. The left panel displays the timeline with draggable dots, while the right panel shows correlation bars for lags 1-10. The example reads from a CSV file and uses d3.behavior.drag and d3.svg.axis to enable manipulation and rendering.

AI-generated description

<a href='http://bl.ocks.org/Kcnarf/8c462789ffbb04351a11'>This block</a> is an experimentation of how to detect if a timeline has a seasonality component, and how to detect the lenght of the season (if any).

Seasonality means that the time serie has a periodic component, repeating the same pattern on each period. For example, sales of a store may have a week-based seasonality: sales increase on saturday, while there is no sale at all on sunday.

Graphically speaking, detecting a seasonality is (quite) easy: just look for a repeating pattern. Note that it could be difficult if the pattern has a long period, or/and the order of magnitude of the seasonilaty is low (ie. lowest and highest values are not so far from the season's mean, but in this case there might be no seasonality at all ! ).

Computationnaly speaking, one can use the correlogram. This diagram represents all the coefficients of autocorrelation of the time serie (go to <a href='http://bl.ocks.org/Kcnarf/89e1e69c888e8241ed92'>this block</a> for detailed explanations of what is a coefficient of autocorrelation, and how to compute it). With the help of this diagram, one can identify season's lenght, if any.

Usages :

  • in the left graph, Drag & Drop points to update the timeline and create seasons of your choice (below the graph are some shortcuts)
  • decrease the order of magnitude of the seasonality component to see that when this order is small, then it becomes difficult to detect a season: coefficient of correlation for each lag are constantly high (see below comment for details);
  • similarily with the previous comment, increase the trend of the timeline to see that the higher is the trend, the more difficult it is to detect a season; each coefficient of correlation is high because their corresponding lagged time serie and the original time serie behave the same way (they have the same trend), and the seasonality component becomes less important;
  • go to this <a href='http://bl.ocks.org/Kcnarf/5118ba2eb78edfcf645e'>block</a> in order to understand that detrending the time serie before computing the correlogram is a must have because it nullifies the previous comment, allowing to detect very small seasonnality order of magnitude;

Notes:

  • another <a href='http://bl.ocks.org/Kcnarf/5118ba2eb78edfcf645e'>block</a> experiments detrending before computing the correlogram
  • another <a href='http://bl.ocks.org/Kcnarf/89e1e69c888e8241ed92'>block</a> experiments autocorrelation
  • another <a href='http://bl.ocks.org/Kcnarf/1e6da47724c39156adb3'>block</a> experiments time series correlation
  • another <a href='http://bl.ocks.org/Kcnarf/0a8fe1caa2ac025c8e86'>block</a> deals with the impact of seasonality when computing the trend of a timeline

Acknowledgments:

  • done with D3 v3.5.5
  • <a href='http://blockbuilder.org'>blockbuilder.org</a>
mit Licensed

Similar vizzes