0
$\begingroup$

I'm a novice to time series and am using seasonal_decompose() to split a time series into three components: trend, seasonality, and residuals as below: enter image description here

As shown in the observed value at the top, most of the values are 0 except for some periods in year 2020 and 2021. However, the seasonal plot shows the same recurring pattern of seasonality across "all" years, not for periods where the observed values are non-zero.

I'm confused as to:

  1. why there is a seasonality in years 2016 - 2019 where observed values are 0
  2. why the seasonality has the same recurring pattern across all years.

Here is the reproducible data for your reference:

import pandas as pd
from statsmodels.tsa.seasonal import seasonal_decompose

bb_dict = {'YYYY-MM': {0: '2016-01',
  1: '2016-02',
  2: '2016-03',
  3: '2016-04',
  4: '2016-05',
  5: '2016-06',
  6: '2016-07',
  7: '2016-08',
  8: '2016-09',
  9: '2016-10',
  10: '2016-11',
  11: '2016-12',
  12: '2017-01',
  13: '2017-02',
  14: '2017-03',
  15: '2017-04',
  16: '2017-05',
  17: '2017-06',
  18: '2017-07',
  19: '2017-08',
  20: '2017-09',
  21: '2017-10',
  22: '2017-11',
  23: '2017-12',
  24: '2018-01',
  25: '2018-02',
  26: '2018-03',
  27: '2018-04',
  28: '2018-05',
  29: '2018-06',
  30: '2018-07',
  31: '2018-08',
  32: '2018-09',
  33: '2018-10',
  34: '2018-11',
  35: '2018-12',
  36: '2019-01',
  37: '2019-02',
  38: '2019-03',
  39: '2019-04',
  40: '2019-05',
  41: '2019-06',
  42: '2019-07',
  43: '2019-08',
  44: '2019-09',
  45: '2019-10',
  46: '2019-11',
  47: '2019-12',
  48: '2020-01',
  49: '2020-02',
  50: '2020-03',
  51: '2020-04',
  52: '2020-05',
  53: '2020-06',
  54: '2020-07',
  55: '2020-08',
  56: '2020-09',
  57: '2020-10',
  58: '2020-11',
  59: '2020-12',
  60: '2021-01',
  61: '2021-02',
  62: '2021-03',
  63: '2021-04',
  64: '2021-05',
  65: '2021-06',
  66: '2021-07',
  67: '2021-08',
  68: '2021-09',
  69: '2021-10',
  70: '2021-11',
  71: '2021-12'},
 'DE': {0: 0.0,
  1: 0.0,
  2: 0.0,
  3: 0.0,
  4: 0.0,
  5: 0.0,
  6: 0.0,
  7: 0.0,
  8: 0.0,
  9: 0.0,
  10: 0.0,
  11: 0.0,
  12: 0.0,
  13: 0.0,
  14: 0.0,
  15: 0.0,
  16: 0.0,
  17: 0.0,
  18: 0.0,
  19: 0.0,
  20: 0.0,
  21: 0.0,
  22: 0.0,
  23: 0.0,
  24: 0.0,
  25: 0.0,
  26: 0.0,
  27: 0.0,
  28: 0.0,
  29: 0.0,
  30: 0.0,
  31: 0.0,
  32: 0.0,
  33: 0.0,
  34: 0.0,
  35: 0.0,
  36: 0.0,
  37: 0.0,
  38: 0.0,
  39: 0.0,
  40: 0.0,
  41: 0.0,
  42: 0.0,
  43: 0.0,
  44: 0.0,
  45: 0.0,
  46: 0.0,
  47: 0.0,
  48: 0.0,
  49: 0.0,
  50: 0.0,
  51: 0.0,
  52: 0.0,
  53: 0.0,
  54: -10.31,
  55: -13.85,
  56: -1.79,
  57: 0.0,
  58: 0.0,
  59: 0.0,
  60: 0.0,
  61: 0.0,
  62: 0.0,
  63: 0.0,
  64: 0.0,
  65: -35.82,
  66: -35.52,
  67: -12.02,
  68: -15.44,
  69: -13.17,
  70: 0.0,
  71: 0.0}}


bb = pd.DataFrame.from_dict(bb_dict)
bb['YYYY-MM'] = pd.to_datetime(bb['YYYY-MM'], format='%Y-%m')
bb = bb.set_index('YYYY-MM')

result = seasonal_decompose(bb['DE'], model = 'additive')
result.plot();
$\endgroup$

1 Answer 1

1
$\begingroup$

I'm confused as to:

  1. why there is a seasonality in years 2016 - 2019 where observed values are 0
  2. why the seasonality has the same recurring pattern across all years.

Seasonal data is by definition recurring.
Say, you have for example visitors' data for an amusement park. You will have a baseline of visitors year round and then see a seasonal variation every year that there will be more visitors in summer than in autumn / winter.
Additionally, you might see a trend, that year after year your baseline of visitors increases and more people overall tend to visit the park.

Coming back to your data, your model is constrained by the definition that seasonal data has to repeat season by season. Judging from your plots, this doesn't make sense here because there is no seasonally repeating pattern in your data in the first 4 years and the last 2 are not enough to base any assumptions on, in my opinion.

$\endgroup$

Your Answer

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

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