Dear Gabor, thank you for your suggestion. I've already verified the result via computation of cor() on ranked timeseries with rank(), and as you report the result is the same of cor() with spearman method on simple timeseries.
But, aren't there a way to extract the rank directly form cor() function, that of course computes ranks in order to give the result. I'm tinking in a way like "cor$ranks". Tanks. Marco > -----Original Message----- > From: [email protected] > Sent: Sun, 9 Jan 2011 15:02:10 -0500 > To: [email protected] > Subject: Re: [R-SIG-Finance] Ranks of Spearman's rank correlation > coefficient > > On Sun, Jan 9, 2011 at 8:22 AM, Zanella Marco <[email protected]> > wrote: >> 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(). >> > > Try this: > >> cor(rank(a), rank(b)) > [1] 0.6 > > > -- > Statistics & Software Consulting > GKX Group, GKX Associates Inc. > tel: 1-877-GKX-GROUP > email: ggrothendieck at gmail.com ____________________________________________________________ Send your photos by email in seconds... TRY FREE IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if3 Works in all emails, instant messengers, blogs, forums and social networks. _______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
