Re: [Rd] ccf documentation bug or suggeston (PR#9394)

From: <murdoch_at_stats.uwo.ca>
Date: Tue 28 Nov 2006 - 17:50:35 GMT


On 11/28/2006 11:50 AM, A.I. McLeod wrote:
> Hi Duncan,

Hi Ian.

>
> ccf(x,y) does not explain whether c(k)=cov(x(t),x(t+k)) or d(k)=cov(x(t),x(t-k)) is calculated. The following example demonstrates
> that the c(k) definition is used:
> ccf(c(-1,1,rep(0,8)),c(1,rep(0,9)))
> However S-Plus acf uses the d(k) definition in their acf function.

I don't think our code looks right, let alone our documentation. In both R-devel and R-patched I get a lag zero value of 1 from ccf(), and I think I should get cor(x,y), which in your example, would be -0.74: and that is what I get from 2.4.0.

I hope this isn't a result of my patch to allow length 1 series...

Duncan Murdoch

P.S. No need to send to more than one of R-devel, R-bugs, or me. I'll see the message on any of them. It's probably best to default to R-devel for suggestions like this, but the lag 0 value really is a bug, I think.

>
> For interpretive purposes this is a **vital distinction** (the cross-covariance/correlation is not symmetric like the
> autocovariance/autocorrelation). There is not fixed convention is textbooks or research papers. Some define it one way and other
> another.
>
> There is no ccf function in S-Plus. Instead there is only acf for the auto/cross computation in multivariate time series. This is
> more complicated since numerical output is 3D array.
>
> Here is how S-Plus documents it:
>
> VALUE:
> a list with the following components:
> acf
> a three-dimensional array containing the autocovariance or autocorrelation function estimates. acf[i,j,k] is the covariance (or
> correlation) between the j -th series at time t and the k-th series at time t+1-i.
> lag
> an array the same shape as acf containing the lags (as fractions of the sampling period) at which acf is calculated. If j > k and i
> > 1, then lag[i,j,k] is negative.
>
> Ian McLeod
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Nov 29 04:54:31 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 28 Nov 2006 - 18:30:51 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.