# Can Spearman rank correlation be extended to three dimensions?

Why can we not define a 3D rank correlation as the elongation of the cloud as a proportion of the multidimensional variance as an extension of the 2D rank correlation case as suggested by @gung?

There are several attempted answers to a related question in Spearman's Rank-Order Correlation for higher dimensions. However, those answers appear to skirt the issue. This question is a cleanup and an attempt to collate other questions. Please hold off on changing this question at least until the matter is clarified. If this question is a duplicate, then the two questions it refers to are also duplicates. There have been several other questions posted on this site that could be answered by extending Spearman's rank correlation to 3D:

correlation among variable per observation

Aggregation of Correlations Coefficients (Spearman)

I do not see why it could not be done. Has it? If not, would someone please extend Spearman's rank to 3D, please?

• Possible duplicate of Spearman's Rank-Order Correlation for higher dimensions Oct 25 '16 at 16:45
• Like @NickCox, I'm not sure what you're asking for here. Consider a simpler situation. Say you have multivariate normal data in 3D, what would you want to say then? Some people might want to know the 3x3 variance-covariance matrix, some might want to know the elongation of the cloud as the proportion of the multidimesional variance that is accounted for by the 1st principle component (ie, 1st eigenvalue / 3), some might want to know the determinant, etc. What is it you would want & why, then we can think of how to connect that to this context. Oct 25 '16 at 17:12
• Unfortunately we don't find these questions to be precise. Each asks for an extension. The comments are cycling round and round quite what kind of extension you have in mind. For example, a fairly trivial answer is that you can easily have a matrix of Spearman correlations. Oct 25 '16 at 17:30
• Until you stipulate what property of multidimensional data you are attempting to characterize, this question appears to be too vague to be answerable.
– whuber
Oct 25 '16 at 22:56
• Although I voted to reopen, I have no clue what you might mean by "the most logical": that looks like a subjective criterion. Once again I would request that you attempt to describe what property of the distribution you are hoping to characterize.
– whuber
Oct 26 '16 at 18:15

Since Spearman correlation in 2D is equivalent to the Pearson correlation between the ranks, and since the $$R^2$$ is (well, kind-of) the generalization of the Pearson correlation to multiple regression, maybe we can use the $$R^2$$ of the ranks?

I tried playing with this a bit in R, not sure I can come with any conclusive results.

Remember that Spearman will only find monotonic relations, so the function probably must also be monotonic in each dimension, e.g. $$e^{x+y}$$.

Here's a code example:

x1 = seq(0.01, 10, 0.1)
x2 = seq(0.01, 10, 0.1)
grid <- expand.grid(x1=x1,x2=x2)
y = exp((grid$$x1)/2+(grid$$x2)/2)+ rnorm(length(grid$x1),0,100) library(plotly) z <- y2 dim(z) <- c(100, 100) fig <- plot_ly(x=~x1, y=~x2, z =~z) fig <- fig %>% add_surface() fig # Regular linear-regression mod1 = lm(y ~ grid$$x1 + grid$$x2) summary(mod1)$r.squared #  0.4158116

# Linear regression of the ranks
n   <- length(grid$$x1) rx1 <- rank(grid$$x1)
rx2 <- rank(grid$$x2) ry <- rank(y2) mod2 = lm(ry ~ rx1 + rx2) summary(mod2)$$r.squared  #  0.7485


Though Spearman seems to also be worse, if I increase the variance from 100 to 1000 (0.328 in the regular $$R^2$$, 0.2547 in the $$R^2$$ of the ranks).

If I use a non monotonic function, e.g. $$\sin(\sqrt{x^2+y^2})$$ even without noise both measures seem to be around zero.

I'm reading now a paper by Chatterjee, "A New Coefficient of Correlation", where he introduces an improved rank correlation he denotes as $$\xi$$. He mentions that "Multivariate measures of dependence and conditional dependence inspired by ξn are now available in the preprint (Azadkia and Chatterjee 2019)". So you might want to check these out.

• OK, will look. Rs and monotonicity are not strict. For example, even if one starts with a monotonic function, in simulation noisy results may not be monotonic. True enough, the more monotonic the better.
– Carl
Mar 10 at 0:04