【发布时间】:2021-08-22 10:26:38
【问题描述】:
我有一个格式如下的年度时间序列:
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
我想通过 moving block bootstrapping 和 Box-Cox transformation 应用一个集成模型,正如 Christoph Bergmeir、Rob Hyndman(天才)和 José Benítez 在 this article 中所建议的那样。
该过程的第一步是分解时间序列并引导残差。但是,来自 Statsmodels 的 STL() 和 seasonal_decompose() 都不会返回残差的相关值。
事实上,当我尝试实现STL() 时,我得到了这个错误:
from statsmodels.tsa.seasonal import STL
stl = STL(time_series).fit()
stl.plot()
ValueError: period must be a positive integer >= 2
并且seasonal_decompose() 不会导致任何残差,因为它将随时间的所有变化分配给趋势组件:
from statsmodels.tsa.seasonal import seasonal_decompose
seasonal = seasonal_decompose(time_series, model='additive')
seasonal.plot()
我尝试使用this thread 上的建议来规避STL() 错误,但无济于事。上述研究的作者并没有将STL()应用于非季节性系列,而是使用了黄土方法,如果有人有任何功能或模块可以推荐,可以探索。
我还尝试在分解数据之前对其进行转换,但还是没有用。
有人对如何调整上述季节性分解器的参数有任何建议吗?或者也许关于如何以不同的方式分解这个时间序列?
【问题讨论】:
标签: python time-series statsmodels forecasting