[R] moving correlation coef ?

Sundar Dorai-Raj
Wed, 29 Jun 2005 14:31:54 -0000

vincent wrote:
> Hello,
>
> R gives us the correlation functions cor(). (Many thanks ;-))
> Does it also exist a "moving correlation" coefficient ?
> (like the moving average).
> If not, could someone give me some infos or link
> on how to practically implement such a function in R.
>
> (I did search for "moving correlation" on the R homepage
> but didn't find anything.)
>
> Thank you.
> Vincent
>


See ?running in the gtools package:

library(gtools)
X <- rnorm(100); Y <- rnorm(100)
running(X, Y, cor)

HTH,

--sundar