我有一个长度为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,1129.329956,109.1099.28.29569.8,112.109.8298.2100,122.109.9008.210092,122.1099.2829956800 ,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,1482.369995 1390.619995,1503.85.91 149.6851.5468.5981.5468.5981.5468.155.9495.145 ,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.8099980000001,919.1400150000001,919.320007,1095.0999.89999.01096.99996.99996.99996.99996.99996.9996.99996.99996.99999.09996.99996.99996.99996.99999.09996.99996.99996.99999.09996.99996.99996.99996.999.999.699.90.990.6999.999.999.60.6900.990.6999.109.608.99.990.6999.109.608.99.990.6999.1999.99.990.6999.109.999.999.600.99.109.109.999.56.109.9995.6999.99.99.409.999.56.109.999.56.109.999.109.996000.99.990.6999.109.999.56.109.996000.99.996000 ,1186.689941、1089.410034、1030.709961 ,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,1246.959961.1349.06.9136.139.240.109.109.140.109.109.109.140.109.140.109.140.109.140.109.140.109.140.109.109.109.140.140.109.109.140.109.134.109.140.109.349.109.349.109.140.109.349.109.140.109.140.109.109.109.140.6097.109.140134.109.109 ,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,1589.598.960898.96098.9958295989359985829 998.598985.8949589858995998 989898954995 ,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,2043.93992 2099.298909298200099000.298.9989081298.298.998980.298.98098.998098 ,2126.149902,21 98.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.810059,127.1807.04702.9760.178.280.170.280.170.280.178.280.178.280.178.280.10017.280.127.280.170.178.2801700.127.28017.109.178

最佳答案

您的时间序列显然很不稳定,因此违反了Yule-Walker的假设。

更一般而言,PACF通常适用于固定时间序列。在考虑部分自相关之前,您可能首先需要对数据进行区分。

关于python-3.x - statsmodels.tsa.stattools中的PACF函数在使用ywunbiased时给出大于1的数字。,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55252492/

10-09 17:14