我有一个长度为177的数据框,我想计算和绘制部分自相关函数(PACF)。
我已经导入了数据,等等:
from statsmodels.tsa.stattools import pacf
ys = pacf(data[key][array].diff(1).dropna(), alpha=0.05, nlags=176, method="ywunbiased")
xs = range(lags+1)
plt.figure()
plt.scatter(xs,ys[0])
plt.grid()
plt.vlines(xs, 0, ys[0])
plt.plot(ys[1])
所使用的方法在很长的滞后(90毫秒)内得出大于1的数字,这是不正确的,并且我得到了RuntimeWarning:在sqrtreturn rho中遇到无效值,np.sqrt(sigmasq),但由于我看不到它们的来源代码我不知道这意味着什么。
说实话,当我搜索PACF时,所有示例仅执行最多40个滞后或60个左右的PACF,并且在lag = 2之后它们从未具有任何有效的PACF,因此我也无法与其他示例进行比较。
但是当我使用时:
method="ols"
# or
method="ywmle"
数字已更正。因此,这一定是他们用来解决问题的算法。
我尝试导入inspect和getsource方法,但它无用,只是表明它使用了另一个软件包,而我找不到。
如果您也知道问题出在哪里,我将非常感谢您的帮助。
作为参考,data [key] [array]的值为:
[1131.130005,1144.939941,1126.209961,1107.300049,1120.680054,1140.839966,1101.719971,1104.23999,1114.579956,1130.199951,1173.819946,1211.920044,1181.27002,1203.599976,1180.589966,1156.849976,1191.5,1189.900.900.129.109.109.129.109.109 1248.290039,1280.079956,1280.660034,1294.869995,1310.609985,1270.089966,1270.199951,1276.660034,1303.819946,1335.849976,1377.939941,1400.630005,1418.300049,1438.23999,1406.819946,1420.859985 1473.4999.8695 1.685.4996.83456 1378.550049、1330.630005、1322.699951、1385.589966、1400.380005、1280.0、1267.380005、1282.829956、1166.359985、968.75、896.23999、903.25、825.880005、735.090027、797.869995、872.809998000000 109.9990090099005.99009.7900900099900999009999.9006.9900.900.900.900.900.900.600.900.600.900.600.900.900.600.900.90.995.1099.1099.1079.1099900、900.99.995.99.995.109.998.109.998.1099.109.109.109.995.109 1104.48999、1169.430054、1186.689941、1089.410034、1030.709 961,1101.599976,1049.329956,1141.199951,1183.26001,1180.550049,1257.640015,1286.119995,1327.219971,1325.829956,1363.609985,1345.199951,1320.640015,1292.280029,1218.890015,1131.420044,1253.300049,1394,9003.41001,139.1406.9349.140.349.240.109.240.109.349.109.240.109.349.149.109.140.109.349.109.140.109.349.109.349.140.109.349.109.349.140.109.349.109.349.140.99240.109.349.109240 1379.319946,1406.579956,1440.670044,1412.160034,1416.180054,1426.189941,1498.109985,1514.680054,1569.189941,1597.569946,1630.73999,1606.280029,1685.72998,1632.969971,1681.550049,1756.540039,1805.810059,1848.359985,1782.589966,1859.449951,1872.339966,1883.949951,1923.569946,1960.22998,1930.6700440000002, 2003.369995,1972.290039,2018.050049,2067.560059,2058.899902,1994.9899899999998,2104.5,2067.889893,2085.51001,2107.389893,2063.110107,2103.840088,1972.180054,1920.030029,2079.360107,2080.409912 2909.96099209999909999998998998 998.99889099998998998998998998998998998998998998998998998998998998998998998998998998998998998998998998998998998998998998998998998998990 2168.27002、2126.149902, 2198.810059,2238.830078,2278.8701170000004,2363.639893,2362.719971,2384.199951,2411.800049,2423.409912,2470.300049,2471.649902,2519.360107,2575.26001,2584.840088,2673.610107,2823.81001004 1280.172.8970.280.178.280.179.280.178.280.178.280
答案 0 :(得分:1)
您的时间序列显然不是平稳的,因此违反了Yule-Walker的假设。
更一般而言,PACF通常适用于固定时间序列。在考虑部分自相关之前,您可能首先需要对数据进行区分。