在 R shell 中执行 a 和 b 之间的互相关:
> x=ccf(a,b)
> x
Autocorrelations of series ‘X’, by lag
...
为什么使用术语“自相关”?我认为“自相关”是序列与自身滞后版本的相关性,而不是与另一个(可能滞后的)序列的相关性。
最佳答案
ccf
首先将两个时间序列在时间上相交,然后将结果传递给 acf
。换句话说,互相关是相交的双变量序列 X
的自相关。
这在查看 ccf
的源代码时很明显,您可以通过键入 ccf
并按回车键来完成(或者,在 RStudio 中,键入它并按 F2 在新的脚本选项卡中打开源代码)。
摘录如下:
function (x, y, lag.max = NULL, type = c("correlation", "covariance"),
plot = TRUE, na.action = na.fail, ...)
{
..
X <- ts.intersect(as.ts(x), as.ts(y))
colnames(X) <- c(deparse(substitute(x))[1L], deparse(substitute(y))[1L])
acf.out <- acf(X, lag.max = lag.max, plot = FALSE, type = type,
na.action = na.action)
..
}
关于r - 为什么 R 的 ccf 说 "Autocorrelations of series ' X',延迟”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24252659/