• incanter

# spearmans-rho

## incanter.stats

• (spearmans-rho a b)

http://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient

In statistics, Spearman's rank correlation coefficient or Spearman's rho, is a non-parametric measure of correlation – that is, it assesses how well an arbitrary monotonic function could describe the relationship between two variables, without making any other assumptions about the particular nature of the relationship between the variables. Certain other measures of correlation are parametric in the sense of being based on possible relationships of a parameterised form, such as a linear relationship.

### Source incanter/stats.clj:2746 top

```(defn spearmans-rho
"
http://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient

In statistics, Spearman's rank correlation coefficient or Spearman's rho, is a non-parametric measure of correlation ‚Äì that is, it assesses how well an arbitrary monotonic function could describe the relationship between two variables, without making any other assumptions about the particular nature of the relationship between the variables. Certain other measures of correlation are parametric in the sense of being based on possible relationships of a parameterised form, such as a linear relationship.
"
[a b]
(let [_ (assert (= (count a) (count b)))
n (count a)
arank (rank-index a)
brank (rank-index b)
dsos (apply
+ (map (fn [x y] (pow
(- (arank x) (brank y))
2))
a b))]
(- 1 (/ (* 6 dsos)
(* n (- (pow n 2) 1))))))```
Vars in incanter.stats/spearmans-rho: * - / defn let
Used in 0 other vars