What is the maximum number of pairs allowed in a Spearman correlation to calculate the p-value in order to check the significance of the correlation coefficient?

As per the articles I've found online and their formulae that I tried, I'm getting a p-value of above 1, I want to know where I'm going wrong.

My data sets' sizes vary from 30 data points to 150 data points. I have the Spearman correlation coefficient but I want to test for significance.

  • 1
    $\begingroup$ Use this in R: cor.test(x, y, method = "spearman") $\endgroup$ Feb 20, 2023 at 17:37
  • 1
    $\begingroup$ Better yet, run ?cor.test and read how the function does hypothesis testing for Spearman correlation. $\endgroup$
    – Dave
    Feb 20, 2023 at 17:40
  • $\begingroup$ You don't give enough detail for people to figure out where you're going wrong. $\endgroup$
    – Glen_b
    Feb 21, 2023 at 4:45
  • $\begingroup$ Sample size and precision for correlations is covered at hbiostat.org/bbr/corr with R code. It's best to assume that all correlations are non-zero and realize that testing against zero isn't very meaningful. Think about using confidence intervals instead. $\endgroup$ Feb 12 at 14:22

2 Answers 2


You definitely shouldn't be getting a p value greater than 1.

You can, of course, do the calculation for Spearman's rho by hand, and then look up in a table the p value for that rho and your given sample size.

However, it's easy enough to do with available software.

For example, you can run the following R code here, without installing software: rdrr.io/snippets/ .

A = c(1,2,3,4,5,6,7,8,9,10)
B = c(2,4,3,5,7,4,4,8,9,11)

cor.test(~ A + B, method="spearman")

In any case, you could use this approach to double-check your calculations.

You could also use free software like Jamovi, which is gui-based, fairly intuitive, and will allow you to import your data, from, say, a .csv file.


There is no maximum sample size allowable for calculating Spearman's rank correlation coefficient.

To test $\text{H}_{0}\text{: }\rho_{\text{S}} = 0$ against $\text{H}_{\text{A}}\text{: }\rho_{\text{S}} \ne 0$, you can use a $t$ test statistic (let's choose $\alpha = 0.01$):

$$t = \frac{r_{\text{S}}-\rho_{\text{S0}}}{\sigma_{r_{\text{S}}}} \approx \frac{r_{\text{S}}}{s_{r_{\text{S}}}}$$

Where $s_{r_{\text{S}}} = \sqrt{\frac{1-r^2_{\text{S}}}{n-2}}$.

For example, of you calculate $r_{\text{S}}=0.6$ in a sample of 20 paired observations, then $s_{r_{\text{S}}}=\sqrt{\frac{1 - .6^2}{20-2}} = 0.1885618$, and so $t = 3.181981$. Therefore $p = Pr(|T_{\nu=18}|\ge |3.181981|) = 0.00258146\times 2 = 0.00516292$.

Because $0.00516292 < 0.01$ (i.e. $p < \alpha$), we reject $\text{H}_{0}$, and can conclude that we found evidence that $\rho_{\text{S}}$ is not equal to 0 significant at the $\alpha = 0.01$ level.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.