Prof Brian Ripley <[EMAIL PROTECTED]> writes: > On Wed, 1 Dec 2004, Branimir K. Hackenberger wrote: > > > Who knows which correction (by tied numbers) is used by Spearman-test in > > function cor.test (e.g. cor.test(a,b,method="spearman"))? > > Anyone who reads the sources! The critical line in cor.test.default is > > r <- cor(rank(x), rank(y)) > > so it uses rank(), and that averages ranks of tied observations.
...and correcting the p value for that is on the wish list for some of us. As far as I remember, that is quite easy to do in the asymptotic approximation (but hard to do exactly): Start by working out the covariance matrix of the y ranks given the tied sets of values; a matrix with compound symmetry, obviously, and with rows/columns summing to zero since the sum of the ranks is known, so you really just need the variance of ry_1. Then note that the statistic is equivalent to sum(rx*ry) which, conditionally on the values of x (and y), has the distribution of a linear combination of the ry, the variance of which is... -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html