lib/statsample/reliability.rb in statsample-2.0.2 vs lib/statsample/reliability.rb in statsample-2.1.0
- old
+ new
@@ -2,24 +2,24 @@
module Reliability
class << self
# Calculate Chonbach's alpha for a given dataset.
# only uses tuples without missing data
def cronbach_alpha(ods)
- ds = ods.dup_only_valid
+ ds = ods.reject_values(*Daru::MISSING_VALUES)
n_items = ds.ncols
return nil if n_items <= 1
- s2_items = ds.to_hash.values.inject(0) { |ac,v|
+ s2_items = ds.to_h.values.inject(0) { |ac,v|
ac + v.variance }
total = ds.vector_sum
(n_items.quo(n_items - 1)) * (1 - (s2_items.quo(total.variance)))
end
# Calculate Chonbach's alpha for a given dataset
# using standarized values for every vector.
# Only uses tuples without missing data
# Return nil if one or more vectors has 0 variance
def cronbach_alpha_standarized(ods)
- ds = ods.dup_only_valid
+ ds = ods.reject_values(*Daru::MISSING_VALUES)
return nil if ds.any? { |v| v.variance==0}
ds = Daru::DataFrame.new(
ds.vectors.to_a.inject({}) { |a,i|
a[i] = ods[i].standardize