Rank of an observation (source code)

= Rank of an observation
{title2=$r_i$}

= Statistical rank
{synonym}

= Ranks of observations
{synonym}

The <rank of an observation> records where that observation lies among the <order statistics> of a <statistical sample>. When all values are distinct, $r_i=1+\#\{j:x_j<x_i\}$ and $x_i=x_{(r_i)}$. For $(0.7,0.1,0.9,0.4,0.2)$, the <ranks of observations> in original order are $(4,1,5,3,2)$: the first observation is fourth smallest, while the fourth observation is third smallest.

Ties require a convention. A tied block occupying sorted positions $a,\ldots,b$ can assign each member the average <rank of an observation> $(a+b)/2$, the minimum position $a$, or the maximum position $b$; an explicit rule can also break ties into distinct positions. R's official documentation describes these choices and uses average ranks by default. https://stat.ethz.ch/R-manual/R-devel/library/base/html/rank.html[R base documentation: sample ranks and tie methods]{ref}.

For example, $(0.1,0.4,0.4,0.9)$ has <order statistics> $(0.1,0.4,0.4,0.9)$. The two $0.4$ observations occupy positions $2$ and $3$; average <ranks of observations> are $(1,2.5,2.5,4)$, whereas minimum-position ranks are $(1,2,2,4)$. A fractional average rank is a summary of tied positions, rather than an index of one <order statistic>. Without omissions, distinct ranks and average ranks sum to $n(n+1)/2$, since averaging each tied block preserves its sum; minimum-position ranks need not.

<Wilcoxon signed-rank tests> rank the absolute nonzero paired differences, while <Wilcoxon rank sum tests> rank the pooled observations from two samples; these are different rankings.