Re: [Rd] CCF and ACF

2006-10-03 Thread Simone Giannerini
Thank you Gabor, by the way I have checked in the Matlab GARCH toolbox, the crosscorrelation function is reversed with respect to R, I think it would be useful for the users to have documented the way CCF is computed. Simone On 10/2/06, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Using "ts" o

Re: [Rd] CCF and ACF

2006-10-02 Thread Gabor Grothendieck
Using "ts" objects these can be written in the following consistent manner: > sum(ts(x) * lag(ts(x)) / sum(ts(x)^2)) [1] -0.2648633 > sum(ts(x) * lag(ts(y)) / sqrt(sum(ts(y)^2) * sum(ts(x)^2))) [1] 0.5930216 On 10/2/06, Simone Giannerini <[EMAIL PROTECTED]> wrote: > Dear all, > > given two nume

[Rd] CCF and ACF

2006-10-02 Thread Simone Giannerini
Dear all, given two numeric vectors x and y, the ACF(x) at lag k is cor(x(t),x(t+k)) while the CCF(x,y) at lag k is cor(x(t),y(t-k)). See below for a simple example. > set.seed(1) > x <- rnorm(10) > y <- rnorm(10) > x [1] -0.6264538 0.1836433 -0.8356286 1.5952808 0.3295078 -0.8204684 0.4