NAME
Statistics::RankCorrelation - Compute the rank correlation between two vectors
SYNOPSIS
use Statistics::RankCorrelation qw(
csim
spearman
correlation_coefficient
);
$n = csim(\@u, \@v);
$n = spearman(\@u, \@v);
$n = correlation_coefficient(\@u, \@v);
DESCRIPTION
This module computes the rank correlation coefficient between two sample vectors.
As an example, this metric is employed in the study of musical contour similarity and "sample agreement".
Okay. Some definitions are always in order:
Statistical rank: The ordinal number of a value in a list arranged in a specified order (usually decreasing).
EXPORTED FUNCTIONS
spearman $VECTOR1, $VECTOR2
$n = spearman($u, $v);
Spearman rank-order correlation is a nonparametric measure of association based on the rank of the data values.
correlation_coefficient $VECTOR1, $VECTOR2
$n = correlation_coefficient($u, $v);
A correlation describes the strength of an association between variables. An association between variables means that the value of one variable can be predicted, to some extent, by the value of the other.
Note: This function "will only work when there is a linear relation between the variables".
csim $VECTOR1, $VECTOR2
$n = csim($u, $v);
Return the "contour similarity index measure", which is a single dimensional measure of the similarity between two vectors.
This returns a measure in the range [-1..1] and is computed using matrices of binary data representing "higher or lower" values in the original vectors.
Please consult the csim
item under the SEE ALSO
section.
PRIVATE FUNCTIONS
_pad_vectors
($u, $v) = _pad_vectors($u, $v);
Append zeros to either input vector for all values in the other that do not have a corresponding value. That is, "pad" the tail of the shorter vector with zero values.
_correlation_matrix
$matrix = _correlation_matrix($u);
Return the correlation matrix for a single vector.
This function builds a square, binary matrix that represents "higher or lower" value within the vector itself.
SEE ALSO
For the csim
function:
http://www2.mdanderson.org/app/ilya/Publications/JNMRcontour.pdf
For the other functions:
http://mathworld.wolfram.com/SpearmanRankCorrelationCoefficient.html
http://faculty.vassar.edu/lowry/ch3b.html
http://www.pinkmonkey.com/studyguides/subjects/stats/chap6/s0606801.asp
http://fonsg3.let.uva.nl/Service/Statistics/RankCorrelation_coefficient.html
TO DO
Remember how to export without using the bloated Exporter
module.
Make a comprehensive test suite with a data file for all functions to use.
Implement other rank correlation measures. Here is a nice survey:
http://jeff-lab.queensu.ca/stat/sas/sasman/sashtml/proc/zompmeth.htm
AUTHOR
Gene Boggs <gene@cpan.org>
COPYRIGHT AND LICENSE
Copyright 2003, Gene Boggs
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.