Forecasting: residuals from seasonal decomposition appears to be highly auto-corelated, why?

I am using a publicly available data Kaggle: Rossmann Store Sales and trying to forecast sales. I am using Python.

My timeseries is stationary, confirmed via the Dickey-Fuller test. However, I wanted to perform seasonal decomposition.

I performed seasonal decompositions using statsmodels.tsa.seasonal.seasonal_decompose. And my seasonal decomposition looks like this:

When I plot ACF of residuals there appears to be too much autocorelation!

Am I doing something wrong? or looking at it the wrong way? My understanding is residuals should show no autocorelation because trend and seasonal have been taken out or adjusted for.

Update 1: Using freq=13 I perform seasonal decomposition and ACF of residuals is given below:

Update 2: As requested by @IrishStat, I am posting the original data

Date
2013-01-01       0
2013-01-02    5737
2013-01-03    5292
2013-01-04    5623
2013-01-05    5018
2013-01-06       0
2013-01-07    9277
2013-01-08    7479
2013-01-09    6681
2013-01-10    6680
Name: Sales, dtype: int64

This is the plot of original data:

• It looks like you've taken a period of ~26 but it seems to be the half : ~13. Try with that and show your results. Jul 11, 2016 at 7:22
• @el Josso, are you refering to parameter freq in seasonal_decompose? The figures were initially generated by using freq=30, I have updated with freq=13. Jul 11, 2016 at 11:34
• Try 15 or something like that. On your first figure, You can see that you are taking one period for two. Jul 11, 2016 at 12:10
• Sales are always seasonal and autocorrelated. If your model structure does not account for autocorrelation, then it'll show up in residuals - where else could it go?! Also sales are usually non-stationary if you measure them in currency. They're usually stationary only in short term. Jul 11, 2016 at 13:54
• @el Josso, can you please elaborate what do you mean by "one period for two"? Jul 11, 2016 at 23:25

You disaggregate a time series into three components -- trend, seasonal and residual.

• The trend component is supposed to capture the slowly-moving overall level of the series.
• The seasonal component captures patterns that repeat every season.
• The residual is what is left. It may or may not be autocorrelated. For example, there can be some autocorrelated pattern evolving quickly around the slowly moving trend plus the seasonal fluctuations. This kind of pattern cannot be ascribed to the trend component (the former moves too fast) or the seasonal component (the former does not obey seasonal timing). So it is left in the remainder.

See also section "Time series decomposition" from Hyndman & Athanasopoulos "Forecasting: principles and practice".

• Considering the residuals to be stationary (it appears to be) I can then use ARMA model to forecast the residuals. How do I go about determining the MA term for my ARMA in this instance? My understanding is that MA term can be determined by ACF plot. Jul 11, 2016 at 11:42
• Yes, you could try forecasting with an ARMA model. Material on determining ARMA orders can be found in (almost all) time series textbooks and has also been discussed extensively in other threads at Cross Validated; I suggest you look them up. ACF and PACF plots can be helpful in simple cases (pure AR or pure MA processes) but become less useful in more complicated cases (both AR and MA parts present). Jul 11, 2016 at 11:51
• do you consider the residuals in the problem a complicated case? Would it be possible to throw some light on what techniques might be better fit for such a case? Jul 11, 2016 at 13:39
• @user2979010, This is a new question, please post it as such (i.e. given certain data -- in your case the remainder term from decomposition -- how to model them best with the goal being forecasting). The original question asks why the remainder term after time series decomposition is autocorrelated. That question I have answered (probably not to your complete satisfaction, that I cannot know). Jul 11, 2016 at 13:43
• sure, I will post a new question. Jul 11, 2016 at 23:26

Correct decomposition requires a good model which might have either fixed seasonal effects or seasonal auto-regressive effects and one or more trends ( or level shifts ) and constant error variance and constant parameters over time. Perhaps your data set ( which you should post) doesn't conform to the requiremnents/assumptions and thus needs "special handling" or empirically-based model formulation.

• I have added the original data plot Jul 11, 2016 at 13:37
• Please post the entire data set . Jul 11, 2016 at 19:18
• The dataset is publicly available via Kaggle Link: kaggle.com/c/rossmann-store-sales Jul 11, 2016 at 23:23
• click on the link, go to "Dashboard --> Data" on the left. The "Data" page will open with links to data CSV files. You will need to login to Kaggle to access the data. I don't think Kaggle T&C allows to re-host/re-distribute the data therefore I cannot post it here. Jul 12, 2016 at 3:27
• You need to post them as I need to have the values before I constructively critique what you are doing ( or not doing ! ). There is no reason that you should not . Jul 14, 2016 at 10:14