繁体   English   中英

R中的CCF函数如何为相同的向量返回不同的相关性,即。 corr(x,y) 和 corr(y,x)

[英]How come CCF function in R return different correlation for same vectors ie. corr(x,y) and corr(y,x)

set.seed(1)
sample = rnorm(20,mean = 5,1)
x=acf(ts.intersect(ts(sample),ts(sample+.5*sample)))

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

x[1,2]!=x[2,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。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM