A little context. A clearer answer.
When this calculator is useful
Reversing the order of the second series turns its association with the first negative, while a tie in the first series limits the strength of the ranking. Change “Y” from 1, 3, 2, 4 to 4, 3, 2, 1 and keep the other inputs from the worked example. The value for “Spearman ρ” goes from 0.9487 to -0.9487. For a related calculation, try Linear regression and residuals.
Spearman’s rank correlation compares the ordering of two measurements recorded on the same observations. One list might contain completion times and the other a sequence of performance ratings for the same people. Enter the values in matching row order. The first element of the second list must belong to the same observation as the first element of the first list, and so on. Sorting the columns separately destroys the pairing and can manufacture a strong association.
The calculation sorts each variable internally to assign ranks, then returns the ranks to their original observation positions. If two equal observations occupy second and third place, both receive rank 2.5. This keeps the total of all ranks unchanged. The coefficient is the ordinary correlation between those two rank vectors. Computing it that way correctly handles groups of equal observed values. The common shortcut based only on squared rank differences assumes distinct ranks and can yield a different answer when several observations have equal values.
For the values 1, 2, 2 and 4, the first rank vector is 1, 2.5, 2.5 and 4. Suppose the paired second values are 1, 3, 2 and 4. Their ranks are 1, 3, 2 and 4. Both mean ranks are 2.5. The cross-product sum after centring is 4.5, and the squared deviations sum to 4.5 and 5 respectively. Dividing the cross-product sum by the geometric mean of those last two numbers gives approximately 0.948683.
In the exact test, the first rank vector stays fixed and the positions of all second ranks are permuted. The two-sided statistic is the absolute correlation, so negative and positive extremes count by magnitude. Each permutation of observation positions contributes once, even when tied observations produce repeated rank arrangements. For the four-observation example there are twenty-four permutations. Four yield absolute correlations at least as large as the observed one. The fraction of permutations at least as extreme as the observed result is therefore one sixth.
With eight pairs the exact option considers 40,320 permutations. Larger lists can use coefficient-only mode for up to sixty-four pairs. No significance value is reported in that mode. The exact permutation interpretation assumes exchangeability of the paired assignments under the null hypothesis. A time series with strong persistence, clustered observations from the same person or repeated measurements nested within a site can violate that assumption. Changing the test setting does not remedy dependence among observations.
A rank-versus-rank graph shows where the observations agree in order and where they do not. Several points can share the same position when repeated equal values occur in both variables. Changing the ranks of one variable from increasing order to decreasing order reverses the sign of the coefficient, while changing units with a strictly increasing transformation leaves it unchanged. A list containing just one distinct value has no measurable rank variation. In that case the denominator of the correlation vanishes and no numerical coefficient is defined.
A value near one describes a consistently increasing ordering, even when the original relationship curves. A value near minus one describes decreasing ordering. A U-shaped relationship can give a correlation near zero because increasing and decreasing ordering patterns can cancel each other in the overall coefficient. Examine the original measurements and their pairing before describing the form of an association. The coefficient measures ordering, and the permutation probability describes extremeness under a specified random reassignment, rather than the probability that a proposed explanation is correct.
What to enter
| Input | What it means | Example value |
|---|---|---|
| X | X | 1, 2, 2, 4 |
| Y | Y | 1, 3, 2, 4 |
| Significance test | Significance test | Exact permutation test |
How the calculation works
- Enter equally long X and Y lists with the observations in the same paired order. Use a decimal point within numbers and commas, semicolons or whitespace between observations.
- Choose the coefficient alone or the exact permutation test. The exact calculation retains tied-observation multiplicities and compares absolute correlation values.
- Inspect the rank scatter and compare the sign and size of rho with your original paired data. A small coefficient does not exclude a nonmonotonic relationship.
ρₛ = Σ(Rx−R̄)(Ry−R̄)/√[Σ(Rx−R̄)²Σ(Ry−R̄)²]A worked example
For X = 1, 2, 2, 4 the tied values both have rank 2.5. With Y = 1, 3, 2, 4 the rank correlation is about 0.948683. Of the 24 permutations, four have an absolute correlation at least this large, giving p = 1/6.
Example you can load
What to enterThis is a fixed example; changing the form above does not change these numbers.
Assumptions & limits
Enter 2–64 paired observations in matching order. Exact permutation testing supports at most eight pairs. Missing cells and constant ranked variables are rejected.
Frequently asked questions
Can the two variables use different units?
Yes. For each variable, only the ordering of observations and groups of exactly equal values affect the correlation coefficient.
How does the exact test handle equal observation values?
The exact option permutes observation positions, including repeated equal values. For every pairing it compares the absolute rank correlation with the observed absolute rank correlation.
Does zero rho imply independence?
No. A strong nonmonotonic relationship may have a small rank correlation. Inspect the paired ranks and the original data.