Spearman Rank Correlation Calculator & Permutation Test
Use paired data to see when a relationship is monotonic and how it differs from the association measured by Pearson’s r. The worksheet shows the pair table, tied ranks and a scatter view of both scales. Inspect what changes when you omit one pair as a diagnostic, then test the original pairs against a distribution of shuffled assignments.
Compare raw values, ranks and ties
See whether paired observations move in order and use a permutation reference to check how unusual the association is.
Paired observations
Paste 3–128 pairs with one pair per row. Use two comma- or tab-separated columns.
5 pairs give Spearman 1 and Pearson 0.795204.
Compare rank and raw scatter
- X 1 to 5
- Y 1 to 5
- Larger dots mark coincident pairs.
Source line 2 · X 1 · Y 1 · ranks 1 and 1
Without this pair, Spearman 1 and Pearson 0.838234.
Test the observed rank association
Evaluate every reassignment of the Y pairs with X held fixed.
Exact p-value 0.016667 from 120 pairings.
- Blue columns show frequency.
- Green outlines mark tail matches.
Horizontal values are shuffled rank correlations. Vertical values count evaluated pairings.
Open distribution counts
| Rho interval | Pairings | Tail matches |
|---|---|---|
| -1 to -0.916667 | 1 | 1 |
| -0.916667 to -0.833333 | 4 | 0 |
| -0.833333 to -0.75 | 3 | 0 |
| -0.75 to -0.666667 | 6 | 0 |
| -0.666667 to -0.583333 | 7 | 0 |
| -0.583333 to -0.5 | 0 | 0 |
| -0.5 to -0.416667 | 6 | 0 |
| -0.416667 to -0.333333 | 4 | 0 |
| -0.333333 to -0.25 | 10 | 0 |
| -0.25 to -0.166667 | 6 | 0 |
| -0.166667 to -0.083333 | 10 | 0 |
| -0.083333 to 0 | 0 | 0 |
| 0 to 0.083333 | 6 | 0 |
| 0.083333 to 0.166667 | 10 | 0 |
| 0.166667 to 0.25 | 6 | 0 |
| 0.25 to 0.333333 | 10 | 0 |
| 0.333333 to 0.416667 | 4 | 0 |
| 0.416667 to 0.5 | 0 | 0 |
| 0.5 to 0.583333 | 6 | 0 |
| 0.583333 to 0.666667 | 7 | 0 |
| 0.666667 to 0.75 | 6 | 0 |
| 0.75 to 0.833333 | 3 | 0 |
| 0.833333 to 0.916667 | 4 | 0 |
| 0.916667 to 1 | 1 | 1 |
Pairs, ranks and tie sizes
| Source line | X | Y | X rank | Y rank | X tie size | Y tie size |
|---|---|---|---|---|---|---|
| 2 (selected) | 1 | 1 | 1 | 1 | 1 | 1 |
| 3 | 2 | 4 | 2 | 2 | 1 | 1 |
| 4 | 3 | 9 | 3 | 3 | 1 | 1 |
| 5 | 4 | 16 | 4 | 4 | 1 | 1 |
| 6 | 5 | 100 | 5 | 5 | 1 | 1 |
Show selectable CSV
How to use this calculator
- Paste paired X and Y values as two columns. Select the header box only when the first nonempty line contains the column names.
- Compare Spearman rho with Pearson r and read the tied group counts. Switch the scatter between ranks and raw values.
- Use the inspect slider to highlight a row. For at least four pairs, read the coefficients after reranking the remaining rows to see whether that point changes the result.
- Choose the permutation tail. For more than eight pairs, enter a seed and draw count. Run the test and compare the shuffled distribution with the observed association.
- Open the distribution counts or download the worksheet to retain the input pairs, midranks, probabilities and evaluated counts.
The Formula
The mathematical logic powering this calculation is:
Enter 3–128 complete numeric X and Y pairs. Each line holds a pair, with the same comma or tab delimiter. The optional header contains two column names. Numeric data must be between −1,000,000,000 and +1,000,000,000 with up to six decimal places. Values keep their order and source lines. The parser keeps the entered precision for comparisons and ties.
Sort each column independently and assign ranks starting at 1. Give equal values the mean of the ranks they occupy. Spearman’s rho is Pearson’s r evaluated on the two rank columns. The product of centered ranks divided by the square root of the two centered sums of squares gives the coefficient. Pearson’s r shown alongside it uses the original values. A constant column has zero centered variation and leaves both coefficients undefined. The omit-one comparison reranks the remaining values and requires at least three remaining pairs. It leaves the original dataset intact.
The permutation test holds X and both rank distributions fixed and reassigns Y across rows. For Either direction it counts shuffled absolute coefficients at least as large as the observed absolute coefficient. Positive tail counts shuffled coefficients at least as large as observed. Negative tail counts coefficients at or below observed. Ties in the tail comparison count. The comparisons use exact integer centered midrank products before division by the common normalizing denominator. Some software doubles the smaller signed tail instead of testing the magnitude.
Through eight pairs the test enumerates every indexed permutation. Repeated ranks can produce the same coefficients on multiple reassigned index orders. Exact p equals tail matches divided by indexed permutations. For larger datasets the worksheet samples 4,096 or 16,384 seeded permutations and reports (tail matches + 1) divided by (draws + 1). The seed and draw count control a repeatable approximate result. Sampled p-values vary with the sampled pairings. The histogram groups the coefficients into 24 equal intervals with the upper limit included only at +1. The test requires independent pairs whose Y values are exchangeable under the null, such as independent observations under independence. Time series, paired clusters and repeated measurements need a permutation structure appropriate to their dependence.Worked Example
If you input:
- X column: 1, 2, 3, 4, 5
- Y column: 1, 4, 9, 16, 100
- Permutation tail: Either direction
Result:
The five pairs have Spearman rho 1 and Pearson r about 0.795204. The order rises throughout even with a large last value. Two of the 120 reassigned pairings are as extreme in either direction, so the exact p-value is 1/60, displayed as 0.016667.
Frequently Asked Questions
What is the difference between Spearman and Pearson correlation?
Spearman correlates the ranks of paired values and describes monotonic ordering. Pearson correlates the original measurements and describes linear association. An increasing curve can give a Spearman coefficient of 1 even when its Pearson result is smaller.
How does this calculator handle tied values?
When two or more observations share a value, they receive the average of the ranks occupied by that tied group. Each variable is ranked independently. The pair table shows the averaged rank and group size for each observation.
Why do exact results count repeated coefficients?
The test reassigns observation indices, so two different pairings can have the same coefficient. Each pairing contributes to the permutation count, including pairings that exchange equal ranks.
Why can a sampled result change when I use a different seed?
Sampled inference evaluates a bounded set of shuffled pairings. A different seed generally draws a different set. The same data, alternative, draw count and seed reproduce the same estimate in this calculator.
Can I use this test for a repeated measurement on the same subjects?
The current test reassigns Y across all rows. A repeated-measures or time-series design often requires shuffling within eligible groups or otherwise preserving dependence. Use the scatter and coefficients descriptively unless the full reassignment assumption fits your design.
What happens when every value in one variable is identical?
That column has zero variation, so the correlation denominator is zero. The worksheet keeps the entered values and tie information, with undefined coefficients and no permutation reference.
Similar Calculators
Pearson Correlation Coefficient Calculator
Calculate Pearson's r to measure the strength and direction of a linear relationship between two variables.
Linear Regression Calculator
Fit a least-squares line, inspect scatter and residual plots, and calculate Student-t confidence and prediction intervals. Paste paired data and export the full ledger.
Relative Frequency Calculator & Cohort Histogram
Compare counts, relative frequencies and cumulative shares in two cohorts. Plot unequal bins and see what raw or grouped data say about a cutoff.
Standard Deviation Calculator
Calculate sample or population standard deviation, variance, mean and extrema from complete decimal data. Preserve small differences and identify invalid entries.
