STATISTICAL WORKSHEETS

Comparing perfect rank order with unequal linear spacing

Two increasing lists can agree perfectly on order and still disagree on straight-line fit. This worksheet puts one tiny example through the Spearman and Pearson calculators to show why.

Two coefficients that answer different questions

Pearson's r asks how closely the pairs sit on a single straight line, using the actual numeric distances between values. Spearman's rho first replaces every value with its rank, the position it takes when its list is sorted, and then asks how closely those ranks agree. Because ranks throw away the size of the gaps, rho only cares whether larger x values go with larger y values. Pearson cares about that and also about whether equal steps in x produce equal steps in y. When the two coefficients disagree on the same pairs, the disagreement is information about spacing. This worksheet builds the smallest case where that happens, so each step of both calculations can be checked by hand.

The three pairs and where the spacing breaks

Take x = 1, 2, 3 and y = 1, 2, 100. Moving from the first pair to the second raises y by 1, and moving from the second to the third raises y by 98. Both lists increase at every step, so the order of the x values matches the order of the y values exactly. The gaps in x are equal, while the gaps in y are wildly unequal. A straight line through the first two points would predict a y of 3 at x = 3, yet the observed value is 100. That single large gap is what separates the two summaries, and it appears only in the distance-based one.

How Spearman reaches exactly one

Ranking x = 1, 2, 3 gives ranks 1, 2, 3. Ranking y = 1, 2, 100 also gives ranks 1, 2, 3, since 100 is the largest value and 1 is the smallest. The two rank lists are identical. The page computes Spearman as the Pearson correlation of the ranks, with average ranks assigned to ties, and the Pearson correlation of two identical lists with any spread is 1. The size of the jump from 2 to 100 plays no role at all. Raw floating-point arithmetic can leave a trace such as a final digit slightly off one, which is why the worksheet states the coefficient as mathematically one.

How Pearson arrives at 0.8704

Pearson's r equals Sxy divided by the square root of Sxx times Syy, where each S is a sum over centered values. The mean of x is 2 and the mean of y is 103/3, about 34.333. The centered cross-product Sxy is (-1)(-33.333) + (0)(-32.333) + (1)(65.667), which equals 99. Sxx is 2. Syy is about 6,468.67, so Sxx times Syy is 38,812/3, about 12,937.33, and its square root is about 113.74. Then r = 99 / 113.74, which is approximately 0.8704. The single point at 100 dominates Syy, which pulls r below one even though the order never wavers. Read the 99 in the numerator as the pull toward a positive slope and the denominator as the total variability available to be explained.

A milder gap gives a smaller difference

Replace the last y value with 4, so the pairs are x = 1, 2, 3 and y = 1, 2, 4. The order is still perfect and Spearman is again 1. The y gaps are now 1 and 2 instead of 1 and 98. The centered cross-product is 3, Sxx is 2 and Syy is about 4.667, so r = 3 / sqrt(2 × 4.667), which is approximately 0.982. Pearson moves much closer to Spearman because the spacing is only mildly uneven. If you set y = 1, 2, 3 the spacing is perfectly even and both coefficients equal one. The distance between the two results grows with how unequal the gaps become.

Reversing the order flips the sign for both

Keep x = 1, 2, 3 and use y = 100, 2, 1. Now every increase in x comes with a decrease in y, so the ranks of y are 3, 2, 1 and Spearman returns -1. The centered cross-product becomes -99, so Pearson returns about -0.8704, the same magnitude as before with the opposite sign. Both calculators therefore treat a perfectly reversed order symmetrically. The size gap between the two coefficients is unchanged by the reversal, because it comes from the spacing of the y values and not from the direction of the relationship. A negative Pearson value that is weaker than a perfectly negative Spearman value points to the same kind of uneven spacing.

Choosing which summary fits the question

Use Spearman when the question is about order: do higher-ranked items on one scale tend to be higher-ranked on another, as with survey ratings, race placements or any ordinal data. It also holds up when one extreme value would otherwise dominate the picture. Use Pearson when the question is about a straight-line relationship between measurements, such as predicting y from x with equal steps in both. Reporting both is reasonable when the data contain a very large value. A large difference between them signals that a few points drive the linear summary, and a scatterplot would show which points those are.

What three constructed pairs can and cannot show

The numbers here were chosen to illustrate a calculation, so neither coefficient says anything about causation or about how the pattern would continue beyond the supplied pairs. With only three observations, a coefficient near one can arise from a very small amount of data, and no significance test is attached to it on this page. The worksheet also uses no tied values. When ties exist, the Spearman calculator assigns each tied value the average of the ranks it spans, which can lower rho below one even for data that never reverse. Check your own lists for repeated values before comparing the two coefficients.

A routine for comparing the two on your own pairs

Start by sorting each list and writing down the ranks. If the rank lists match, or match in reverse, Spearman will be 1 or -1 and any shortfall in Pearson comes entirely from spacing. Next, look at the gaps between consecutive sorted values in each list and find the largest one relative to the rest. A gap many times the typical size, like the 98 here, is the usual cause of a wide difference. Then run both calculators with the same x and y text so the pairs line up. If Pearson sits far below Spearman, plot the points and decide whether the extreme value is a real observation or an entry error before choosing a summary.

Reproduce the checks

Rank-based coefficient

Open the Spearman Correlation Calculator and enter:

X observations
1,2,3
Y observations
1,2,100

Expected output:

Rho

1

The exact rank coefficient is one; raw floating-point digits can differ slightly.

Distance-based coefficient

Open the Pearson Correlation Calculator and enter:

X observations
1,2,3
Y observations
1,2,100

Expected output:

R

0.8703878312633371

The independently derived coefficient uses centered cross-product 99 and squared-sum product 38812/3.

References and implementation scope

The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.

Sources

Related tasks