Why am I getting different results from cor VS ccf ? (R)
Posted
by Tal Galili
on Stack Overflow
See other posts from Stack Overflow
or by Tal Galili
Published on 2010-04-26T17:50:05Z
Indexed on
2010/04/26
17:53 UTC
Read the original article
Hit count: 309
Hi all,
I am getting different results from ccf and cor, Here is a simple example:
set.seed(100)
N <- 100
x1 <- sample(N)
x2 <- x1 + rnorm(N,0,5)
ccf(x1,x2)$acf[ccf(x1,x2)$lag == -1]
cor(x1[-N], x2[-1])
Results:
> ccf(x1,x2)$acf[ccf(x1,x2)$lag == -1]
[1] -0.128027
> cor(x1[-N], x2[-1])
[1] -0.1301427
Thanks, Tal
© Stack Overflow or respective owner