Skip to main content
Changed title
Source Link

Decompose yearlyannual time series with seasonal_decompse or STL in Statsmodels fails

I have a yearlyan annual time series with the following format:

import pandas as pd
import numpy as np

index = pd.date_range(start='2011-01-01', end='2021-01-01', freq='AS')
values = np.array([.065, .07, .07, .082, .078, .074, .079, .094, .111, .145, .127]) * 10**4
time_series = pd.DataFrame(values, index=index)

                     0
2011-01-01   650.0
2012-01-01   700.0
2013-01-01   700.0
2014-01-01   820.0
2015-01-01   780.0
2016-01-01   740.0
2017-01-01   790.0
2018-01-01   940.0
2019-01-01  1110.0
2020-01-01  1450.0
2021-01-01  1270.0

I would like to apply an ensemble model via moving block bootstrapping and Box-Cox transformation, as suggested by Christoph Bergmeir, Rob Hyndman (the genius), and José Benítez in this article.

The first steps in the procedure are to decompose the time series and bootstrap the residuals. However, neither the STL() nor the seasonal_decompose() from Statsmodels return relevant values for the residual.

In fact, when I try to implement STL() I get this error:

from statsmodels.tsa.seasonal import STL
stl = STL(time_series).fit()
stl.plot()

ValueError: period must be a positive integer >= 2

And the seasonal_decompose() does not lead to any residual, as it assigns all the changes over time to the trend component:

from statsmodels.tsa.seasonal import seasonal_decompose
seasonal = seasonal_decompose(time_series, model='additive')
seasonal.plot()

Plot of seasonal decomposition of yearly time series

I've tried to circumvent the STL() error with the suggestions on this thread, to no avail. The authors of the study above do not apply STL() to non-seasonal series, they apply the loess method instead, which could be explored if someone has any function or module to recommend.

I've also tried to transform the data prior to decomposing it, which again didn't work.

Does anyone have any suggestions on how to tune the parameters for the seasonal decomposers above? Or maybe on how to decompose this time series in a different way?

Decompose yearly time series with seasonal_decompse or STL in Statsmodels fails

I have a yearly time series with the following format:

import pandas as pd
import numpy as np

index = pd.date_range(start='2011-01-01', end='2021-01-01', freq='AS')
values = np.array([.065, .07, .07, .082, .078, .074, .079, .094, .111, .145, .127]) * 10**4
time_series = pd.DataFrame(values, index=index)

                     0
2011-01-01   650.0
2012-01-01   700.0
2013-01-01   700.0
2014-01-01   820.0
2015-01-01   780.0
2016-01-01   740.0
2017-01-01   790.0
2018-01-01   940.0
2019-01-01  1110.0
2020-01-01  1450.0
2021-01-01  1270.0

I would like to apply an ensemble model via moving block bootstrapping and Box-Cox transformation, as suggested by Christoph Bergmeir, Rob Hyndman (the genius), and José Benítez in this article.

The first steps in the procedure are to decompose the time series and bootstrap the residuals. However, neither the STL() nor the seasonal_decompose() from Statsmodels return relevant values for the residual.

In fact, when I try to implement STL() I get this error:

from statsmodels.tsa.seasonal import STL
stl = STL(time_series).fit()
stl.plot()

ValueError: period must be a positive integer >= 2

And the seasonal_decompose() does not lead to any residual, as it assigns all the changes over time to the trend component:

from statsmodels.tsa.seasonal import seasonal_decompose
seasonal = seasonal_decompose(time_series, model='additive')
seasonal.plot()

Plot of seasonal decomposition of yearly time series

I've tried to circumvent the STL() error with the suggestions on this thread, to no avail. The authors of the study above do not apply STL() to non-seasonal series, they apply the loess method instead, which could be explored if someone has any function or module to recommend.

I've also tried to transform the data prior to decomposing it, which again didn't work.

Does anyone have any suggestions on how to tune the parameters for the seasonal decomposers above? Or maybe on how to decompose this time series in a different way?

Decompose annual time series with Statsmodels

I have an annual time series with the following format:

import pandas as pd
import numpy as np

index = pd.date_range(start='2011-01-01', end='2021-01-01', freq='AS')
values = np.array([.065, .07, .07, .082, .078, .074, .079, .094, .111, .145, .127]) * 10**4
time_series = pd.DataFrame(values, index=index)

                     0
2011-01-01   650.0
2012-01-01   700.0
2013-01-01   700.0
2014-01-01   820.0
2015-01-01   780.0
2016-01-01   740.0
2017-01-01   790.0
2018-01-01   940.0
2019-01-01  1110.0
2020-01-01  1450.0
2021-01-01  1270.0

I would like to apply an ensemble model via moving block bootstrapping and Box-Cox transformation, as suggested by Christoph Bergmeir, Rob Hyndman (the genius), and José Benítez in this article.

The first steps in the procedure are to decompose the time series and bootstrap the residuals. However, neither the STL() nor the seasonal_decompose() from Statsmodels return relevant values for the residual.

In fact, when I try to implement STL() I get this error:

from statsmodels.tsa.seasonal import STL
stl = STL(time_series).fit()
stl.plot()

ValueError: period must be a positive integer >= 2

And the seasonal_decompose() does not lead to any residual, as it assigns all the changes over time to the trend component:

from statsmodels.tsa.seasonal import seasonal_decompose
seasonal = seasonal_decompose(time_series, model='additive')
seasonal.plot()

Plot of seasonal decomposition of yearly time series

I've tried to circumvent the STL() error with the suggestions on this thread, to no avail. The authors of the study above do not apply STL() to non-seasonal series, they apply the loess method instead, which could be explored if someone has any function or module to recommend.

I've also tried to transform the data prior to decomposing it, which again didn't work.

Does anyone have any suggestions on how to tune the parameters for the seasonal decomposers above? Or maybe on how to decompose this time series in a different way?

Source Link

Decompose yearly time series with seasonal_decompse or STL in Statsmodels fails

I have a yearly time series with the following format:

import pandas as pd
import numpy as np

index = pd.date_range(start='2011-01-01', end='2021-01-01', freq='AS')
values = np.array([.065, .07, .07, .082, .078, .074, .079, .094, .111, .145, .127]) * 10**4
time_series = pd.DataFrame(values, index=index)

                     0
2011-01-01   650.0
2012-01-01   700.0
2013-01-01   700.0
2014-01-01   820.0
2015-01-01   780.0
2016-01-01   740.0
2017-01-01   790.0
2018-01-01   940.0
2019-01-01  1110.0
2020-01-01  1450.0
2021-01-01  1270.0

I would like to apply an ensemble model via moving block bootstrapping and Box-Cox transformation, as suggested by Christoph Bergmeir, Rob Hyndman (the genius), and José Benítez in this article.

The first steps in the procedure are to decompose the time series and bootstrap the residuals. However, neither the STL() nor the seasonal_decompose() from Statsmodels return relevant values for the residual.

In fact, when I try to implement STL() I get this error:

from statsmodels.tsa.seasonal import STL
stl = STL(time_series).fit()
stl.plot()

ValueError: period must be a positive integer >= 2

And the seasonal_decompose() does not lead to any residual, as it assigns all the changes over time to the trend component:

from statsmodels.tsa.seasonal import seasonal_decompose
seasonal = seasonal_decompose(time_series, model='additive')
seasonal.plot()

Plot of seasonal decomposition of yearly time series

I've tried to circumvent the STL() error with the suggestions on this thread, to no avail. The authors of the study above do not apply STL() to non-seasonal series, they apply the loess method instead, which could be explored if someone has any function or module to recommend.

I've also tried to transform the data prior to decomposing it, which again didn't work.

Does anyone have any suggestions on how to tune the parameters for the seasonal decomposers above? Or maybe on how to decompose this time series in a different way?