T
- public class KendallTauRankCorrelation<T extends RealType<T>> extends Algorithm<T>
According to this article, Tau-b (appropriate if multiple pairs share the same first, or second, value), the rank correlation of a set of pairs (x_1, y_1), ..., (x_n, y_n):
Tau_B = (n_c - n_d) / sqrt( (n_0 - n_1) (n_0 - n_2) )where
n_0 = n (n - 1) / 2 n_1 = sum_i t_i (t_i - 1) / 2 n_2 = sum_j u_j (u_j - 1) / 2 n_c = #{ i, j; i != j && (x_i - x_j) * (y_i - y_j) > 0 }, i.e. the number of pairs of pairs agreeing on the order of x and y, respectively n_d = #{ i, j: i != j && (x_i - x_j) * (y_i - y_j) < 0 }, i.e. the number of pairs of pairs where x and y are ordered opposite of each other t_i = number of tied values in the i-th group of ties for the first quantity u_j = number of tied values in the j-th group of ties for the second quantity
Constructor and Description |
---|
KendallTauRankCorrelation() |
Modifier and Type | Method and Description |
---|---|
static <T extends RealType<T>> |
calculateMergeSort(PairIterator<T> iterator)
Calculate Tau-b efficiently.
|
static <T extends RealType<T>> |
calculateNaive(PairIterator<T> iterator) |
void |
execute(DataContainer<T> container)
Executes the previously initialized
Algorithm . |
void |
processResults(ResultHandler<T> handler)
A method to give the algorithm the opportunity to let
its results being processed by the passed handler.
|
addWarning, getName, getWarnings
public void execute(DataContainer<T> container) throws MissingPreconditionException
Algorithm
Algorithm
.public static <T extends RealType<T>> double calculateNaive(PairIterator<T> iterator)
public static <T extends RealType<T>> double calculateMergeSort(PairIterator<T> iterator)
This implementation is based on this description of the merge sort based way to calculate Tau-b. This is supposed to be the method described in:
Knight, W. (1966). "A Computer Method for Calculating Kendall's Tau with Ungrouped Data". Journal of the American Statistical Association 61 (314): 436–439. doi:10.2307/2282833.
but since that article is not available as Open Access, it is unnecessarily hard to verify.
iterator
- the iterator of the pairspublic void processResults(ResultHandler<T> handler)
Algorithm
processResults
in class Algorithm<T extends RealType<T>>
handler
- The ResultHandler to process the results.Copyright © 2015–2021 Fiji. All rights reserved.