Spearman’s rank correlation
Spearman’s rank correlation is one of the best-known measures for assessing the relationship between two variables when the data are ordinally scaled or not normally distributed.
What is Spearman’s rank correlation?
Spearman’s rank correlation, often abbreviated as ρ (rho) or r with a subscript s, is a non-parametric (i.e., distribution-free) measure of association. It measures the strength and direction of the relationship between two variables based on their ranks rather than their absolute values. This makes it robust to outliers and suitable for non-normally distributed data.
The range of values is between -1 and +1:
- +1: Perfect positive relationship (higher values for variable A are associated with higher values for variable B).
- -1: Perfect negative relationship (higher values for variable A are associated with lower values for variable B).
- 0: No relationship.
Absolute values around 0.3 indicate weak rank correlations, values around 0.5 indicate moderate rank correlations, and values around 0.7 indicate strong rank correlations.
When interpreting the result, you should consider the direction (positive/negative), the strength (absolute value), and, where applicable, statistical significance.
When is Spearman’s rank correlation used?
Spearman’s rank correlation is used when:
- The data are measured on an ordinal scale (e.g., school grades, rankings).
- The data are not normally distributed, but you want to examine a relationship.
- There are outliers in the data that could distort the result of a parametric test such as Pearson’s correlation.
Examples:
- The relationship between satisfaction with a product (measured on a scale from 1 to 5) and the likelihood of recommending it.
- Comparing students’ performance in two different exams based on their ranking positions.
Advantages and limitations
Advantages:
- Robust against outliers.
- Suitable for ordinal data.
- Easy to interpret.
Limitations:
- It does not provide any information about causal relationships.
How is Spearman’s rank correlation calculated?
Procedure
The calculation is carried out in five steps:
Convert the data into ranks: The values of the two variables X and Y are transformed into ranks. In the case of ties (identical values), each value is assigned the average rank.
Calculate rank differences: For each pair of values, the difference between the ranks of X and Y is calculated:

Square the rank differences: The rank differences d are squared:

Apply the formula: Spearman’s rank correlation is calculated using:

Interpret the results: A positive value indicates a positive relationship, while a negative value indicates a negative relationship.
An example with a perfect rank correlation
Suppose we want to examine whether there is a relationship between the number of hours students study (X) and their exam grade (Y). The data could look like this:
| Student | Study hours (X) | Grade (Y) |
|---|---|---|
| A | 10 | 2.3 |
| B | 8 | 2.7 |
| C | 6 | 3.0 |
| D | 4 | 4.0 |
| E | 2 | 5.0 |
First, we calculate the ranks:
| Student | X | Rank X | Y | Rank Y |
|---|---|---|---|---|
| A | 10 | 1 | 2.3 | 1 |
| B | 8 | 2 | 2.7 | 2 |
| C | 6 | 3 | 3.0 | 3 |
| D | 4 | 4 | 4.0 | 4 |
| E | 2 | 5 | 5.0 | 5 |
We then calculate the rank differences and their squares:
| Student | Rank X | Rank Y | d_i = R(X) – R(Y) | d_i^2 |
|---|---|---|---|---|
| A | 1 | 1 | 0 | 0 |
| B | 2 | 2 | 0 | 0 |
| C | 3 | 3 | 0 | 0 |
| D | 4 | 4 | 0 | 0 |
| E | 5 | 5 | 0 | 0 |
The sum of:

We then calculate the actual rank correlation:

In this case, there is a perfect positive relationship (which you can already notice beforehand when you sort the X and Y columns).
An example of a weak rank correlation
We examine the relationship between the number of hours of sport per week (X) and satisfaction with one’s own fitness (Y) on a scale from 1 (very dissatisfied) to 10 (very satisfied).
| Person | Hours of sport (X) | Satisfaction (Y) |
|---|---|---|
| A | 8 | 9 |
| B | 6 | 7 |
| C | 5 | 6 |
| D | 4 | 5 |
| E | 3 | 4 |
| F | 2 | 8 |
| G | 1 | 3 |
Calculate the ranks:
| Person | X | Rank X | Y | Rank Y |
|---|---|---|---|---|
| A | 8 | 1 | 9 | 1 |
| B | 6 | 2 | 7 | 3 |
| C | 5 | 3 | 6 | 4 |
| D | 4 | 4 | 5 | 5 |
| E | 3 | 5 | 4 | 6 |
| F | 2 | 6 | 8 | 2 |
| G | 1 | 7 | 3 | 7 |
Calculate rank differences:
| Person | Rank X | Rank Y | d_i = R(X) – R(Y) | d_i^2 |
|---|---|---|---|---|
| A | 1 | 1 | 0 | 0 |
| B | 2 | 3 | -1 | 1 |
| C | 3 | 4 | -1 | 1 |
| D | 4 | 5 | -1 | 1 |
| E | 5 | 6 | -1 | 1 |
| F | 6 | 2 | 4 | 16 |
| G | 7 | 7 | 0 | 0 |

Calculate rank correlation:
The formula is:

Substituting the values:

Spearman’s rank correlation is r_s = 0.357, indicating a weak positive relationship between the number of hours of exercise and satisfaction with fitness.
This example shows that although satisfaction with fitness tends to increase with more hours of exercise, there are also some deviations (e.g., Person F).
Calculate Spearman’s rank correlation with R
In R, Spearman’s rank correlation can be calculated easily using the cor() function. The method parameter must be set to "spearman". Example:
# Daten
x <- c(8, 6, 5, 4, 3, 2, 1)
y <- c(9, 7, 6, 5, 4, 8, 3)
# Spearman-Korrelation
cor(x, y, method = "spearman")
The result provides the rank correlation coefficient. For larger datasets, you can also use data frames.
Calculating Spearman’s Rank Correlation with SPSS
In SPSS, you can calculate Spearman’s rank correlation via the menus:
- Select Analyze > Correlate > Bivariate.
- Drag the variables of interest into the input fields.
- Select the Spearman checkbox and click OK. The result appears in the output view and displays the correlation matrix with the Spearman coefficients.
Calculating Spearman’s Rank Correlation with PSPP
In PSPP, the open-source alternative to SPSS, the calculation is similar:
- Go to Analyze > Correlations > Bivariate.
- Select the variables to be analyzed.
- Select Spearman as the correlation type and click OK. The results are displayed in the output, analogous to SPSS.
Calculating Spearman’s Rank Correlation with JASP
In JASP, calculating Spearman’s rank correlation is particularly intuitive:
- Load your data and select Regression > Correlations.
- Drag the desired variables into the analysis field.
- Select the Spearman option. The result appears directly as a table and can be exported together with the visualization.
Conclusion
Spearman’s rank correlation is a versatile and easy-to-use measure for analyzing relationships between two ordinal variables or non-normally distributed metric data. It provides a valuable alternative to parametric methods such as Pearson correlation and is particularly useful in social and behavioral research.
Alles klar?
Ich hoffe, der Beitrag war für dich soweit verständlich. Wenn du weitere Fragen hast, nutze bitte hier die Möglichkeit, eine Frage an mich zu stellen!
