A pair of observations (x1, y1) and (x2, y2) are considered concordant if x1 < x2 and y1 < y2 or x2 < x1 and y2 < y1. The pair is discordant if x1 < x2 and y2 < y1 or x2 < x1 and y1 < y2. If either x1 = x2 or y1 = y2, the pair is neither concordant nor discordant.
Kendall's Tau-b is defined as:
taub = (nc - nd) / sqrt((n0 - n1) * (n0 - n2))
where:
This implementation uses the O(n log n) algorithm described in William R. Knight's 1966 paper "A Computer Method for Calculating Kendall's Tau with Ungrouped Data" in the Journal of the American Statistical Association.
| Modifier and Type | Field and Description |
|---|---|
| private final RealMatrix | correlationMatrix
correlation matrix |
| Access | Constructor and Description |
|---|---|
| public | |
| public | KendallsCorrelation(double[][]
rectangular array with columns representing variables data)Create a KendallsCorrelation from a rectangular array whose columns represent values of variables to be correlated. |
| public | KendallsCorrelation(RealMatrix
matrix with columns representing variables to correlate matrix)Create a KendallsCorrelation from a RealMatrix whose columns represent variables to be correlated. |
| Modifier and Type | Method and Description |
|---|---|
| public RealMatrix | Returns: correlation matrixmatrix with columns representing variables to correlate matrix)Computes the Kendall's Tau rank correlation matrix for the columns of the input matrix. |
| public RealMatrix | Returns: correlation matrixmatrix with columns representing variables to correlate matrix)Computes the Kendall's Tau rank correlation matrix for the columns of the input rectangular array. |
| public double | Returns: Returns Kendall's Tau rank correlation coefficient for the two arraysfirst data array xArray, final double[] second data array yArray)Computes the Kendall's Tau rank correlation coefficient between the two arrays. |
| public RealMatrix | |
| private static long | Returns: the sum of the number from 1 to nthe summation end n)Returns the sum of the number from 1 .. |
| correlationMatrix | back to summary |
|---|---|
| private final RealMatrix correlationMatrix correlation matrix | |
| KendallsCorrelation | back to summary |
|---|---|
| public KendallsCorrelation() Create a KendallsCorrelation instance without data. | |
| KendallsCorrelation | back to summary |
|---|---|
| public KendallsCorrelation(double[][] data) Create a KendallsCorrelation from a rectangular array whose columns represent values of variables to be correlated.
| |
| KendallsCorrelation | back to summary |
|---|---|
| public KendallsCorrelation(RealMatrix matrix) Create a KendallsCorrelation from a RealMatrix whose columns represent variables to be correlated.
| |
| computeCorrelationMatrix | back to summary |
|---|---|
| public RealMatrix computeCorrelationMatrix(final RealMatrix matrix) Computes the Kendall's Tau rank correlation matrix for the columns of the input matrix.
| |
| computeCorrelationMatrix | back to summary |
|---|---|
| public RealMatrix computeCorrelationMatrix(final double[][] matrix) Computes the Kendall's Tau rank correlation matrix for the columns of the input rectangular array. The columns of the array represent values of variables to be correlated.
| |
| correlation | back to summary |
|---|---|
| public double correlation(final double[] xArray, final double[] yArray) throws DimensionMismatchException Computes the Kendall's Tau rank correlation coefficient between the two arrays.
| |
| getCorrelationMatrix | back to summary |
|---|---|
| public RealMatrix getCorrelationMatrix() Returns the correlation matrix.
| |
| sum | back to summary |
|---|---|
| private static long sum(long n) Returns the sum of the number from 1 .. n according to Gauss' summation formula: \[ \sum\limits_{k=1}^n k = \frac{n(n + 1)}{2} \]
| |