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 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], 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 real‐valued 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 and j marginals of dist, respectively, and disti,j is the marginal of dist.
- SpearmanRho[dist] gives a matrix where the entry is given by SpearmanRho[dist,i,j].
Examples
open allclose allBasic Examples (4)
Scope (7)
Data (4)
Exact input yields exact output:
Approximate input yields approximate output:
SparseArray data can be used:
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:
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 :
Spearman's is related to KendallTau:
KendallTau tends to be about of given weak linear association:
Spearman's will attain or 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:
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 :
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