[R] S in cor.test(..., method="spearman")

Dietrich Trenkler Dietrich.Trenkler at uni-osnabrueck.de
Wed Sep 13 16:44:50 CEST 2006


Dear HelpeRs,

I have some data:

"ice" <- structure(c(0.386, 0.374, 0.393, 0.425, 0.406, 0.344,
    0.327, 0.288, 0.269, 0.256, 0.286, 0.298, 0.329, 0.318, 0.381,
    0.381, 0.47, 0.443, 0.386, 0.342, 0.319, 0.307, 0.284, 0.326,
    0.309, 0.359, 0.376, 0.416, 0.437, 0.548, 41, 56, 63, 68,
    69, 65, 61, 47, 32, 24, 28, 26, 32, 40, 55, 63, 72, 72, 67,
    60, 44, 40, 32, 27, 28, 33, 41, 52, 64, 71), .Dim = as.integer(c(30,
    2)))

Using

    cor.test(ice[,1],ice[,2],method="spearman")

I get (apart from a warning message due to ties)

        Spearman's rank correlation rho

data:  ice[, 1] and ice[, 2]
S = 769.4403, p-value = 1.543e-08
alternative hypothesis: true rho is not equal to 0
sample estimates:
     rho
0.828823

I wonder what S is. I presume it is

sum((rank(ice[,1])-rank(ice[,2]))^2),

but this delivers  768.5. Is it the way ranks are computed in cor.test?


Thank you in advance.

D. Trenkler                              

-- 
Dietrich Trenkler c/o Universitaet Osnabrueck 
Rolandstr. 8; D-49069 Osnabrueck, Germany    
email: Dietrich.Trenkler at Uni-Osnabrueck.de



More information about the R-help mailing list