Why Spearman's rank correlation ranges from from -1 to 1 $$\rho = 1 - \frac{6 \sum d_i^2}{n(n^2 - 1)}$$
$\rho$ = Spearman's rank correlation coefficient
$d_i$ = difference between the two ranks of each observation
$n$ = number of observations
Given the Spearman's rank correlation above, it's clear to see the maximum is 1 as the smallest $d_i$ will be zero. I am trying to figure out why it is -1 by having two ranks in exactly reversed order.
I attach my calculation below, where the red rectangle represents the specific case of four rows, and I ordered two ranks in exactly reverse order.
The purple rectangle is the actual calculation, and it indeed results in -1.
I try to generalize in the green rectangle, but how does that formula result in 2?


See Wikipedia for the definition. Note that Spearman correlation is just the usual Pearson correlation, but calculated using the ranks of the data, not the data itself.
So the reason it is always in the interval $[-1,1]$ is by the same proof as for the Pearson correlation. By using the Cauchy-Schwartz inequality.
