Reputation: 541
my problem is that I have calculated Spearman rank correlations between two variables. One reviewer asked me if I could add also test statistics for all coefficients where p < 0.001.
Here is one result:
> cor.test(pl$data, pl$rang, method= "spearman")
# Spearman's rank correlation rho
data: pl$data and pl$rang
S = 911164.6, p-value = 1.513e-05
alternative hypothesis: true rho is not equal to 0
sample estimates:
rho
-0.3347658
Is the test statistics equal to S = 911164.6? Is it OK that it is so big number? Sorry in advance if the question is not very professional but I spend quite some time searching for the answers in the books and on internet. :( Thank you for the help in advance.
Upvotes: 1
Views: 4408
Reputation: 21
The best answer I have found is on the page: Rpubs Spearman Rank Correlation
This question is also on Cross Validated "Interpreting the Spearman's Rank Correlation Coefficient output in R. What is 'S'?"
While 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 is clear, there is no clear explaination on how to interpret the results. I have yet to find a clear answer :(
Upvotes: 0
Reputation: 121077
Yes. The ?cor.test
help page (in the Value section) describes the return value from cor.test
as:
A list with class ‘"htest"’ containing the following components:
statistic: the value of the test statistic.
Adapting the example on that page, we see
x <- c(44.4, 45.9, 41.9, 53.3, 44.7, 44.1, 50.7, 45.2, 60.1)
y <- c( 2.6, 3.1, 2.5, 5.0, 3.6, 4.0, 5.2, 2.8, 3.8)
(result <- cor.test(x, y, method = "spearman"))
# Spearman's rank correlation rho
# data: x and y
# S = 48, p-value = 0.0968
# alternative hypothesis: true rho is not equal to 0
# sample estimates:
# rho
# 0.6
result$statistic
# S
# 48
The statistic is given by (n ^ 3 - n) * (1 - r) / 6
where n
is the length of x
and r <- cor(rank(x), rank(y))
.
Upvotes: 4