【问题标题】:How come CCF function in R return different correlation for same vectors ie. corr(x,y) and corr(y,x)R中的CCF函数如何为相同的向量返回不同的相关性,即。 corr(x,y) 和 corr(y,x)
【发布时间】:2019-06-03 16:33:25
【问题描述】:
set.seed(1)
sample = rnorm(20,mean = 5,1)
x=acf(ts.intersect(ts(sample),ts(sample+.5*sample)))

当我们查看上述代码的输出时, x[1,2] , corr between x,y 和 x[2,1] corr between y,x ,它给出了不同的答案。

x[1,2]!=x[2,1] ;我错过了什么?

【问题讨论】:

    标签: r statistics correlation


    【解决方案1】:

    就情节而言,也许您缺少滞后值:右上方的情节滞后 0,...,10,而左下的情节滞后 -10,...,0。那么确实 i 和 -i 滞后在 i=0,...,10 时重合。

    x对象而言,

    x[2,1]
    
    # Autocorrelations of series ‘ts.intersect(ts(sample), ts(sample + 0.5 * sample))’, by lag
    #
    #      2 
    # -0.185 
    x[1,2]
    
    # Autocorrelations of series ‘ts.intersect(ts(sample), ts(sample + 0.5 * sample))’, by lag
    #
    #      1 
    # -0.122 
    

    所以第一个对应于滞后±2,而第二个对应于滞后±1。

    【讨论】:

    • 谢谢,现在清楚了。 x$acf 是一个数组(不是矩阵);所以 x[1,2] 是滞后 1 的相关性,而 x[2,1] 是滞后 2 的相关性
    • @Yash,对。此外,虽然x$acf 确实是一个数组,但目前尚不清楚该数组x[1,2] 的哪个元素是,因为x$acf 是三维的(因此我们需要三个索引),所以看起来确实是一个更好的主意子集x$acf
    • 是的,这就是它变得混乱的原因。感谢您的澄清。
    猜你喜欢
    • 1970-01-01
    • 2016-05-06
    • 2021-08-18
    • 2013-04-22
    • 2012-02-21
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    • 2022-01-17
    相关资源
    最近更新 更多