【问题标题】:What is the order of the arguments in Python statsmodels cross-correlation function?Python statsmodels 互相关函数中参数的顺序是什么?
【发布时间】:2021-05-13 08:01:21
【问题描述】:

我正在查看 Python statsmodels 互相关函数 statsmodels.tsa.stattools.ccf 的文档并有一个问题。

问题:这个函数的参数顺序是什么?所以如果我们输入ccf(x, y),正时滞对应的是哪一个:

(1) x(t)y(t + 滞后),或

(2) y(t)x(t + 滞后)

从文档https://www.statsmodels.org/stable/generated/statsmodels.tsa.stattools.ccf.html 中似乎不清楚。

提前致谢。

【问题讨论】:

    标签: python statistics statsmodels cross-correlation


    【解决方案1】:

    ccf 函数是这样定义的(here 你可以看看文档):

    x = array_like(x, "x")
    y = array_like(y, "y")
    adjusted = bool_like(adjusted, "adjusted")
    
    cvf = ccovf(x, y, adjusted=adjusted, demean=True)
    return cvf / (np.std(x) * np.std(y))
    

    还有here 交叉协方差函数 (ccovf) 定义。

    【讨论】:

    • 非常感谢您的回复。查看文档,看起来ccovf 函数依赖于np.correlate。根据这里的帖子:stackoverflow.com/questions/37093382/…,看起来 (x, y) 的顺序对应于 x(t)*y(t+lag)。这看起来正确吗?非常感谢
    • 对,我也是这么理解的
    猜你喜欢
    • 2016-08-27
    • 2016-08-27
    • 2020-06-07
    • 2019-01-28
    • 1970-01-01
    • 2020-01-05
    • 1970-01-01
    • 2011-05-29
    相关资源
    最近更新 更多