[R] moving correlation coef ?

vincent vincent at 7d4.com
Thu Jun 30 07:15:55 CEST 2005


Sundar Dorai-Raj a écrit :

> Perhaps ?cov.wt will work for you? Your example would be identical to:
> 
> set.seed(1)
> X <- rnorm(100); Y <- rnorm(100)
> # using cov.wt
> rho1 <- cov.wt(cbind(X, Y), 1:100, cor = TRUE)$cor[1, 2]
> # your weighting scheme
> rho2 <- cor(X[rep(1:100, 1:100)], Y[rep(1:100, 1:100)])
> all.equal(rho1, rho2)
> # [1] TRUE
> 
> HTH,
> 
> --sundar

Thank you very much Sundar for your advices.
I will try this way.
Have a good day.
Vincent




More information about the R-help mailing list