为什么偏自相关超过1.0?

2024-04-19 20:37:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我曾经统计模型.tsa.stattools.pscf(python模块)来计算时间序列的自相关。虽然自相关的范围必须在-1到1之间,但是由统计工具.pscf超越它。为什么?你知道吗

a=np.array([1,2,3,4,5,1,2,3,4,5])
cor=sm.tsa.stattools.pacf(a,nlags=5,method='yw')
print(cor)
[ 1.          0.22222222 -0.44642857 -0.55588139 -0.50024995  1.49605777]

当滞后为5时,自相关系数大于1.0

a=np.array([1,2,3,4,5,1,2,3,4,9])
cor=sm.tsa.stattools.pacf(a,nlags=5,method='ols')
print(cor)
[ 1.          0.6        -0.32307692 -0.62857143 -1.8         1.84782609

当滞后为4和5时,自相关超出了-1到1的范围。 我知道我做错了什么事,但一根手指也插不上。 请告诉我。你知道吗

]


Tags: 模块模型np时间序列arraymethodsm