edu.northwestern.at.utils.math.statistics
Class SpearmanCorr

java.lang.Object
  extended by edu.northwestern.at.utils.math.statistics.SpearmanCorr

public class SpearmanCorr
extends java.lang.Object

SpearmanCorr -- get Spearman rank order correlations for an m x n matrix.


Constructor Summary
protected SpearmanCorr()
          Don't allow instantiation, but do allow subclassing.
 
Method Summary
static double sigSpearmanCorr(double r, int n)
          Calculate approximate significance of Spearman correlation coefficient.
static Matrix spearmanCorr(Matrix dataMatrix)
          Generate a Spearman rank-order correlation matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpearmanCorr

protected SpearmanCorr()
Don't allow instantiation, but do allow subclassing.

Method Detail

spearmanCorr

public static Matrix spearmanCorr(Matrix dataMatrix)
Generate a Spearman rank-order correlation matrix.

Parameters:
dataMatrix - The n x m data matrix for which to compute a Spearman rank-order correlation matrix.
Returns:
The n-by-n correlation matrix.

We calculate Spearman's rank-order correlation coefficient by computing the rank-order of each variable stored as a column in a matrix. Ties are handled by mid-ranking. Computing the usual Pearson correlation on the rank ordered data yields Spearman's correlation coefficient.


sigSpearmanCorr

public static double sigSpearmanCorr(double r,
                                     int n)
Calculate approximate significance of Spearman correlation coefficient.

Parameters:
r - The Spearman correlation coefficient.
n - The sample size.
Returns:
The approximate significance level of the Spearman coefficient.

The approximate significance of Spearman's correlation r is computing using Student's t distribution with ( n - 2 ) degrees of freedom, as follows:

df = n - 2
t = r * sqrt( df / ( 1 - r^2 ) )
sig(r) = sigt( t , df )

If r is exactly one, the significance is returned as zero.