Sb8–Sb10 - Spearman's rank and choosing a test

Sb8–Sb10 - Spearman's rank and choosing a test

Calculate Spearman's coefficient from untied ranks, test for population association and choose between the Pearson and Spearman procedures. The shape of the relationship matters as much as the availability of a calculator button.

Ranks and Spearman's coefficient

Can two data sets have exactly the same rank correlation even though their numerical gaps are completely different?

Yes. Ranking remembers order and forgets spacing. That is useful for studying a monotonic relationship, but it deliberately discards some information.

You already know

Pearson's coefficient describes linear correlation. A monotonic relationship tends to increase throughout or decrease throughout; a U-shaped relationship does neither over its full range.

Rank each variable separately, but keep the two ranks for each observation paired. Use the same convention for both variables, such as rank 11 for the smallest value. The calculations here use distinct values: tied ranks are outside this topic's assessed scope.

Spearman's rank correlation coefficient

Spearman's coefficient rsr_s is the pmcc of the two columns of ranks. It measures the direction and strength of monotonic association. It lies between −1-1 and 11, with the extremes representing completely agreeing or completely reversed rank orders.

Your calculator's correlation calculation on the ranked columns gives rsr_s. Entering the raw measurements instead gives Pearson's coefficient for the raw data, a different calculation.

Spearman's coefficient without ties

For nn pairs of untied ranks, let did_i be the difference between the two ranks for observation ii. Then

rs=1−6∑di2n(n2−1)r_s=1-\frac{6\sum d_i^2}{n(n^2-1)}

This is equivalent to calculating the pmcc of the ranks. Rank both variables consistently and preserve the pairs.

In the formula booklet.

The short-cut formula is convenient for summary statistics; a rank table makes detailed reasoning clear.

Worked example 1: ranking raw measurements

Question. Six walks have distances 2,3,5,6,8,10 km2,3,5,6,8,10\,\mathrm{km} and corresponding durations 20,35,50,65,95,8520,35,50,65,95,85 minutes. Find Spearman's coefficient.

Plan. Rank each column from smallest to largest, then calculate the sum of squared paired rank differences.

WalkDistance rankDuration rankddd2d^2
AA11110000
BB22220000
CC33330000
DD44440000
EE5566−1-111
FF66551111
∑d2=2add the squared differencesrs=1−6(2)6(62−1)use n=6=3335=0.943to 3 significant figures\begin{aligned} \sum d^2&=2&&\text{add the squared differences}\\ r_s&=1-\frac{6(2)}{6(6^2-1)}&&\text{use }n=6\\ &=\frac{33}{35}=0.943&&\text{to }3\text{ significant figures} \end{aligned}

Why this step? The final two walks reverse their duration order. Their ranks must remain attached to their own distances.

Answer. rs=3335r_s=\frac{33}{35}, showing strong positive monotonic association in this sample.

Check. The pmcc of rank columns (1,2,3,4,5,6)(1,2,3,4,5,6) and (1,2,3,4,6,5)(1,2,3,4,6,5) is the same value.

Change only the second variable's orientation: record minutes remaining from a 115115-minute allowance instead of minutes used.

Worked example 2: reversing one ordering

Question. For the same walks, the remaining times are 95,80,65,50,20,3095,80,65,50,20,30 minutes. Find Spearman's coefficient between distance and remaining time.

Plan. Keep distance ranks fixed, reverse the duration ordering through the new variable, and calculate again.

WalkDistance rankRemaining-time rankd2d^2
AA11662525
BB225599
CC334411
DD443311
EE55111616
FF66221616
∑d2=68sum the new squared differencesrs=1−6(68)6(35)same number of pairs=−3335=−0.943opposite direction\begin{aligned} \sum d^2&=68&&\text{sum the new squared differences}\\ r_s&=1-\frac{6(68)}{6(35)}&&\text{same number of pairs}\\ &=-\frac{33}{35}=-0.943&&\text{opposite direction} \end{aligned}

Why this step? Longer durations leave less remaining time, so reversing just one ordering reverses the coefficient's sign.

Answer. rs=−3335r_s=-\frac{33}{35}, a strong negative monotonic association in the sample.

Check. Its magnitude matches Example 1. Reversing both rank conventions would preserve a coefficient; reversing only one changes its sign.

To see the information loss in the opening question, compare x=(1,2,3)x=(1,2,3) with either y=(2,3,4)y=(2,3,4) or y=(2,3,100)y=(2,3,100). Both rank columns are (1,2,3)(1,2,3), so both give rs=1r_s=1, despite their very different numerical gaps.

Watch out

Wrong: subtract raw measurements to calculate did_i, or feed raw measurements into the calculator and call its rr “Spearman's”. Right: calculate on the paired ranks.

Use a new ordering, still with no ties.

Testing for population association

Spearman's test does not require a bivariate Normal population model. It still needs suitable paired observations and a defensible sampling or experimental design; removing a distributional assumption does not remove the need for sound data.

Spearman hypotheses

State H0\mathrm{H_0}: no association between the variables in the population. The alternative specifies positive association, negative association or any association in that population. Use “association” for this test, distinguishing it from Pearson's test of linear correlation.

A monotonic pattern is the relevant alternative. For an observational study, a random sample of independent pairs supports inference to its population. Spearman can also be used for an appropriate association question with controlled input levels; it does not require both variables to have a bivariate Normal distribution.

Use the booklet's Spearman table, with the row for the number of pairs, not the Pearson table. For example:

n=8n=8, Spearman tableOne-sided 5%5\%Two-sided 5%5\%
Critical magnitude0.64290.64290.73810.7381

Reject in the positive or negative tail specified by the alternative, or use ∣rs∣|r_s| for a two-sided test. Equality at the critical boundary belongs to the critical region; compare with the precision used by the printed table. Do not interpolate unlisted or blank entries. The critical tables are in the formula booklet.

Continue this lesson.

You’re previewing NovaLearn without an account. Create a free account to read the rest.

Create free account