[R-SIG-Finance] Ranks of Spearman's rank correlation coefficient

Zanella Marco marco.zanella at inbox.com
Sun Jan 9 14:22:23 CET 2011


Dear Sirs,
I'm using cor() funcion with Spearman method to analyse correlation of timeseries. As you know Spearman method is based on ranks of timeseries, instead of their value. 

Well, what I'm not able to do is to extract the ranks of the timeseries used from cor() to compute the Spearman correlation coefficient (also called rho). 

For instance if I have this two timeseries
> a = c(-0.10, -0.21, -0.35, -0.38, -0.19)
> b = c(-0.53, -0.42, -0.59, -0.55, -0.35)

I obtain rho in this way
> cor(a,b, method="spearman")
>[1] 0.6

but how can I obtain ranks for the two timeseries? Of course, the same computed and used by previous cor().

Best,

Marco

____________________________________________________________
GET FREE 5GB EMAIL - Check out spam free email with many cool features!
Visit http://www.inbox.com/email to find out more!



More information about the R-SIG-Finance mailing list