Class: Rust::Correlation::Kendall
- Defined in:
- lib/rust/stats/correlation.rb
Overview
Kendall correlation utility methods.
Class Method Summary collapse
-
.estimate(d1, d2) ⇒ Object
Returns the Kendall correlation index between
d1
andd2
. -
.test(d1, d2) ⇒ Object
Runs the Kendall correlation test between
d1
andd2
.
Class Method Details
.estimate(d1, d2) ⇒ Object
Returns the Kendall correlation index between d1
and d2
114 115 116 |
# File 'lib/rust/stats/correlation.rb', line 114 def self.estimate(d1, d2) self.test(d1, d2).correlation end |
.test(d1, d2) ⇒ Object
Runs the Kendall correlation test between d1
and d2
.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/rust/stats/correlation.rb', line 90 def self.test(d1, d2) raise TypeError, "Expecting Array of numerics" if !d1.is_a?(Array) || !d1.all? { |e| e.is_a?(Numeric) } raise TypeError, "Expecting Array of numerics" if !d2.is_a?(Array) || !d2.all? { |e| e.is_a?(Numeric) } Rust.exclusive do Rust['correlation.a'] = d1 Rust['correlation.b'] = d2 _, warnings = Rust._eval("correlation.result <- cor.test(correlation.a, correlation.b, method='k')", true) result = Result.new result.name = "Kendall's rank correlation tau" result.statistics['T'] = Rust._pull('correlation.result$statistic') result.pvalue = Rust._pull('correlation.result$p.value') result.correlation = Rust._pull('correlation.result$estimate') result.exact = !warnings.include?("Cannot compute exact p-value with ties") return result end end |