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:

    StudentStudy hours (X)Grade (Y)
    A102.3
    B82.7
    C63.0
    D44.0
    E25.0

    First, we calculate the ranks:

    StudentXRank XYRank Y
    A1012.31
    B822.72
    C633.03
    D444.04
    E255.05

    We then calculate the rank differences and their squares:

    StudentRank XRank Yd_i = R(X) – R(Y)d_i^2
    A1100
    B2200
    C3300
    D4400
    E5500

    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).

    PersonHours of sport (X)Satisfaction (Y)
    A89
    B67
    C56
    D45
    E34
    F28
    G13

    Calculate the ranks:

    PersonXRank XYRank Y
    A8191
    B6273
    C5364
    D4455
    E3546
    F2682
    G1737

    Calculate rank differences:

    PersonRank XRank Yd_i = R(X) – R(Y)d_i^2
    A1100
    B23-11
    C34-11
    D45-11
    E56-11
    F62416
    G7700

    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:

    1. Select Analyze > Correlate > Bivariate.
    2. Drag the variables of interest into the input fields.
    3. 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:

    1. Go to Analyze > Correlations > Bivariate.
    2. Select the variables to be analyzed.
    3. 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:

    1. Load your data and select Regression > Correlations.
    2. Drag the desired variables into the analysis field.
    3. 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!

    Stelle Dominik eine Frage