Module: Computing seasonality

Executive summary

A large part of algorithms in the STOCK is based on functionalities, which can predict future development, or they “explain” the past one. For example, they can estimate how much of a product would have been sold if there was no stockout of the product.

First of all – so that the lost quantity is reliable – it is very important to establish the precise period of the stockout. Suppose, for example, that the product we deal with is beer and suppose further that the stockout happens during summer. Then, the lost quantity is going to be considerably greater than if the stockout happened in the middle of February.

To avoid the need to run all computational algorithms for every stockout analysis, we created a separate module to do these calculations – and other algorithms just use its results.

The calculation is based on the principle that tries to forecast seasonality of an item accurately (or as accurately as possible). If we do not have enough information about the item, seasonality is set for the whole product, category – or even the entire company’s portfolio. Everything – of course – can be set and adjusted.

The algorithm can identify even extreme seasons, such as Christmas, or extremely seasonal items such as Easter eggs.

The module is also able to identify (and suppress) the so-called false seasons: randomly high sales during a year.

Functional description

Seasonal algorithm inputs

The seasonal algorithm needs the following data (depending whether we deal with a product at a single warehouse or a product at all available warehouses):

  • A product at a warehouse
    • Time series of an item at a specific warehouse
    • Time series of a superordinate product (to the product at the specific warehouse)
    • Time series of an adjustable superordinate category (to the product at the warehouse)
    • Time series of all sales
  • Product
    • Time series of the product
    • Time series of an adjustable superordinate category (to the product)
    • Time series of all sales

Any of the input time series can be disabled and, of course, in the configuration, categories (that are used to determine seasonality) are selected.

Output of the algorithm

The outputs of the algorithm are seasonal indices of all products in stock. Seasonal indices, in turn, are arrays of the size 12, and for each month, it is determined how big were the sales in the given month compared to others. Seasonal index of a month, then, is the ratio of the given month to the average of all the months.

For a seasonal index S, therefore, it follows that:

  • S < 1 – the month was below average
  • S = 1 – the month was average
  • S > 1 – the month was above average

By definition, the sum of the seasonal indices must equal 12.

The seasonality algorithm’s course

To explain the algorithms involved in seasonality, their overview is shown in the following diagram:

../../../_images/NewSeasonality.png

Legend to the seasonal indices:

  • Sharp indices – unsmoothed seasonal indices without upper and lower limits.
  • Strong indices – smoothed seasonal indices without upper and lower limits.
  • Weak indices – smoothed seasonal indices with both the lower and upper limits.

The principle behind the seasonality algorithm

The algorithm runs through the input time series in the sequence specified above until the time series have enough data. The algorithm thus rises higher up the levels until it has enough data. Requirement for enough data in the time series are defined as follows:

  • The time series must have at least a specified number of months (now 14 months).
  • The time series must have sales in at least 5 months (i.e., months with number of units sold > 0).
  • The time series has less than 5 sales months, but one calendar month contains more than 85% of all sales.

After the level is selected, we proceed to determine the seasonal indices – these indices are determined solely on the basis of the time series of the selected level. There are two algorithms used to determine the indices: an algorithm detecting sharp seasons and the classical algorithm. Given that the sharp seasons are susceptible to smoothing (used in the classical algorithm), the time series is first presented to the algorithm detecting sharp seasons. If a sharp season is confirmed, indices of the sharp season algorithm are used – otherwise, the time series is submitted to the classical algorithm and its indices are applied. The algorithm of sharp season is set to strike only in certain seasons – typically for Easter and Christmas. Most of the time series is thus determined by the “classical algorithm”.

Algorithm for a sharp season

For this algorithm, the time series must first be adjusted – and it is done in the following steps:

  • If the history is longer than 3 years, it gets trimmed to 3 years.
  • It is smoothed with trend adjustment, so that weaker years are not penalized.

The time series adjusted in this way is then “overlaid over itself by years” and using an average, seasonal indices are determined. For example, then, the seasonal index for January is calculated as the average of all the Januaries in time series for all years.

Subsequently, a seasonality score is calculated for a time series and seasonal indices; the seasonality score is used in the further calculations. The seasonality score is a metric that indicates the extent to which the seasonal indices match the time series. For the metric, the following statement holds: the higher the metric, the more the seasonal indices correspond to the time series. STOCK normally uses the seasonality score as thresholds; for instance, an earlier seasonal algorithm used the following distribution of intervals to determine seasonality:

  • x < -1 – unseasonal
  • x >= -1 && x <0.8 – undefined seasonality
  • x >= 0.8 – seasonal

Exact procedure to measure the seasonality score

The input for computing the seasonality score are adjusted values of the time series and resulting seasonal indices for each calendar month. To describe the algorithm, we use the following notation:

  • G:sub: i – a set of values ​​for a given calendar month; G2, for instance, is a set of all the values of the time series from February.
  • AVGi – the seasonal index in the i-th calendar month; AVG is used to suggest the computation of seasonal indices as averages of the sets Gi.
  • STDi – a standard deviation of i-th calendar month calculated from the set Gi.

Each seasonal index I, an element of {1..12}, contributes to the seasonality score with its Addi – that, then, is computed as follows:

If the following condition applies, the contribution is computed as described below; otherwise, the contribution of the seasonal index is Addi = 0.

  • Gi is at least 2
  • At least one of the following conditions hold:
    • The number of seasonal indices AVGi equal to zero is less than or equal to 4
    • AVGi - STDi > 0

If the condition is met, the contribution of the seasonal index is then determined as follows:

  • If AVGi> = 1, then the seasonal index contribution is Addi = AVGi - STDi - 1
  • If AVGi < 1, then the seasonal index contribution is Addi = 1 - (AVGi + STDi)

The final seasonality score is equal to the sum of all the contributions of the seasonal indices limited by 5 from above. The seasonality score is thus calculated as:

I is an element of {1..12}

S = sumi(min(addi,5))

Using seasonal indices of a sharp season

The seasonal indices computed in the algorithm detecting sharp seasons are used, if one of the following conditions holds:

  1. Condition for Easter
  • The time series has at least 500 sales.
  • The time series must span at least two Easter seasons, i.e., sales are high in the actual Easter month, but in the subsequent month, the sales are weak.
  1. Standard condition

In the text for the standard condition, seasonal indices refer to the resulting array of size 12; the i-th index corresponds to the seasonal index of i-th calendar month.

  • The seasonality score (described above) is greater than the threshold (now set to 4.0).
  • At least one seasonal index is greater than the threshold (now set to 4.0).
  • At least 8 seasonal indices are smaller than the threshold (now set to 0.5).
  • The seasonal indices contain only “one hill”, i.e., all indices greater than the threshold (now set as 0.05) create a single contiguous block with no gap – or they create two contiguous blocks without gaps and one of them starts in January and the other ends in December. The second condition allows to have a hill between December and January.

The “Classical algorithm”

For this algorithm, the time series must first be adjusted – and it is done in the following steps:

  • If the history is longer than 3 years, it gets trimmed to 3 years.
  • Adjustment to trim very low values.
  • Smoothing with weighted moving average (0.25, 0.50, 0.25).
  • It is smoothed with trend adjustment, so that weaker years are not penalized.

The time series adjusted in this way is then “overlaid over itself by years” and using an average, seasonal indices are determined. For example, then, the seasonal index for January is calculated as the average of all the Januaries in time series for all years.

The seasonal indices described above are computed for all the time series, but not all time series might have finite seasonal indices. Specifically for nonseasonal series with random high sales, we encounter too high indices, that, in turn, have a bad effect on the operation of certain algorithms in Planning Wizard. Therefore, the time series is subjected to a test to confirm its seasonality. If the test is successful, the result of the whole algorithm are strong indices, otherwise they are weak indices.

  • Strong indices – raw indices just as they were computed, without any adjustments.
  • Weak indices – indices computed by the algorithms and adjusted so that they acquire only the defined limit values ​​(now set from 0.7 to 1.3). Seasonal effects on these indices is suppressed, but it cannot disappear completely. This, as a matter of fact, is an advantage especially for those time series, that are the limit cases, on the border of seasonality. Limitations of indices, on the other hand, helps with nonseasonal and sporadic time series.

Confirmation of seasonality in the classical algorithm

Again, let us repeat that the result of the seasonality algorithm is either a strong or weak index. Which indices are used is determined by the algorithm that confirms seasonality. This algorithm is standardly governed by the following rules:

  1. First, it selects all the peaks of “hills” in the seasonal indices higher than the defined threshold (now set to 2.0).
  2. For the seasonality to be confirmed, for each peak (of the hill), there must be at least two years with - seasonal index in the peak month was greater than the defined threshold (now set to 1.5). - sales in the peak month must be greater than one-fifth of the largest sales in a given month in one of the years: this ensures that a random small sale is not accepted as a season.

There is, however, one exception to confirm the seasonality for the months defined in the configuration. For the months set in the configuration, weaker seasonality confirmation rules apply. For example, a single confirmed season is taken as sufficient. This configuration is used to detect seasonality of Christmas more effectively .

Configuration

There are two important settings in the configuration.

The first is to determine the type of category that is subsequently applied in determining the seasonality by category. You can choose any product category, though, ideally as close as possible to the given product in the product tree – to ensure that the products of the same category have the same seasonal behavior. For example, in automotive business, we cannot choose a category ‘tires’, but only a subcategory, as only in the subcategory the division into summer and winter tires is found.

The second setting is to determine, which of the months are to be considered seasonal, despite the fact that algorithmically, the months do not show all the characteristics of seasonality. The default setting is December – Christmas, February and March – Easter. If we sell, say, toys and it turns out that some of the products have strong sales in December, it is not a coincidence: we have to accept it as a fact, although the sales of the very same product were very weak last year.