Rankings and Rank Correlations

This package implements various strategies for computing ranks and rank correlations.

StatsBase.ordinalrankFunction
ordinalrank(x; lt=isless, by=identity, rev::Bool=false, ...)

Return the ordinal ranking ("1234" ranking) of an array. Supports the same keyword arguments as the sort function. All items in x are given distinct, successive ranks based on their position in the sorted vector. Missing values are assigned rank missing.

source
StatsBase.competerankFunction
competerank(x; lt=isless, by=identity, rev::Bool=false, ...)

Return the standard competition ranking ("1224" ranking) of an array. Supports the same keyword arguments as the sort function. Equal ("tied") items are given the same rank, and the next rank comes after a gap that is equal to the number of tied items - 1. Missing values are assigned rank missing.

source
StatsBase.denserankFunction
denserank(x; lt=isless, by=identity, rev::Bool=false, ...)

Return the dense ranking ("1223" ranking) of an array. Supports the same keyword arguments as the sort function. Equal items receive the same rank, and the next subsequent rank is assigned with no gap. Missing values are assigned rank missing.

source
StatsBase.tiedrankFunction
tiedrank(x; lt=isless, by=identity, rev::Bool=false, ...)

Return the tied ranking, also called fractional or "1 2.5 2.5 4" ranking, of an array. Supports the same keyword arguments as the sort function. Equal ("tied") items receive the mean of the ranks they would have been assigned under the ordinal ranking (see ordinalrank). Missing values are assigned rank missing.

source
StatsBase.corspearmanFunction
corspearman(x, y=x)

Compute Spearman's rank correlation coefficient. If x and y are vectors, the output is a float, otherwise it's a matrix corresponding to the pairwise correlations of the columns of x and y.

source
StatsBase.corkendallFunction
corkendall(x, y=x)

Compute Kendall's rank correlation coefficient, τ. x and y must both be either matrices or vectors.

source