Tunny Icon
TunnyDocs

The next-gen Grasshopper optimization tool.

Spearman

Overview

Spearman's rank correlation coefficient ρ measures the strength of a monotonic relationship between a parameter x and an objective y. It works on ranks rather than raw values, so it handles non-linear but monotonic relationships and is robust to outliers.

The Importance Chart displays |ρ| (absolute value): it captures how strongly a parameter is related to the objective, regardless of direction.

Formula

Step 1: Convert values to ranks

x=[3.1,1.2,4.5,2.0]\mathbf{x} = [3.1, 1.2, 4.5, 2.0]

rank(x)=[3,1,4,2]\operatorname{rank}(\mathbf{x}) = [3, 1, 4, 2]

Ties receive the average rank:

x=[1.0,2.0,2.0,3.0]    rank(x)=[1,2.5,2.5,4]\mathbf{x} = [1.0, 2.0, 2.0, 3.0] \implies \operatorname{rank}(\mathbf{x}) = [1, 2.5, 2.5, 4]

Here "values" refers to each of the two series being compared (parameter xix_i and objective yy). Ranking is done independently for each series, based on that series' own values: the ranks of xx come from the values of xx, and the ranks of yy from the values of yy. This does not mean reordering the parameters according to the objective values.

The trial correspondence (rows) stays fixed; the xx column and yy column are each converted to ranks independently. This measures whether the rank of xx moves together with the rank of yy (i.e. whether a monotonic relationship exists).

For example, suppose four trials yield the following values (rows — the trial ordering — are fixed):

trial xx yy rank(x)\operatorname{rank}(x) rank(y)\operatorname{rank}(y)
A 3.1 10.0 3 2
B 1.2 30.0 1 4
C 4.5 5.0 4 1
D 2.0 20.0 2 3
rank(x)\operatorname{rank}(x) is determined by the magnitudes in the xx column and rank(y)\operatorname{rank}(y) by those in the yy column, each independently.

Step 2: Apply Pearson correlation to ranks

Let Rx=rank(x)R_x = \operatorname{rank}(x) and Ry=rank(y)R_y = \operatorname{rank}(y) denote the rank series from Step 1. That is, RxiR_{x_i} is the rank of the xx value of the ii-th trial, and RyiR_{y_i} is the rank of the yy value of the same trial. Rˉx\bar{R}_x and Rˉy\bar{R}_y are the means of those rank series (equal to n+12\frac{n+1}{2} when there are no ties).

Pearson's correlation is then computed on these rank series RxR_x and RyR_y:

ρ=Corr(Rx,Ry)=(RxiRˉx)(RyiRˉy)(RxiRˉx)2(RyiRˉy)2\rho = \operatorname{Corr}(R_x, R_y) = \frac{\sum (R_{x_i} - \bar{R}x)(R{y_i} - \bar{R}y)}{\sqrt{\sum (R{x_i} - \bar{R}x)^2 \cdot \sum (R{y_i} - \bar{R}_y)^2}}

For ties-free data this simplifies to:

ρ=16di2n(n21)\rho = 1 - \frac{6 \sum d_i^2}{n(n^2 - 1)}

where di=RxiRyid_i = R_{x_i} - R_{y_i} (difference of ranks).

Aside: What is Pearson's product-moment correlation?

For the definition and properties of the Pearson product-moment correlation used in Step 2, see Pearson product-moment correlation.

Spearman's correlation is simply this measure applied to the rank series instead of the raw values. Because ranks are evenly spaced, looking at the linear co-movement of ranks corresponds to looking at the monotonic co-movement of the original values.

Multiple Objectives

Spearman's ρ is computed independently for each objective yky_k:

ρk(pj)=ρ(pj,yk)\rho_k(p_j) = \rho(p_j, y_k)

There is no cross-objective averaging: the dashboard keeps one score per (parameter, objective) pair. The Importance Chart displays ρk(pj)|\rho_k(p_j)| for the currently selected objective kk only — switching the objective selector recomputes and redraws the scores for that objective.

Characteristics

Strengths:

  • Robust to outliers (uses ranks, not raw values).
  • Detects any monotonic relationship, not just linear.
  • Non-parametric — no distributional assumptions.
  • Very fast: O(n log n).

Limitations:

  • Cannot detect non-monotonic (U-shaped, multi-modal) relationships.
  • Does not capture parameter interactions.
  • No magnitude scale (tells you strength, not direction of effect size).

When to Use

  • Small datasets (n < 50) — still reliable.
  • First pass to screen all parameters.
  • When the shape of the objective function is unknown.

References

  • Spearman, C. (1904). The proof and measurement of association between two things. American Journal of Psychology, 15(1), 72–101. https://doi.org/10.2307/1412159