Spearman correlation (rho) calculator with confidence interval
Rank correlation between two variables, which detects monotonic relationships even if they are not straight, with p value and confidence interval.
Calculator inputs
Results
Enter your values and press “Calculate” to see the result.
See the working step by step
- n = 10 pairs; t(8) = 9.691
In short
- What it calculates
- Rank correlation between two variables, which detects monotonic relationships even if they are not straight, with p value and confidence interval.
- Formula used
ρ = Pearson correlation between the ranks of X and the ranks of Y- Example
- Example 1. With repeated values.
Spearman correlation calculator
Spearman’s correlation is the robust sibling of Pearson’s: instead of working with the values, it works with their positions (ranks). So it detects relationships that rise or fall steadily even if they are not straight, is not dragged by outliers and suits ordinal data (such as a 1-to-5 agreement scale).
Paste the two columns and you get the coefficient rho, its p value, the confidence interval and the scatter plot. Ties are handled with average ranks. Everything runs in your browser.
How it works
Each value is replaced by its rank (1 for the smallest, n for the largest; with ties, the average of the ranks they occupy) and Pearson’s correlation is computed between the ranks. The result runs from −1 to +1: +1 if whenever one variable rises the other always does, even along a curve.
The p value uses a Student’s t on n − 2 degrees of freedom, and the confidence interval uses Fisher’s z transformation with Bonett and Wright’s (2000) standard error, which is slightly larger than Pearson’s.
Formula
ρ = Pearson correlation between the ranks of X and the ranks of Y
t = ρ · √( (n − 2) / (1 − ρ²) ), df = n − 2
CI: z = atanh(ρ); SE = √( (1 + ρ²/2) / (n − 3) ); limits = tanh( z ± critical z · SE )
With ties: average rank of the tied positions
Worked example
Example 1. With repeated values.
With X = 1, 2, 2, 3, 4, 4, 4, 5, 6, 7 and Y = 2, 1, 3, 3, 5, 6, 4, 7, 8, 9 (there are ties), rho = .960 (95% CI .782 to .993), t(8) = 9.69, p < .001: a very strong positive monotonic relationship.
Example 2. An outlier.
With X = 1 to 10 and Y = 2, 3, …, 10 and 60, Pearson would give .644, but Spearman gives rho = 1: the relationship is perfectly monotonic, and the outlier does not count because only its position matters.
Example 3. A monotonic curve.
With y = x² for x = 1 to 10, the relationship is not a line but is always increasing: rho = 1.
Explanation
What Spearman measures
The strength of the monotonic relationship between two variables: whether, in general, when one rises the other rises (or falls), even if not at a steady rate. It is Pearson’s correlation applied to the ranks.
When to use it
- **Ordinal** data (Likert scales, positions, grades).
- A **curved but monotonic** relationship.
- **Outliers** that distort Pearson.
- Very **skewed** distributions.
Spearman versus Pearson
Pearson measures fit to a straight line and is sensitive to extreme values; Spearman measures fit to an increasing or decreasing relationship, whatever its shape and extremes. If the data are roughly normal and the relationship linear, both give similar results.
Ties
When values are repeated, they get the average of the ranks they would occupy. With many ties, the coefficient loses some precision.
Common mistakes
- Reading correlation as causation.
- Using Spearman with relationships that are not monotonic (for example, U-shaped).
- Ignoring the scatter plot.
- Forgetting that with few pairs the interval is very wide.
Limits of this calculator
- It measures monotonic relationships, not any kind of association.
- The p value is the Student’s t approximation; with fewer than 10 pairs an exact value is preferable.
- The confidence interval uses the Bonett and Wright approximation.
- It accepts up to 2,000 pairs.
Notice
This is an estimate. For publication, check the figures with your statistics package.
Frequently asked questions
What is Spearman’s correlation?
Pearson’s correlation applied to the ranks of the data. It measures whether two variables rise or fall together, without requiring a straight line.
When should I use Spearman instead of Pearson?
With ordinal data, curved but monotonic relationships, outliers or very skewed distributions.
How does it handle ties?
With average ranks: repeated values get the average of the positions they occupy.
What does rho = 1 mean?
That whenever one variable rises, the other always rises (a perfect monotonic relationship), even if it is not a line.
Does it detect any relationship?
No: only monotonic ones. A U-shaped relationship can give a rho near 0.
How much data do I need?
The more the better; with fewer than 10 pairs the approximate p value is not very reliable.
Does correlation imply causation?
No. Two variables moving together does not prove one causes the other.
Is my data sent to a server?
No. The calculation runs in your browser.
Sources and references
The formula behind this calculator is not ours. These are the sources it comes from, in APA 7 format, in case you want to go to the original or cite them in your own work.
- Spearman, C. (1904). The proof and measurement of association between two things. The American Journal of Psychology, 15(1), 72–101. https://doi.org/10.2307/1412159 https://doi.org/10.2307/1412159 The origin of the rank correlation coefficient.
- Bonett, D. G., & Wright, T. A. (2000). Sample size requirements for estimating Pearson, Kendall and Spearman correlations. Psychometrika, 65(1), 23–28. https://doi.org/10.1007/BF02294183 https://doi.org/10.1007/BF02294183 The standard error used for rho’s confidence interval.
Need to calculate something else?
These tools are often used alongside this calculator.
Pearson correlation
Pearson’s r between two variables, with p value, confidence interval, regression line and scatter plot.
Linear regression
Least-squares line or plane with coefficients, intervals, prediction, assumption checks and fit and residual…
Non-parametric tests
Non-parametric tests for ordinal or non-normal data: exact p values when possible, effect sizes and Dunn’s…
Chi-square
Chi-square test for contingency tables and goodness of fit, with Cramér’s V, residuals, Yates’ correction…
Cohen’s d
Effect size between two groups or before and after, with confidence intervals, plain-language equivalents…
Sample size
How many responses you need to estimate a percentage or a mean, with finite population, design effect and…