[R] How does ccf() really work?
Robert Lundqvist
Robert.Lundqvist at ltu.se
Thu Apr 13 15:35:39 CEST 2006
I can't understand the results from cross-correlation function ccf()
even though it should be simple.
Here's my short example:
*********
a<-rnorm(5);b<-rnorm(5)
a;b
[1] 1.4429135 0.8470067 1.2263730 -1.8159190 -0.6997260
[1] -0.4227674 0.8602645 -0.6810602 -1.4858726 -0.7008563
cc<-ccf(a,b,lag.max=4,type="correlation")
cc
Autocorrelations of series 'X', by lag
-4 -3 -2 -1 0 1 2 3 4
-0.056 -0.289 -0.232 0.199 0.618 0.568 -0.517 -0.280 -0.012
**********
With lag 4 and vectors of length 5 there should as far as I can see
only be 2 pairs of observations. The correlation would then be 1.
Guess I am missing something really simple here. Anyone who could
explain what is happening?
Robert
More information about the R-help
mailing list