- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 Python 中的 statsmodels 中运行 Dickey-Fuller 测试,但出现错误 P
从 python 2.7 和 Pandas 版本 0.19.2 运行。数据集来自 Github 并导入相同
enter code here
from statsmodels.tsa.stattools import adfuller
def test_stationarity(timeseries):
print 'Results of Dickey-Fuller Test:'
dftest = ts.adfuller(timeseries, autolag='AIC' )
dfoutput = pd.Series(dftest[0:4], index=['Test Statistic','p-value','#Lags Used','Number of Observations Used'])
for key,value in dftest[4].items():
dfoutput['Critical Value (%s)'%key] = value
print dfoutput
test_stationarity(tr)
Results of Dickey-Fuller Test:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-15-10ab4b87e558> in <module>()
----> 1 test_stationarity(tr)
<ipython-input-14-d779e1ed35b3> in test_stationarity(timeseries)
19 #Perform Dickey-Fuller test:
20 print 'Results of Dickey-Fuller Test:'
---> 21 dftest = ts.adfuller(timeseries, autolag='AIC' )
22 #dftest = adfuller(timeseries, autolag='AIC')
23 dfoutput = pd.Series(dftest[0:4], index=['Test Statistic','p-value','#Lags Used','Number of Observations Used'])
C:\Users\SONY\Anaconda2\lib\site-packages\statsmodels\tsa\stattools.pyc in adfuller(x, maxlag, regression, autolag, store, regresults)
209
210 xdiff = np.diff(x)
--> 211 xdall = lagmat(xdiff[:, None], maxlag, trim='both', original='in')
212 nobs = xdall.shape[0] # pylint: disable=E1103
213
C:\Users\SONY\Anaconda2\lib\site-packages\statsmodels\tsa\tsatools.pyc in lagmat(x, maxlag, trim, original)
322 if x.ndim == 1:
323 x = x[:,None]
--> 324 nobs, nvar = x.shape
325 if original in ['ex','sep']:
326 dropidx = nvar
ValueError: too many values to unpack
最佳答案
tr 必须是一维数组,如您所见 here .我不知道你的情况下 tr 是什么。假设您将 tr 定义为包含时间序列数据的数据帧,您应该执行以下操作:
tr = tr.iloc[:,0].values
关于python-2.7 - 我正在尝试在 Python 中的 statsmodels 中运行 Dickey-Fuller 测试,但出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43100441/
我想在时间序列(nobs = 23)上测试平稳性,并从 statsmodels.tsa.stattools 实现 adfuller 测试。 以下是原始数据: 1995-01-01 3126.
我试图弄清楚以下表达式的确切含义: 执行 Dickey-Fuller 测试: print 'Results of Dickey-Fuller Test:' dftest = adfuller(time
这个问题是关于 statsmodels.tsa.stattools python 库中的 Augmented Dickey–Fuller 测试实现 - adfuller()。 原则上,AIC 和 BI
我正在尝试执行时间序列分析,在此过程中我将执行迪基富勒测试来检查数据帧的平稳性。 我不断收到错误ValueError:解包值太多(预期为 2)。我已从数据框中删除了带有 NaN 的所有行。我唯一能想到
我正在尝试在 Python 中的 statsmodels 中运行 Dickey-Fuller 测试,但出现错误 P 从 python 2.7 和 Pandas 版本 0.19.2 运行。数据集来自 G
我是一名优秀的程序员,十分优秀!