SpearmanRho

SpearmanRho[v1,v2]

gives Spearman's rank correlation coefficient for the vectors v1 and v2.

SpearmanRho[m]

gives Spearman's rank correlation coefficient for the matrix m.

SpearmanRho[m1,m2]

gives Spearman's rank correlation coefficient for the matrices m1 and m2.

SpearmanRho[dist]

gives Spearman's rank correlation matrix for the multivariate symbolic distribution dist.

SpearmanRho[dist,i,j]

gives the ^(th) Spearman rank correlation for the multivariate symbolic distribution dist.

Details

  • SpearmanRho[v1,v2] gives Spearman's rank correlation coefficient between v1 and v2.
  • Spearman's is a measure of association based on the rank differences between two lists which indicates how well a monotonic function describes their relationship.
  • Spearman's is given by , where is equal to Length[xlist], r_(i) is the rank difference between and , is the correction term for ties in v1, and is the correction term for ties in v2.
  • SpearmanRho[{v11,v12,},{v21,v22,}] is equivalent to Correlation[{r11,r12,},{r21,r22,}] where rij is the tie-corrected ranking corresponding to vij.
  • The arguments v1 and v2 can be any realvalued vectors of equal length.
  • For a matrix m with columns SpearmanRho[m] is a × matrix of the rank correlations between columns of m.
  • For an × matrix m1 and an × matrix m2 SpearmanRho[m1,m2] is a × matrix of the rank correlations between columns of m1 and columns of m2.
  • SpearmanRho[dist,i,j] is 12 Expectation[F[x]G[y],{x,y}disti,j]-3 where F[x] and G[y] are the CDFs of the i^(th) and j^(th) marginals of dist, respectively, and disti,j is the ^(th) marginal of dist.
  • SpearmanRho[dist] gives a matrix where the ^(th) entry is given by SpearmanRho[dist,i,j].

Examples

open allclose all

Basic Examples  (4)

Spearman's for two vectors:

Spearman's for a matrix:

Spearman's for two matrices:

Compute Spearman's for a bivariate distribution:

Compare to a simulated value:

Scope  (7)

Data  (4)

Exact input yields exact output:

Approximate input yields approximate output:

Works with large arrays:

SparseArray data can be used:

Distributions and Processes  (3)

Spearman's for a continuous multivariate distribution:

Spearman's for derived distributions:

Data distribution:

Spearman's for a random process at times s and t:

Applications  (4)

Spearman's is typically used to detect linear dependence between two vectors:

The absolute magnitude of tends to 1 given strong linear dependence:

The value tends to 0 for linearly independent vectors:

Spearman's can be used to measure linear association:

Spearman's can only detect monotonic relationships:

HoeffdingD can be used to detect a variety of dependence structures:

A collection of measurements were taken from a representative sample of new cars in 1993. Because some of the variables are measured at an ordinal scale, Spearman's is more appropriate than Correlation for measuring monotonic association:

A scatter plot matrix of the various metrics:

Spearman's corresponding to the scatter plot matrix:

SpearmanRankTest suggests that vehicles with higher horsepower are more costly:

Higher fuel economy meant lower prices in 1993:

Properties & Relations  (10)

Spearman's ranges from -1 to 1 for high negative and high positive association, respectively:

Spearman's is Correlation applied to ranks:

With no ties, ranks can be computed using ordering:

Spearman's matrix is symmetric:

The diagonal elements of Spearman's matrix are 1:

Spearman's is related to KendallTau:

KendallTau tends to be about of given weak linear association:

Spearman's will attain 1 or -1 if the variables are perfectly monotonically related:

This is in contrast to Correlation, which strictly measures linear association:

Spearman's is less sensitive to outliers than Correlation:

With outliers:

Without outliers:

Use SpearmanRankTest to test for independence:

Alternatively, use IndependenceTest to automatically select an appropriate test:

Use CorrelationTest to test a particular value of Spearman's :

Test against a value of :

Spearman's for a continuous bivariate distribution:

Wolfram Research (2012), SpearmanRho, Wolfram Language function, https://reference.wolfram.com/language/ref/SpearmanRho.html.

Text

Wolfram Research (2012), SpearmanRho, Wolfram Language function, https://reference.wolfram.com/language/ref/SpearmanRho.html.

CMS

Wolfram Language. 2012. "SpearmanRho." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SpearmanRho.html.

APA

Wolfram Language. (2012). SpearmanRho. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SpearmanRho.html

BibTeX

@misc{reference.wolfram_2024_spearmanrho, author="Wolfram Research", title="{SpearmanRho}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/SpearmanRho.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_spearmanrho, organization={Wolfram Research}, title={SpearmanRho}, year={2012}, url={https://reference.wolfram.com/language/ref/SpearmanRho.html}, note=[Accessed: 21-November-2024 ]}