statsample 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/History.txt +7 -0
  3. data/README.md +2 -4
  4. data/Rakefile +6 -0
  5. data/benchmarks/correlation_matrix_methods/correlation_matrix.rb +0 -1
  6. data/examples/correlation_matrix.rb +0 -16
  7. data/examples/dataset.rb +0 -7
  8. data/examples/dominance_analysis_bootstrap.rb +0 -6
  9. data/examples/reliability.rb +0 -2
  10. data/lib/statsample.rb +3 -2
  11. data/lib/statsample/anova/oneway.rb +1 -1
  12. data/lib/statsample/bivariate.rb +4 -4
  13. data/lib/statsample/converter/spss.rb +1 -1
  14. data/lib/statsample/crosstab.rb +3 -3
  15. data/lib/statsample/daru.rb +1 -3
  16. data/lib/statsample/factor/parallelanalysis.rb +1 -3
  17. data/lib/statsample/formula/fit_model.rb +46 -0
  18. data/lib/statsample/formula/formula.rb +306 -0
  19. data/lib/statsample/matrix.rb +0 -2
  20. data/lib/statsample/regression.rb +1 -3
  21. data/lib/statsample/regression/multiple/alglibengine.rb +1 -1
  22. data/lib/statsample/regression/multiple/gslengine.rb +1 -1
  23. data/lib/statsample/regression/multiple/rubyengine.rb +1 -3
  24. data/lib/statsample/reliability.rb +3 -3
  25. data/lib/statsample/reliability/icc.rb +1 -2
  26. data/lib/statsample/reliability/multiscaleanalysis.rb +0 -1
  27. data/lib/statsample/reliability/scaleanalysis.rb +2 -3
  28. data/lib/statsample/reliability/skillscaleanalysis.rb +1 -1
  29. data/lib/statsample/test/levene.rb +4 -4
  30. data/lib/statsample/test/t.rb +10 -10
  31. data/lib/statsample/test/umannwhitney.rb +3 -3
  32. data/lib/statsample/version.rb +1 -1
  33. data/statsample.gemspec +4 -1
  34. data/test/fixtures/df.csv +15 -0
  35. data/test/helpers_tests.rb +7 -0
  36. data/test/test_factor.rb +0 -5
  37. data/test/test_factor_pa.rb +1 -6
  38. data/test/test_fit_model.rb +88 -0
  39. data/test/test_reliability.rb +0 -10
  40. data/test/test_statistics.rb +1 -1
  41. metadata +52 -48
@@ -21,7 +21,6 @@ class ::Matrix
21
21
  row_size.times {|i|
22
22
  ds.add_row(self.row(i).to_a)
23
23
  }
24
- ds.update
25
24
  ds.rename(self.name) if self.respond_to? :name
26
25
  ds
27
26
  end
@@ -95,7 +94,6 @@ module GSL
95
94
  row_size.times {|i|
96
95
  ds.add_row(self.row(i).to_a)
97
96
  }
98
- ds.update
99
97
  ds.rename(self.name) if self.respond_to? :name
100
98
  ds
101
99
  end
@@ -15,8 +15,6 @@ module Statsample
15
15
  #
16
16
  # * Simple Regression : Statsample::Regression::Simple
17
17
  # * Multiple Regression: Statsample::Regression::Multiple
18
- # * Logit Regression: Statsample::Regression::Binomial::Logit
19
- # * Probit Regression: Statsample::Regression::Binomial::Probit
20
18
  module Regression
21
19
 
22
20
  LinearDependency=Class.new(Exception)
@@ -58,7 +56,7 @@ module Statsample
58
56
  if Statsample.has_gsl? and false
59
57
  Statsample::Regression::Multiple::GslEngine.new(ds, y_var, opts)
60
58
  else
61
- ds2=ds.dup_only_valid
59
+ ds2=ds.reject_values(*Daru::MISSING_VALUES)
62
60
  Statsample::Regression::Multiple::RubyEngine.new(ds2,y_var, opts)
63
61
  end
64
62
  end
@@ -19,7 +19,7 @@ module Multiple
19
19
  class AlglibEngine < BaseEngine
20
20
  def initialize(ds,y_var, opts=Hash.new)
21
21
  super
22
- @ds = ds.dup_only_valid
22
+ @ds = ds.reject_values(*Daru::MISSING_VALUES)
23
23
  @ds_valid = @ds
24
24
  @dy = @ds[@y_var]
25
25
  @ds_indep = ds.dup(ds.vectors.to_a - [y_var])
@@ -19,7 +19,7 @@ if Statsample.has_gsl?
19
19
  class GslEngine < BaseEngine
20
20
  def initialize(ds,y_var, opts=Hash.new)
21
21
  super
22
- @ds = ds.dup_only_valid
22
+ @ds = ds.reject_values(*Daru::MISSING_VALUES)
23
23
  @ds_valid = @ds
24
24
  @valid_cases = @ds_valid.nrows
25
25
  @dy = @ds[@y_var]
@@ -30,7 +30,7 @@ class RubyEngine < MatrixEngine
30
30
  super(matrix, y_var, opts)
31
31
  @ds = ds
32
32
  @dy = ds[@y_var]
33
- @ds_valid = ds.dup_only_valid
33
+ @ds_valid = ds.reject_values(*Daru::MISSING_VALUES)
34
34
  @total_cases = @ds.nrows
35
35
  @valid_cases = @ds_valid.nrows
36
36
  @ds_indep = ds.dup(ds.vectors.to_a - [y_var])
@@ -55,7 +55,6 @@ class RubyEngine < MatrixEngine
55
55
  end
56
56
  i += 1
57
57
  end
58
- @ds_indep.update
59
58
  set_dep_columns
60
59
  end
61
60
  def fix_with_regression
@@ -75,7 +74,6 @@ class RubyEngine < MatrixEngine
75
74
  end
76
75
  i+=1
77
76
  end
78
- @ds_indep.update
79
77
  set_dep_columns
80
78
  end
81
79
  # Standard error for constant
@@ -4,10 +4,10 @@ module Statsample
4
4
  # Calculate Chonbach's alpha for a given dataset.
5
5
  # only uses tuples without missing data
6
6
  def cronbach_alpha(ods)
7
- ds = ods.dup_only_valid
7
+ ds = ods.reject_values(*Daru::MISSING_VALUES)
8
8
  n_items = ds.ncols
9
9
  return nil if n_items <= 1
10
- s2_items = ds.to_hash.values.inject(0) { |ac,v|
10
+ s2_items = ds.to_h.values.inject(0) { |ac,v|
11
11
  ac + v.variance }
12
12
  total = ds.vector_sum
13
13
 
@@ -18,7 +18,7 @@ module Statsample
18
18
  # Only uses tuples without missing data
19
19
  # Return nil if one or more vectors has 0 variance
20
20
  def cronbach_alpha_standarized(ods)
21
- ds = ods.dup_only_valid
21
+ ds = ods.reject_values(*Daru::MISSING_VALUES)
22
22
  return nil if ds.any? { |v| v.variance==0}
23
23
 
24
24
  ds = Daru::DataFrame.new(
@@ -96,8 +96,7 @@ module Statsample
96
96
  attr_accessor :alpha
97
97
  attr_accessor :name
98
98
  def initialize(ds, opts=Hash.new)
99
- ds.update
100
- @ds=ds.dup_only_valid
99
+ @ds=ds.reject_values(*Daru::MISSING_VALUES)
101
100
  @vectors=@ds.map { |e| e }
102
101
  @n=@ds.nrows
103
102
  @k=@ds.ncols
@@ -128,7 +128,6 @@ module Statsample
128
128
  ds[code.to_sym] = scale.ds.vector_sum
129
129
  end
130
130
 
131
- ds.update
132
131
  ds
133
132
  end
134
133
 
@@ -21,7 +21,7 @@ module Statsample
21
21
  }
22
22
 
23
23
  @ods = ds
24
- @ds = ds.dup_only_valid(ds.vectors.to_a - @dumped)
24
+ @ds = ds.reject_values(*Daru::MISSING_VALUES).dup(ds.vectors.to_a - @dumped)
25
25
  @ds.rename ds.name
26
26
 
27
27
  @k = @ds.ncols
@@ -117,11 +117,10 @@ module Statsample
117
117
  ds_new = Daru::DataFrame.new({}, order: ([:case,:score] + dif_sort.collect{|a,b| a.to_sym}))
118
118
  scores_sort.each do |i,score|
119
119
  row = [i, score]
120
- case_row = @ds.row[i].to_hash
120
+ case_row = @ds.row[i].to_h
121
121
  dif_sort.each{ |variable,dif_value| row.push(case_row[variable]) }
122
122
  ds_new.add_row(row)
123
123
  end
124
- ds_new.update
125
124
  ds_new
126
125
  end
127
126
 
@@ -63,7 +63,7 @@ module Statsample
63
63
  out = {}
64
64
  row.each_with_index do |v, k|
65
65
  if @key.has_key? k
66
- if @ds[k].exists? v
66
+ if @ds[k].reject_values(*Daru::MISSING_VALUES).include_values? v
67
67
  out[k]= @key[k] == v ? 1 : 0
68
68
  else
69
69
  out[k] = nil
@@ -30,7 +30,7 @@ module Statsample
30
30
  # Input could be an array of vectors or a dataset
31
31
  def initialize(input, opts=Hash.new())
32
32
  if input.is_a? Daru::DataFrame
33
- @vectors = input.to_hash.values
33
+ @vectors = input.to_h.values
34
34
  else
35
35
  @vectors = input
36
36
  end
@@ -48,7 +48,7 @@ module Statsample
48
48
  builder.text "%s : F(%d, %d) = %0.4f , p = %0.4f" % [@name, @d1, @d2, f, probability]
49
49
  end
50
50
  def compute
51
- n=@vectors.inject(0) { |ac,v| ac + v.n_valid}
51
+ n=@vectors.inject(0) { |ac,v| ac + v.reject_values(*Daru::MISSING_VALUES).size }
52
52
 
53
53
  zi=@vectors.collect do |vector|
54
54
  mean=vector.mean
@@ -57,7 +57,7 @@ module Statsample
57
57
 
58
58
  total_mean = Daru::Vector.new(
59
59
  zi.inject([]) do |ac,vector|
60
- ac + vector.only_valid(:array)
60
+ ac + vector.reject_values(*Daru::MISSING_VALUES).to_a
61
61
  end
62
62
  ).mean
63
63
 
@@ -68,7 +68,7 @@ module Statsample
68
68
 
69
69
  sum_den = zi.inject(0) do |ac,vector|
70
70
  z_mean = vector.mean
71
- ac + vector.only_valid(:array).inject(0) do |acp,zij|
71
+ ac + vector.reject_values(*Daru::MISSING_VALUES).to_a.inject(0) do |acp,zij|
72
72
  acp + (zij - z_mean)**2
73
73
  end
74
74
  end
@@ -163,11 +163,11 @@ module Statsample
163
163
  @u=@opts[:u]
164
164
  @tails=@opts[:tails]
165
165
  @confidence_level=@opts[:confidence_level] || 0.95
166
- @df= @vector.n_valid-1
166
+ @df= @vector.reject_values(*Daru::MISSING_VALUES).size-1
167
167
  @t=nil
168
168
  end
169
169
  def t_object
170
- T.new(@vector.mean-u, @vector.se, @vector.n_valid-1, opts)
170
+ T.new(@vector.mean-u, @vector.se, @vector.reject_values(*Daru::MISSING_VALUES).size-1, opts)
171
171
  end
172
172
  def t
173
173
  t_object.t
@@ -264,12 +264,12 @@ module Statsample
264
264
 
265
265
  # Set t and probability for given u
266
266
  def compute
267
- @t_equal_variance= T.two_sample_independent(@v1.mean, @v2.mean, @v1.sd, @v2.sd, @v1.n_valid, @v2.n_valid,true)
267
+ @t_equal_variance= T.two_sample_independent(@v1.mean, @v2.mean, @v1.sd, @v2.sd, @v1.reject_values(*Daru::MISSING_VALUES).size, @v2.reject_values(*Daru::MISSING_VALUES).size,true)
268
268
 
269
- @t_not_equal_variance= T.two_sample_independent(@v1.mean, @v2.mean, @v1.sd, @v2.sd, @v1.n_valid, @v2.n_valid, false)
269
+ @t_not_equal_variance= T.two_sample_independent(@v1.mean, @v2.mean, @v1.sd, @v2.sd, @v1.reject_values(*Daru::MISSING_VALUES).size, @v2.reject_values(*Daru::MISSING_VALUES).size, false)
270
270
 
271
- @df_equal_variance=T.df_equal_variance(@v1.n_valid, @v2.n_valid)
272
- @df_not_equal_variance=T.df_not_equal_variance(@v1.sd, @v2.sd, @v1.n_valid, @v2.n_valid)
271
+ @df_equal_variance=T.df_equal_variance(@v1.reject_values(*Daru::MISSING_VALUES).size, @v2.reject_values(*Daru::MISSING_VALUES).size)
272
+ @df_not_equal_variance=T.df_not_equal_variance(@v1.sd, @v2.sd, @v1.reject_values(*Daru::MISSING_VALUES).size, @v2.reject_values(*Daru::MISSING_VALUES).size)
273
273
 
274
274
  @probability_equal_variance = p_using_cdf(Distribution::T.cdf(@t_equal_variance, @df_equal_variance), tails)
275
275
 
@@ -278,8 +278,8 @@ module Statsample
278
278
  end
279
279
  # Cohen's d is a measure of effect size. Its defined as the difference between two means divided by a standard deviation for the data
280
280
  def d
281
- n1=@v1.n_valid
282
- n2=@v2.n_valid
281
+ n1=@v1.reject_values(*Daru::MISSING_VALUES).size
282
+ n2=@v2.reject_values(*Daru::MISSING_VALUES).size
283
283
  num=@v1.mean-@v2.mean
284
284
  den=Math::sqrt( ((n1-1)*@v1.sd+(n2-1)*@v2.sd).quo(n1+n2))
285
285
  num.quo(den)
@@ -288,8 +288,8 @@ module Statsample
288
288
  def report_building(b) # :nodoc:
289
289
  b.section(:name=>@name) {|g|
290
290
  g.table(:name=>_("Mean and standard deviation"), :header=>[_("Variable"), _("mean"), _("sd"),_("n")]) {|t|
291
- t.row([@v1.name,"%0.4f" % @v1.mean,"%0.4f" % @v1.sd, @v1.n_valid])
292
- t.row([@v2.name,"%0.4f" % @v2.mean,"%0.4f" % @v2.sd, @v2.n_valid])
291
+ t.row([@v1.name,"%0.4f" % @v1.mean,"%0.4f" % @v1.sd, @v1.reject_values(*Daru::MISSING_VALUES).size])
292
+ t.row([@v2.name,"%0.4f" % @v2.mean,"%0.4f" % @v2.sd, @v2.reject_values(*Daru::MISSING_VALUES).size])
293
293
  }
294
294
  g.parse_element(Statsample::Test.levene([@v1,@v2],:name=>_("Levene test for equality of variances")))
295
295
 
@@ -118,8 +118,8 @@ module Statsample
118
118
  def initialize(v1,v2, opts=Hash.new)
119
119
  @v1 = v1
120
120
  @v2 = v2
121
- v1_valid = v1.only_valid.reset_index!
122
- v2_valid = v2.only_valid.reset_index!
121
+ v1_valid = v1.reject_values(*Daru::MISSING_VALUES).reset_index!
122
+ v2_valid = v2.reject_values(*Daru::MISSING_VALUES).reset_index!
123
123
  @n1 = v1_valid.size
124
124
  @n2 = v2_valid.size
125
125
  data = Daru::Vector.new(v1_valid.to_a + v2_valid.to_a)
@@ -172,7 +172,7 @@ module Statsample
172
172
  # == Reference:
173
173
  # * http://europe.isixsigma.com/library/content/c080806a.asp
174
174
  def adjust_for_ties(data)
175
- @t = data.frequencies.find_all { |k,v| v > 1 }.inject(0) { |a,v|
175
+ @t = data.frequencies.to_h.find_all { |k,v| v > 1 }.inject(0) { |a,v|
176
176
  a + (v[1]**3 - v[1]).quo(12)
177
177
  }
178
178
  end
@@ -1,3 +1,3 @@
1
1
  module Statsample
2
- VERSION = '2.0.2'
2
+ VERSION = '2.1.0'
3
3
  end
@@ -60,7 +60,7 @@ Gem::Specification.new do |s|
60
60
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
61
61
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
62
62
 
63
- s.add_runtime_dependency 'daru', '~> 0.1'
63
+ s.add_runtime_dependency 'daru', '~> 0.1.6'
64
64
  s.add_runtime_dependency 'spreadsheet', '~> 1.1'
65
65
  s.add_runtime_dependency 'reportbuilder', '~> 1.4'
66
66
  s.add_runtime_dependency 'minimization', '~> 0.2'
@@ -81,4 +81,7 @@ Gem::Specification.new do |s|
81
81
  s.add_development_dependency 'mocha', '~> 1.1'
82
82
  s.add_development_dependency 'nmatrix', '~> 0.2.1'
83
83
  s.add_development_dependency 'gsl', '~> 2.1'
84
+ s.add_development_dependency 'pry'
85
+ s.add_development_dependency 'rubocop'
86
+ s.add_development_dependency 'activesupport', '~> 4.2'
84
87
  end
@@ -0,0 +1,15 @@
1
+ y,a,b,c,d,e
2
+ 0,6,62.1,no,female,A
3
+ 1,18,34.7,yes,male,B
4
+ 1,6,29.7,no,female,C
5
+ 0,4,71,no,male,C
6
+ 1,5,36.9,yes,male,B
7
+ 0,11,58.7,no,female,B
8
+ 0,8,63.3,no,male,B
9
+ 1,21,20.4,yes,male,A
10
+ 1,2,20.5,yes,male,C
11
+ 0,11,59.2,no,male,B
12
+ 0,1,76.4,yes,female,A
13
+ 0,8,71.7,no,female,B
14
+ 1,2,77.5,no,male,C
15
+ 1,3,31.1,no,male,B
@@ -30,6 +30,13 @@ module Minitest
30
30
  end
31
31
 
32
32
  module Assertions
33
+ def assert_vectors_from_formula(formula, names)
34
+ model = Statsample::FitModel.new formula, @df
35
+
36
+ model.df_for_regression.vectors.to_a.sort
37
+ .must_equal names.sort
38
+ end
39
+
33
40
  def assert_similar_vector(exp, obs, delta = 1e-10, msg = nil)
34
41
  msg ||= "Different vectors #{exp} - #{obs}"
35
42
  assert_equal(exp.size, obs.size)
@@ -7,19 +7,14 @@ class StatsampleFactorTestCase < Minitest::Test
7
7
  # Based on Hardle and Simar
8
8
  def setup
9
9
  @fixtures_dir = File.expand_path(File.dirname(__FILE__) + '/fixtures')
10
- Daru.lazy_update = true
11
10
  end
12
11
 
13
- def teardown
14
- Daru.lazy_update = false
15
- end
16
12
  # Based on Hurdle example
17
13
  def test_covariance_matrix
18
14
  ds = Daru::DataFrame.from_plaintext(@fixtures_dir + '/bank2.dat', [:v1,:v2,:v3,:v4,:v5,:v6])
19
15
  ds.vectors.each {|f|
20
16
  ds[f] = ds[f].center
21
17
  }
22
- ds.update
23
18
  cm = Statsample::Bivariate.covariance_matrix ds
24
19
  pca = Statsample::Factor::PCA.new(cm, m: 6)
25
20
  # puts pca.summary
@@ -7,11 +7,6 @@ class StatsampleFactorTestCase < Minitest::Test
7
7
  # Based on Hardle and Simar
8
8
  def setup
9
9
  @fixtures_dir = File.expand_path(File.dirname(__FILE__) + '/fixtures')
10
- Daru.lazy_update = true
11
- end
12
-
13
- def teardown
14
- Daru.lazy_update = false
15
10
  end
16
11
 
17
12
  def test_parallelanalysis_with_data
@@ -44,7 +39,7 @@ class StatsampleFactorTestCase < Minitest::Test
44
39
  pa2 = Statsample::Factor::ParallelAnalysis.with_random_data(samples, variables, iterations: iterations, percentil: 95)
45
40
  3.times do |n|
46
41
  var = "ev_0000#{n + 1}".to_sym
47
- assert_in_delta(pa1.ds_eigenvalues[var].mean, pa2.ds_eigenvalues[var].mean, 0.05)
42
+ assert_in_delta(pa1.ds_eigenvalues[var].mean, pa2.ds_eigenvalues[var].mean, 0.07)
48
43
  end
49
44
  else
50
45
  skip('Too slow without GSL')
@@ -0,0 +1,88 @@
1
+ require(File.expand_path(File.dirname(__FILE__) + '/helpers_tests.rb'))
2
+ require 'minitest/autorun'
3
+
4
+ describe Statsample::FitModel do
5
+ before do
6
+ @df = Daru::DataFrame.from_csv 'test/fixtures/df.csv'
7
+ @df.to_category 'c', 'd', 'e'
8
+ end
9
+ context '#df_for_regression' do
10
+ context 'no interaction' do
11
+ it { assert_vectors_from_formula 'y~a+e', %w[a e_B e_C y] }
12
+ end
13
+
14
+ context '2-way interaction' do
15
+ context 'interaction of numerical with numerical' do
16
+ context 'none reoccur' do
17
+ it { assert_vectors_from_formula 'y~a:b', %w[a:b y] }
18
+ end
19
+
20
+ context 'one reoccur' do
21
+ it { assert_vectors_from_formula 'y~a+a:b', %w[a a:b y] }
22
+ end
23
+
24
+ context 'both reoccur' do
25
+ it { assert_vectors_from_formula 'y~a+b+a:b', %w[a a:b b y] }
26
+ end
27
+ end
28
+
29
+ context 'interaction of category with numerical' do
30
+ context 'none reoccur' do
31
+ it { assert_vectors_from_formula 'y~a:e', %w[e_A:a e_B:a e_C:a y] }
32
+ end
33
+
34
+ context 'one reoccur' do
35
+ context 'numeric occur' do
36
+ it { assert_vectors_from_formula 'y~a+a:e', %w[a e_B:a e_C:a y] }
37
+ end
38
+
39
+ context 'category occur' do
40
+ it { assert_vectors_from_formula 'y~e+a:e',
41
+ %w[e_B e_C e_A:a e_B:a e_C:a y] }
42
+ end
43
+ end
44
+
45
+ context 'both reoccur' do
46
+ it { assert_vectors_from_formula 'y~a+e+a:e',
47
+ %w[a e_B e_C e_B:a e_C:a y] }
48
+ end
49
+ end
50
+
51
+ context 'interaction of category with category' do
52
+ context 'none reoccur' do
53
+ it { assert_vectors_from_formula 'y~c:e',
54
+ %w[e_B e_C c_yes:e_A c_yes:e_B c_yes:e_C y] }
55
+ end
56
+
57
+ context 'one reoccur' do
58
+ it { assert_vectors_from_formula 'y~e+c:e',
59
+ %w[e_B e_C c_yes:e_A c_yes:e_B c_yes:e_C y] }
60
+ end
61
+
62
+ context 'both reoccur' do
63
+ it { assert_vectors_from_formula 'y~c+e+c:e',
64
+ %w[c_yes e_B e_C c_yes:e_B c_yes:e_C y] }
65
+ end
66
+ end
67
+ end
68
+
69
+ context 'corner case' do
70
+ context 'example 1' do
71
+ it { assert_vectors_from_formula 'y~d:a+d:e',
72
+ %w[e_B e_C d_male:e_A d_male:e_B d_male:e_C d_female:a d_male:a y] }
73
+ end
74
+ end
75
+
76
+ context 'complex examples' do
77
+ context 'random example 1' do
78
+ it { assert_vectors_from_formula 'y~a+e+c:d+e:d',
79
+ %w[e_B e_C d_male c_yes:d_female c_yes:d_male e_B:d_male e_C:d_male a y] }
80
+ end
81
+
82
+ context 'random example 2' do
83
+ it { assert_vectors_from_formula 'y~e+b+c+d:e+b:e+a:e+0',
84
+ %w[e_A e_B e_C c_yes d_male:e_A d_male:e_B d_male:e_C b e_B:b e_C:b e_A:a e_B:a e_C:a y] }
85
+ end
86
+ end
87
+ end
88
+ end
@@ -1,14 +1,6 @@
1
1
  require(File.expand_path(File.dirname(__FILE__) + '/helpers_tests.rb'))
2
2
  class StatsampleReliabilityTestCase < Minitest::Test
3
3
  context Statsample::Reliability do
4
- setup do
5
- Daru.lazy_update = true
6
- end
7
-
8
- teardown do
9
- Daru.lazy_update = false
10
- end
11
-
12
4
  should 'return correct r according to Spearman-Brown prophecy' do
13
5
  r = 0.6849
14
6
  n = 62.quo(15)
@@ -29,14 +21,12 @@ class StatsampleReliabilityTestCase < Minitest::Test
29
21
  @ds[i] = Daru::Vector.new(base.collect { |v| v + rand })
30
22
  end
31
23
 
32
- @ds.update
33
24
  @k = @ds.ncols
34
25
  @cm = Statsample::Bivariate.covariance_matrix(@ds)
35
26
  @dse = @ds.dup
36
27
  @dse.vectors.each do |f|
37
28
  @dse[f] = @dse[f].standardize
38
29
  end
39
- @dse.update
40
30
  @cme = Statsample::Bivariate.covariance_matrix(@dse)
41
31
  @a = Statsample::Reliability.cronbach_alpha(@ds)
42
32
  @as = Statsample::Reliability.cronbach_alpha_standarized(@ds)