# Interpreting the Spearman's Rank Correlation Coefficient output in R. What is 'S'?

I just need some clarification regarding the interpretation of the Spearman's Rank Correlation Coefficient output in R. I am currently determining correlations over a tri-nominal temporal scale in an ecological setting. My basic code is as below:

cor.test(v1,v2,method="spearman")

and the example output is as follows:

Spearman's rank correlation rho


data: v1 and v2 S = 466770, p-value = 0.4601 alternative hypothesis: true rho is not equal to 0 sample estimates: rho 0.06203443

I understand the output for the rho and p values however i cannot find a definitive answer for what 'S' is? Am i required to report this value? Any clarification will be much welcomed.

Thanks

• The best answer I have found is on the page: Rpubs Spearman Rank Correlation This question is also on Stack Overflow "test statistic for Spearman rank correlation" While both provide the forumla (n ^ 3 - n) * (1 - r) / 6, were n is equal to the sample size of variables and r is equal to the correlation coefficient (rho) for calculting the S statistic, they do not explain how to interpret the results. I have yet to find a clear answer :(
– Dan
May 20, 2020 at 12:59
• $S,$ by itself, is meaningless (because it depends on the amount of data).
– whuber
May 20, 2020 at 14:21

S is the test statistic which is the sum of all squared rank differences. To make it more understandable. Assume we have to following data:

v1 <- c(1, 2, 3, 4)
v2 <- c(3, 4, 2, 1)


Now, we get the ranks.

#v1 rank(v1)  v2  rank(v2) d = |rank(v2) - rank (v1)|  d^2
# 1        4   3         2                          2    4
# 2        3   4         1                          2    4
# 3        2   2         3                          1    1
# 4        1   1         4                          3    9


The sum over all d^2 is 4 + 4 + 1 + 9 = 18. (Another example can be found here: https://statistics.laerd.com/statistical-guides/spearmans-rank-order-correlation-statistical-guide-2.php)

We find the same thing in R:

test <- cor.test(v1,v2,method="spearman")
test\$statistic #S is 18


S is derived from random variables and can be assumed to have a distribution (like a t-distribution or normal-distribution). And depending on the distribution and their parameters you can say how likeli it is to observe this (or a more extreme) value under this distribution. This is your p-value.

In moste cases I would say that the major part of the readers is happy with the correlation-coefficient, the p-value and the cases numbers ("n"). But this is a next question that would better fit at https://academia.stackexchange.com/.

• Thank you, that makes sense. So when reporting the results of the Spearman's Rank, I can exclude this S value and jsut continue with the reporting of Rho and p-value? Jul 28, 2016 at 10:34
• @TomDallo10 Nobody can tell you what should or should not be reported, since it depends on context, which you have not given. For example, different journals have entirely different standards on some things, and some areas of research have very different expectations. I find some sets of conventions on these things to be baffling and others to be perfectly reasonable, even when they differ. What are the expectations of your audience? (I sure can't guess) Jul 28, 2016 at 10:51
• I am currently writing a scientific report looking at the overall temporal change over a tri-annual period looking at various variables such as hard coral cover and coral reef community diveristy, to put it short. The scientific report is not peer-reviewed and is open access - as if it was peer-reviewed i would be able to source the answer. I guess my query is the standard format of which it is reported, hence my assumption of excluding the S value. Jul 28, 2016 at 11:04