为什么R的ccf说"Autocorrelations of series 'X', by lag"?



在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)
  ..
}

最新更新