python的pacf与R的pacf结果不同

时间:2018-07-06 14:55:43

标签: python r statistics statsmodels

我有62条以csv格式编写的数据,如下所示:

30.5362
25.6885
26.4064
32.3865
119.7683
47.8631
39.2101
66.3556
50.2116
39.0534
80.1353
244.6534
27.6962
31.156
36.8919
24.5189
30.0495
76.6318
29.7643
27.4282
33.3718
50.5167
33.9744
57.1195
28.2873
57.1757
44.3871
40.2751
24.8593
106.2184
38.9212
27.1548
73.0252
26.3496
77.244
59.3436
39.004
42.1198
28.9949
27.6137
84.7359
30.3363
26.3834
82.2613
38.5462
38.3386
39.7399
32.3213
27.2249
30.7603
28.3559
98.3449
30.0068
36.6621
71.6423
67.1936
173.1703
93.3722
27.6405
38.4115
31.3264
24.966

首先,使用R的pacf函数计算pacf如下:

mydata = read.csv('peaks.csv')
pacf(mydata[,1], lag=50, xlim=c(3,50), ylim=c(-0.3,0.3))

结果如下:

enter image description here

接下来,我使用python的statsmodels.tsa.stattools包尝试了此数据,如下所示:

import pandas as pd
from statsmodels.tsa.stattools import acf, pacf
PACF = pacf(dataframe['peak_pressure'], method='ld', nlags=50)
ax2 = fig.add_subplot(111)
ax2.set_title('PACF')
ax2.set_xlabel('time lag')
ax2.stem(lags[2:], PACF[2:], markerfmt=' ', label='PACF')
ax2.set_ylim([-0.3, 0.3])
plt.show()

enter image description here

如您所见,这两个图形显示相同的行为,直到出现36个滞后,但之后python的结果如下所示低于-1:

enter image description here

如何解决此问题?还是Python中的错误?

0 个答案:

没有答案