Spearman Correlation Calculator
Calculate Spearman's rank correlation coefficient ρ for paired data. The calculator ranks each variable (tied values share the average rank), shows the rank table with the differences d and Σd², and returns ρ with its t statistic, degrees of freedom and two-sided p-value, plus a scatter plot of the data.
For a straight-line relationship between raw values, use the Pearson correlation coefficient calculator. Related guide: correlation vs causation.
Enter numbers separated by commas, spaces or new lines
One Y for every X, in the same order
A decimal such as 0.05, for the verdict on the p-value
Related Calculators
Correlation Coefficient Calculator
Calculate Pearson's r with its p-value, Fisher z confidence interval, R², covariance, worked steps and a scatter plot.
Linear Regression Calculator
Fit a least-squares line and get the equation, R², coefficient tests, ANOVA table, confidence and prediction intervals, residuals and a plot.
Covariance Calculator
Measure how paired variables move together with sample or population covariance and Pearson r.
Learn More
Correlation and Regression in Excel: CORREL, SLOPE and LINEST
Excel functions for correlation and linear regression — CORREL, RSQ, SLOPE, INTERCEPT, LINEST — the Regression ToolPak output explained and Spearman correlation via RANK.AVG.
Parametric vs Nonparametric Tests
What each family assumes, the rank-based alternative to every common test, a worked comparison of the t-test with Mann-Whitney U, and when to switch to ranks.
What Spearman's rank correlation measures
Spearman's ρ (rho) measures how well the relationship between two variables can be described by a monotonic function, one that only ever rises or only ever falls. It is Pearson's correlation applied to the ranks of the data instead of the raw values, so it needs only an ordering, not a distance: it works for ordinal scales such as survey ratings, it is not thrown off by outliers, and it equals 1 for any perfectly increasing relationship even when the points lie on a curve.
Formulas
Without ties: ρ = 1 − 6·Σd² / ( n(n² − 1) ), d = rank of x − rank of y
With ties: ρ = Pearson's r of the two lists of average ranks
t = ρ·√( (n − 2) / (1 − ρ²) ) on n − 2 degrees of freedom
Tied values receive the mean of the ranks they span: two values tied for 2nd and 3rd place both get rank 2.5. The shortcut with Σd² is exact only when there are no ties, so the calculator always computes ρ as Pearson's r of the rank lists, which is correct in both cases, and prints the shortcut as a check when there are no ties.
Worked example: IQ and hours of television
Ten people have IQ scores X = 86, 97, 99, 100, 101, 103, 106, 110, 112, 113 and watch Y = 2, 20, 28, 27, 50, 29, 7, 17, 6, 12 hours of television per week. Load example fills in these numbers.
| Person | IQ | TV hours | Rank of IQ | Rank of TV | d | d² |
|---|---|---|---|---|---|---|
| 1 | 86 | 2 | 1 | 1 | 0 | 0 |
| 2 | 97 | 20 | 2 | 6 | −4 | 16 |
| 3 | 99 | 28 | 3 | 8 | −5 | 25 |
| 4 | 100 | 27 | 4 | 7 | −3 | 9 |
| 5 | 101 | 50 | 5 | 10 | −5 | 25 |
| 6 | 103 | 29 | 6 | 9 | −3 | 9 |
| 7 | 106 | 7 | 7 | 3 | 4 | 16 |
| 8 | 110 | 17 | 8 | 5 | 3 | 9 |
| 9 | 112 | 6 | 9 | 2 | 7 | 49 |
| 10 | 113 | 12 | 10 | 4 | 6 | 36 |
| Sum | 0 | 194 |
- Rho: ρ = 1 − 6 × 194 ÷ (10 × 99) = 1 − 1164 ÷ 990 = −0.1758.
- Test: t = −0.1758 × √(8 ÷ 0.9691) = −0.505 on 8 degrees of freedom, so the two-sided p-value is 0.627188.
Interpretation: the ranks show a weak negative association, and with p = 0.627 there is no evidence of a monotonic relationship between IQ and television time in this sample.
Spearman or Pearson?
Choose by the kind of relationship and data, not by which coefficient is larger:
| Situation | Pearson r | Spearman ρ |
|---|---|---|
| Straight-line trend, no outliers | Best choice: uses the actual distances | Similar value; slightly less powerful |
| X = 1 to 6, Y = 1, 4, 9, 16, 25, 36 (a curve) | 0.9789 | 1 |
| X = 1 to 7, Y = 2, 3, 4, 5, 6, 7, 100 (one outlier) | 0.6491 | 1 |
| Ordinal data such as 1 to 5 ratings | Assumes equal spacing | Appropriate |
Neither coefficient shows causation, and both can miss a non-monotonic pattern such as a U shape. To fit a line to the raw data, use the linear regression calculator.
How the p-value is calculated
The calculator converts ρ to t = ρ√((n − 2) / (1 − ρ²)) and reads the two-sided p-value from the t distribution with n − 2 degrees of freedom. This is the approximation SciPy's spearmanr reports, and it works well from about 10 pairs. For small samples without ties, R's cor.test computes exact or series-approximated p-values instead, which can differ in the second or third decimal. The tie-adjusted ρ itself is identical everywhere. The test assumes independent pairs.
Spearman correlation in other software
| Tool | Command |
|---|---|
| Excel / Google Sheets | Rank each column with =RANK.AVG(A2, A$2:A$11, 1), then =CORREL(rank_x_range, rank_y_range); there is no single built-in function |
| R | cor(x, y, method = "spearman"); cor.test(x, y, method = "spearman") |
| Python | scipy.stats.spearmanr(x, y) returns rho and the p-value |
| SPSS | Analyze > Correlate > Bivariate, tick Spearman |
Related guides and calculators
Pearson's coefficient is the correlation calculator; the covariance calculator gives the unscaled version, the regression calculator fits a line, and R-squared measures the share of variation explained. Read covariance vs correlation and correlation vs causation.
Frequently Asked Questions
What is the Spearman correlation coefficient?
Spearman's ρ is the correlation between the ranks of two variables. It ranges from −1 to 1 and is 1 when Y always increases as X increases, whatever the shape of the curve, −1 when Y always decreases, and near 0 when there is no monotonic pattern. It is computed as Pearson's r on the ranks.
When should I use Spearman instead of Pearson?
Use it for ordinal data, for data with outliers, and for relationships that rise or fall steadily but not in a straight line. Use Pearson when the relationship is linear and the data are continuous without extreme values, because it uses more of the information in the data.
How does the calculator handle tied values?
Tied values share the average of the ranks they would occupy, for example ranks 2 and 3 become 2.5 and 2.5. With ties the shortcut formula 1 − 6Σd² / (n(n² − 1)) is not exact, so ρ is computed as the Pearson correlation of the average ranks, the same as SciPy and R.
What is a good Spearman rho?
The same conventions as for Pearson's r apply: about 0.1 small, 0.3 medium and 0.5 large in behavioral research, but the meaning depends on the field. Look at the p-value for evidence of a monotonic association and at the scatter plot for the shape of the relationship.
Why is my p-value different from R or SPSS?
This calculator, like SciPy, uses the t approximation with n − 2 degrees of freedom. For small samples without ties R computes exact or series-approximated p-values, and SPSS uses its own approximation, so p-values can differ in the second or third decimal for small n. The value of ρ itself is the same.
How many pairs do I need?
The calculator needs at least 2 pairs for ρ (which is then always 1 or −1) and 3 for a p-value. The t approximation is reliable from about 10 pairs; with fewer, treat the p-value with caution and prefer an exact table or permutation test.
Why does the calculator say a variable has no variation?
If every X value (or every Y value) is the same, all ranks are equal, the ranks have zero variance and the correlation is a division of 0 by 0. The calculator reports which list is constant instead of returning a number.
Embed This Calculator
Add this free calculator to your course page or LMS.
Adjust the height value to fit your page.