4

I'm trying to code up the spearman correlation coefficient test of R in C++.

> x = runif(100)
> y = runif(100)
> cor.test(x,y, method="spearman")
Spearman's rank correlation rho

data:  x and y 
S = 165182, p-value = 0.9306
alternative hypothesis: true rho is not equal to 0 
sample estimates:
    rho 
    0.008808881

I manage to get S and rho, but I cannot find any documentation to go from S to the pvalue. Is there any GSL distribution I can use for this? BTW, I don't want to test significance using Student's t distribution or permutations.

Thanks!

mdewey
  • 16,541
  • 22
  • 30
  • 57
koskos
  • 41
  • 2
  • There are very interesting references and explanations in package [pspearman](http://cran.r-project.org/web/packages/pspearman/index.html) that could help you answer your question. – Vincent Guillemot Jan 24 '14 at 10:27
  • 1
    Look, for example, here http://pic.dhe.ibm.com/infocenter/spssstat/v20r0m0/topic/com.ibm.spss.statistics.help/alg_nonpar_corr_spearman.htm – ttnphns Jan 24 '14 at 12:21
  • 1
    I found one very interesting report: [Fast computation of the exact null distribution of Spearman's $\rho$ and Page's $L$ statistic for samples with and without ties](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.45.7124&rep=rep1&type=pdf). The authors cite many classical references for the computation of the exact distribution of $\rho$ for small samples, and they also provide an algorithm. I would be interested in your opinion on this article, @koskos! – Vincent Guillemot Jan 24 '14 at 13:44

0 Answers0