1.2.3-SNAPSHOT permalink Arrow_down_16x16

kendalls-tau

incanter.stats

  • (kendalls-tau a b)

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source incanter/stats.clj:2789 top

(defn kendalls-tau
"
http://en.wikipedia.org/wiki/Kendall_tau_rank_correlation_coefficient
http://www.statsdirect.com/help/nonparametric_methods/kend.htm
http://mail.scipy.org/pipermail/scipy-dev/2009-March/011589.html
best explanation and example is in \"cluster analysis for researchers\" page 165.
http://www.amazon.com/Cluster-Analysis-Researchers-Charles-Romesburg/dp/1411606175
"
[a b]
(let [_ (assert (= (count a) (count b)))
      n (count a)
      ranked (reverse (sort-map (zipmap a b)))
      ;;dcd is the meat of the calculation, the difference between the doncordant and discordant pairs
      dcd (second
           (reduce
           (fn [[vals total] [k v]]
             (let [diff (- (count (filter #(> % v) vals))
                           (count (filter #(< % v) vals)))]
               [(conj vals v) (+ total diff)]))
           [[] 0]
           ranked))]
(/ (* 2 dcd)
   (* n (- n 1)))))
Vars in incanter.stats/kendalls-tau: * - / defn let
Used in 0 other vars

Comments top

No comments for kendalls-tau. Log in to add a comment.