statsample 0.14.1 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,9 @@ module Statsample
18
18
  @ds=ds.dup_only_valid
19
19
  @k=@ds.fields.size
20
20
  @total=@ds.vector_sum
21
- @item_mean=@ds.vector_mean.mean
21
+ @vector_mean=@ds.vector_mean
22
+ @item_mean=@vector_mean.mean
23
+ @item_sd=@vector_mean.sd
22
24
  @mean=@total.mean
23
25
  @median=@total.median
24
26
  @skew=@total.skew
@@ -115,8 +117,11 @@ module Statsample
115
117
  }
116
118
  end
117
119
  end
120
+ # =Adjusted R.P.B. for each item
121
+ # Adjusted RPB(Point biserial-correlation) for each item
122
+ #
118
123
  def item_total_correlation
119
- @ds.fields.inject({}) do |a,v|
124
+ @itc||=@ds.fields.inject({}) do |a,v|
120
125
  vector=@ds[v].clone
121
126
  ds2=@ds.clone
122
127
  ds2.delete_vector(v)
@@ -125,6 +130,9 @@ module Statsample
125
130
  a
126
131
  end
127
132
  end
133
+ def mean_rpb
134
+ item_total_correlation.values.to_scale.mean
135
+ end
128
136
  def item_statistics
129
137
  @is||=@ds.fields.inject({}) do |a,v|
130
138
  a[v]={:mean=>@ds[v].mean, :sds=>Math::sqrt(@cov_m.variance(v))}
@@ -183,20 +191,24 @@ module Statsample
183
191
  t.row [_("Sum median"), @median]
184
192
  t.hr
185
193
  t.row [_("Item mean"), "%0.4f" % @item_mean]
194
+ t.row [_("Item sd"), "%0.4f" % @item_sd]
195
+ t.hr
186
196
  t.row [_("Skewness"), "%0.4f" % @skew]
187
197
  t.row [_("Kurtosis"), "%0.4f" % @kurtosis]
188
198
  t.hr
189
199
  t.row [_("Cronbach's alpha"), "%0.4f" % @alpha]
190
200
  t.row [_("Standarized Cronbach's alpha"), "%0.4f" % @alpha_standarized]
201
+ t.row [_("Mean rpb"), "%0.4f" % mean_rpb]
202
+
191
203
  t.row [_("Variances mean"), "%g" % @variances_mean]
192
204
  t.row [_("Covariances mean") , "%g" % @covariances_mean]
193
205
  end
194
- s.text _("items for obtain alpha(0.8) : %d" % Statsample::Reliability::n_for_desired_alpha(0.8, @variances_mean,@covariances_mean))
195
- s.text _("items for obtain alpha(0.9) : %d" % Statsample::Reliability::n_for_desired_alpha(0.9, @variances_mean,@covariances_mean))
196
- itc=item_total_correlation
206
+ s.text _("Items for obtain alpha(0.8) : %d" % Statsample::Reliability::n_for_desired_reliability(@alpha, 0.8, @ds.fields.size))
207
+ s.text _("Items for obtain alpha(0.9) : %d" % Statsample::Reliability::n_for_desired_reliability(@alpha, 0.9, @ds.fields.size))
208
+
197
209
  sid=stats_if_deleted
198
210
  is=item_statistics
199
-
211
+ itc=item_total_correlation
200
212
 
201
213
 
202
214
  s.table(:name=>_("Items report for %s") % @name, :header=>["item","mean","sd", "mean if deleted", "var if deleted", "sd if deleted"," item-total correl.", "alpha if deleted"]) do |t|
@@ -1,6 +1,11 @@
1
1
  module Statsample
2
2
  # Several methods to estimate parameters for simple random sampling
3
+ # == Reference:
4
+ # * Cochran, W.(1972). Sampling Techniques [spanish edition].
5
+ # * http://stattrek.com/Lesson6/SRS.aspx
6
+
3
7
  module SRS
8
+
4
9
  class << self
5
10
  ########################
6
11
  #
@@ -71,7 +76,6 @@ module Statsample
71
76
  # Know proportion, sample without replacement.
72
77
  #
73
78
  # Sources:
74
- # * http://stattrek.com/Lesson6/SRS.aspx
75
79
  # * Cochran(1972)
76
80
  def proportion_sd_kp_wor(p, sam, pop)
77
81
  fpc(sam,pop)*Math::sqrt(p*(1-p).quo(sam))
@@ -32,7 +32,6 @@ module Statsample
32
32
  extend self
33
33
  # Calculate chi square for two Matrix
34
34
  class << self
35
-
36
35
  def chi_square(observed, expected=nil)
37
36
  case observed
38
37
  when Vector
@@ -41,7 +40,7 @@ module Statsample
41
40
  ChiSquare::WithMatrix.new(observed,expected)
42
41
  else
43
42
  raise "Not implemented for #{observed.class}"
44
- end
43
+ end
45
44
  end
46
45
  # Shorthand for Statsample::Test::UMannWhitney.new
47
46
  #
@@ -41,7 +41,11 @@ module Statsample
41
41
  p_using_cdf(Distribution::F.cdf(f, @df_num, @df_den), tails)
42
42
  end
43
43
  def report_building(builder) #:nodoc:
44
- builder.text "%s : F(%d, %d) = %0.4f , p = %0.4f" % [@name, @df_num, @df_den, f, probability]
44
+ if @df_num.is_a? Integer and @df_den.is_a? Integer
45
+ builder.text "%s : F(%d, %d) = %0.4f , p = %0.4f" % [@name, @df_num, @df_den, f, probability]
46
+ else
47
+ builder.text "%s : F(%0.2f, %0.2f) = %0.4f , p = %0.4f" % [@name, @df_num, @df_den, f, probability]
48
+ end
45
49
  end
46
50
  end
47
51
  end
@@ -25,7 +25,7 @@ module Statsample
25
25
  # Parameters:
26
26
  # * <tt>n1</tt>: group 1 size
27
27
  # * <tt>n2</tt>: group 2 size
28
- # Reference:
28
+ # == Reference:
29
29
  # * Dinneen, L., & Blakesley, B. (1973). Algorithm AS 62: A Generator for the Sampling Distribution of the Mann- Whitney U Statistic. <em>Journal of the Royal Statistical Society, 22</em>(2), 269-273
30
30
  #
31
31
  def self.u_sampling_distribution_as62(n1,n2)
@@ -169,7 +169,7 @@ module Statsample
169
169
  end
170
170
  # Adjunt for ties.
171
171
  #
172
- # Reference:
172
+ # == Reference:
173
173
  # * http://europe.isixsigma.com/library/content/c080806a.asp
174
174
  def adjust_for_ties(data)
175
175
  @t=data.frequencies.find_all{|k,v| v>1}.inject(0) {|a,v|
@@ -182,7 +182,7 @@ module Statsample
182
182
  # Z value for U, with adjust for ties.
183
183
  # For large samples, U is approximately normally distributed.
184
184
  # In that case, you can use z to obtain probabily for U.
185
- # Reference:
185
+ # == Reference:
186
186
  # * SPSS Manual
187
187
  def z
188
188
  mu=(@n1*@n2).quo(2)
@@ -361,7 +361,7 @@ module Statsample
361
361
  sum.push(nil)
362
362
  end
363
363
  }
364
- Statsample::Vector.new(sum)
364
+ Statsample::Vector.new(sum, :scale )
365
365
  else
366
366
  raise ArgumentError, "The array/vector parameter should be of the same size of the original vector"
367
367
  end
@@ -373,8 +373,7 @@ module Statsample
373
373
  else
374
374
  nil
375
375
  end
376
- }
377
- )
376
+ } , :scale)
378
377
  else
379
378
  raise TypeError,"You should pass a scalar or a array/vector"
380
379
  end
@@ -761,7 +760,6 @@ module Statsample
761
760
  m||=mean
762
761
  @scale_data.inject(0){|a,x| a+(x-m).square}
763
762
  end
764
-
765
763
  # Sum of squared deviation
766
764
  def sum_of_squared_deviation
767
765
  check_type :scale
@@ -0,0 +1,22 @@
1
+ References
2
+ * Azen, R. & Budescu, D.V. (2003). The dominance analysis approach for comparing predictors in multiple regression. <em>Psychological Methods, 8</em>(2), 129-148.
3
+ * Azen, R. & Budescu, D.V. (2006). Comparing predictors in Multivariate Regression Models: An extension of Dominance Analysis. <em>Journal of Educational and Behavioral Statistics, 31</em>(2), 157-180.
4
+ * Budescu, D. V. (1993). Dominance analysis: a new approach to the problem of relative importance of predictors in multiple regression. <em>Psychological Bulletin, 114</em>, 542-551.
5
+ * Cochran(1972)
6
+ * Cohen et al. (2003). Applied Multiple Reggression / Correlation Analysis for the Behavioral Sciences
7
+ * Dinneen, L., & Blakesley, B. (1973). Algorithm AS 62: A Generator for the Sampling Distribution of the Mann- Whitney U Statistic. <em>Journal of the Royal Statistical Society, 22</em>(2), 269-273
8
+ * Dziuban, C., & Shirkey E. (1974). When is a correlation matrix appropriate for factor analysis? Some decision rules. Psychological Bulletin, 81(6), 358-361.
9
+ * Hayton, J., Allen, D. & Scarpello, V.(2004). Factor Retention Decisions in Exploratory Factor Analysis: a Tutorial on Parallel Analysis. <i>Organizational Research Methods, 7</i> (2), 191-205.
10
+ * Lin, J. (2007). VARIMAX_K58 [Source code]. [http://www.johnny-lin.com/idl_code/varimax_k58.pro]
11
+ * Liu, O., & Rijmen, F. (2008). A modified procedure for parallel analysis of ordered categorical data. Behavior Research Methods, 40(2), 556-562.
12
+ * McGraw, K. & Wong, S.P. (1996). Forming Inferences About Some Intraclass Correlation Coefficients. Psychological methods, 1(1), 30-46.
13
+ * O'Connor, B. (2000). SPSS and SAS programs for determining the number of components using parallel analysis and Velicer's MAP test. Behavior Research Methods, Instruments, & Computers, 32(3), 396-402.
14
+ * SPSS Manual
15
+ * Shrout,P. & Fleiss, J. (1979). Intraclass Correlation: Uses in assessing rater reliability. Psychological Bulletin, 86(2), 420-428
16
+ * Smith, L. (2002). A tutorial on Principal Component Analysis. Available on http://courses.eas.ualberta.ca/eas570/pca_tutorial.pdf
17
+ * http://en.wikipedia.org/wiki/Welch-Satterthwaite_equation
18
+ * http://europe.isixsigma.com/library/content/c080806a.asp
19
+ * http://snippets.dzone.com/posts/show/4666
20
+ * http://stattrek.com/Lesson6/SRS.aspx
21
+ * http://www.cut-the-knot.org/do_you_know/AllPerm.shtml
22
+ * http://www.gnu.org/software/gsl/manual/html_node/The-histogram-struct.html
@@ -1,12 +1,12 @@
1
1
  require(File.dirname(__FILE__)+'/helpers_tests.rb')
2
2
 
3
3
  class StatsampleBivariateTestCase < MiniTest::Unit::TestCase
4
- def test_sum_of_squares
4
+ should "method sum of squares should be correct" do
5
5
  v1=[1,2,3,4,5,6].to_vector(:scale)
6
6
  v2=[6,2,4,10,12,8].to_vector(:scale)
7
7
  assert_equal(23.0, Statsample::Bivariate.sum_of_squares(v1,v2))
8
8
  end
9
- def test_covariance
9
+ should "return same covariance with ruby and gls implementation" do
10
10
  if Statsample.has_gsl?
11
11
  v1=20.times.collect {|a| rand()}.to_scale
12
12
  v2=20.times.collect {|a| rand()}.to_scale
@@ -17,7 +17,7 @@ class StatsampleBivariateTestCase < MiniTest::Unit::TestCase
17
17
 
18
18
  end
19
19
 
20
- def test_gsl_pearson
20
+ should "return same correlation with ruby and gls implementation" do
21
21
  if Statsample.has_gsl?
22
22
  v1=20.times.collect {|a| rand()}.to_scale
23
23
  v2=20.times.collect {|a| rand()}.to_scale
@@ -27,7 +27,7 @@ class StatsampleBivariateTestCase < MiniTest::Unit::TestCase
27
27
  skip "Not tested gsl versus ruby correlation (needs GSL)"
28
28
  end
29
29
  end
30
- def test_pearson
30
+ should "return correct pearson correlation" do
31
31
  v1=[6,5,4,7,8,4,3,2].to_vector(:scale)
32
32
  v2=[2,3,7,8,6,4,3,2].to_vector(:scale)
33
33
  assert_in_delta(0.525,Statsample::Bivariate.pearson(v1,v2), 0.001)
@@ -40,7 +40,7 @@ class StatsampleBivariateTestCase < MiniTest::Unit::TestCase
40
40
  v3a,v4a=Statsample.only_valid v3, v4
41
41
  assert_in_delta(0.525, Statsample::Bivariate.pearson_slow(v3a,v4a),0.001)
42
42
  end
43
- def test_bivariate_pearson
43
+ should "return correct values for t_pearson and prop_pearson" do
44
44
  v1=[6,5,4,7,8,4,3,2].to_vector(:scale)
45
45
  v2=[2,3,7,8,6,4,3,2].to_vector(:scale)
46
46
  r=Statsample::Bivariate::Pearson.new(v1,v2)
@@ -49,7 +49,7 @@ class StatsampleBivariateTestCase < MiniTest::Unit::TestCase
49
49
  assert_in_delta(Statsample::Bivariate.prop_pearson(r.t,8,:both), r.probability, 0.001)
50
50
  assert(r.summary.size>0)
51
51
  end
52
- def test_matrix_correlation
52
+ should "return correct correlation_matrix" do
53
53
  v1=[6,5,4,7,8,4,3,2].to_vector(:scale)
54
54
  v2=[2,3,7,8,6,4,3,2].to_vector(:scale)
55
55
  v3=[6,2, 1000,1000,5,4,7,8].to_vector(:scale)
@@ -69,7 +69,7 @@ class StatsampleBivariateTestCase < MiniTest::Unit::TestCase
69
69
  end
70
70
  #assert_equal(expected,obt)
71
71
  end
72
- def test_prop_pearson
72
+ should "return correct value for prop pearson" do
73
73
  assert_in_delta(0.42, Statsample::Bivariate.prop_pearson(Statsample::Bivariate.t_r(0.084,94), 94),0.01)
74
74
  assert_in_delta(0.65, Statsample::Bivariate.prop_pearson(Statsample::Bivariate.t_r(0.046,95), 95),0.01)
75
75
  r=0.9
@@ -87,13 +87,13 @@ class StatsampleBivariateTestCase < MiniTest::Unit::TestCase
87
87
  assert(Statsample::Bivariate.prop_pearson(t,n,:left)<0.05)
88
88
  end
89
89
 
90
- def test_spearman
90
+ should "return correct value for Spearman's rho" do
91
91
  v1=[86,97,99,100,101,103,106,110,112,113].to_vector(:scale)
92
92
  v2=[0,20,28,27,50,29,7,17,6,12].to_vector(:scale)
93
93
  assert_in_delta(-0.175758,Statsample::Bivariate.spearman(v1,v2),0.0001)
94
94
 
95
95
  end
96
- def test_point_biserial
96
+ should "return correct value for point_biserial correlation" do
97
97
  c=[1,3,5,6,7,100,200,300,400,300].to_vector(:scale)
98
98
  d=[1,1,1,1,1,0,0,0,0,0].to_vector(:scale)
99
99
  assert_raises TypeError do
@@ -101,7 +101,7 @@ class StatsampleBivariateTestCase < MiniTest::Unit::TestCase
101
101
  end
102
102
  assert_in_delta(Statsample::Bivariate.point_biserial(d,c), Statsample::Bivariate.pearson(d,c), 0.0001)
103
103
  end
104
- def test_tau
104
+ should "return correct value for tau_a and tau_b" do
105
105
  v1=[1,2,3,4,5,6,7,8,9,10,11].to_vector(:ordinal)
106
106
  v2=[1,3,4,5,7,8,2,9,10,6,11].to_vector(:ordinal)
107
107
  assert_in_delta(0.6727,Statsample::Bivariate.tau_a(v1,v2),0.001)
@@ -110,7 +110,7 @@ class StatsampleBivariateTestCase < MiniTest::Unit::TestCase
110
110
  v2=[11,4,4,2,0,0,0,0,0,0,4,0,4,0,0,0,0,4,0,0,0,0,0].to_vector(:ordinal)
111
111
  assert_in_delta(-0.376201540231705, Statsample::Bivariate.tau_b(Statsample::Crosstab.new(v1,v2).to_matrix),0.001)
112
112
  end
113
- def test_gamma
113
+ should "return correct value for gamma correlation" do
114
114
  m=Matrix[[10,5,2],[10,15,20]]
115
115
  assert_in_delta(0.636,Statsample::Bivariate.gamma(m),0.001)
116
116
  m2=Matrix[[15,12,6,5],[12,8,10,8],[4,6,9,10]]
@@ -1,6 +1,16 @@
1
1
  require(File.dirname(__FILE__)+'/helpers_tests.rb')
2
2
  class StatsampleReliabilityTestCase < MiniTest::Unit::TestCase
3
3
  context Statsample::Reliability do
4
+ should "return correct r according to Spearman-Brown prophecy" do
5
+ r=0.6849
6
+ n=62.quo(15)
7
+ assert_in_delta(0.9, Statsample::Reliability.sbp(r,n), 0.001)
8
+ end
9
+ should "return correct n for desired realiability" do
10
+ r=0.6849
11
+ r_d=0.9
12
+ assert_in_delta(62, Statsample::Reliability.n_for_desired_reliability(r, r_d, 15),0.5)
13
+ end
4
14
  context "Cronbach's alpha" do
5
15
  setup do
6
16
  @samples=40
@@ -44,6 +54,7 @@ class StatsampleReliabilityTestCase < MiniTest::Unit::TestCase
44
54
  #p n_obtained
45
55
  assert_in_delta(Statsample::Reliability.cronbach_alpha_from_n_s2_cov(n_obtained, vm,cm) ,@a,0.001)
46
56
  end
57
+
47
58
  should "standarized alpha will be equal to sum of matrix covariance less the individual variances on standarized values" do
48
59
  total_sum=@cme.total_sum
49
60
  ind_var=@dse.fields.inject(0) {|ac,v| ac+@dse[v].variance}
@@ -0,0 +1,188 @@
1
+ $reliability_icc=nil
2
+ require(File.dirname(__FILE__)+'/helpers_tests.rb')
3
+ class StatsampleReliabilityIccTestCase < MiniTest::Unit::TestCase
4
+ context Statsample::Reliability::ICC do
5
+ setup do
6
+ a=[9,6,8,7,10,6].to_scale
7
+ b=[2,1,4,1,5,2].to_scale
8
+ c=[5,3,6,2,6,4].to_scale
9
+ d=[8,2,8,6,9,7].to_scale
10
+ @ds={'a'=>a,'b'=>b,'c'=>c,'d'=>d}.to_dataset
11
+ @icc=Statsample::Reliability::ICC.new(@ds)
12
+ end
13
+ should "basic method be correct" do
14
+ assert_equal(6,@icc.n)
15
+ assert_equal(4,@icc.k)
16
+ end
17
+ should "total mean be correct" do
18
+ assert_in_delta(5.291, @icc.total_mean, 0.001)
19
+ end
20
+ should "df methods be correct" do
21
+ assert_equal(5, @icc.df_bt)
22
+ assert_equal(18, @icc.df_wt)
23
+ assert_equal(3, @icc.df_bj)
24
+ assert_equal(15, @icc.df_residual)
25
+ end
26
+ should "ms between targets be correct" do
27
+ assert_in_delta(11.24, @icc.ms_bt, 0.01)
28
+ end
29
+ should "ms within targets be correct" do
30
+ assert_in_delta(6.26, @icc.ms_wt, 0.01)
31
+ end
32
+ should "ms between judges be correct" do
33
+ assert_in_delta(32.49, @icc.ms_bj, 0.01)
34
+ end
35
+ should "ms residual be correct" do
36
+ assert_in_delta(1.02, @icc.ms_residual, 0.01)
37
+ end
38
+ context "with McGraw and Wong denominations," do
39
+
40
+ end
41
+ context "with Shrout & Fleiss denominations, " do
42
+ should "icc(1,1) method be correct" do
43
+ assert_in_delta(0.17, @icc.icc_1_1, 0.01)
44
+ end
45
+ # Verified on SPSS and R
46
+ should "icc(2,1) method be correct" do
47
+ assert_in_delta(0.29, @icc.icc_2_1, 0.01)
48
+ end
49
+ should "icc(3,1) method be correct" do
50
+ assert_in_delta(0.71, @icc.icc_3_1, 0.01)
51
+ end
52
+ should "icc(1,k) method be correct" do
53
+ assert_in_delta(0.44, @icc.icc_1_k, 0.01)
54
+ end
55
+ # Verified on SPSS and R
56
+ should "icc(2,k) method be correct" do
57
+ assert_in_delta(0.62, @icc.icc_2_k, 0.01)
58
+ end
59
+ should "icc(3,k) method be correct" do
60
+ assert_in_delta(0.91, @icc.icc_3_k, 0.01)
61
+ end
62
+
63
+ should "icc(1,1) F be correct" do
64
+ assert_in_delta(1.795, @icc.icc_1_f.f)
65
+ end
66
+ should "icc(1,1) confidence interval should be correct" do
67
+ assert_in_delta(-0.133, @icc.icc_1_1_ci[0], 0.001)
68
+ assert_in_delta(0.723, @icc.icc_1_1_ci[1], 0.001)
69
+ end
70
+ should "icc(1,k) confidence interval should be correct" do
71
+ assert_in_delta(-0.884, @icc.icc_1_k_ci[0], 0.001)
72
+ assert_in_delta(0.912, @icc.icc_1_k_ci[1], 0.001)
73
+ end
74
+
75
+ should "icc(2,1) F be correct" do
76
+ assert_in_delta(11.027, @icc.icc_2_f.f)
77
+ end
78
+ should "icc(2,1) confidence interval should be correct" do
79
+ #skip("Not yet operational")
80
+ assert_in_delta(0.019, @icc.icc_2_1_ci[0], 0.001)
81
+ assert_in_delta(0.761, @icc.icc_2_1_ci[1], 0.001)
82
+ end
83
+
84
+ # Verified on SPSS and R
85
+ should "icc(2,k) confidence interval should be correct" do
86
+ #skip("Not yet operational")
87
+ #p @icc.icc_2_k_ci
88
+ assert_in_delta(0.039, @icc.icc_2_k_ci[0], 0.001)
89
+ assert_in_delta(0.929, @icc.icc_2_k_ci[1], 0.001)
90
+
91
+ end
92
+ #should "Shrout icc(2,k) and McGraw icc(a,k) ci be equal" do
93
+ # assert_in_delta(@icc.icc_2_k_ci_shrout[0], @icc.icc_2_k_ci_mcgraw[0], 10e-5)
94
+ #end
95
+
96
+ should "icc(3,1) F be correct" do
97
+ assert_in_delta(11.027, @icc.icc_3_f.f)
98
+ end
99
+
100
+ should "icc(3,1) confidence interval should be correct" do
101
+ assert_in_delta(0.342, @icc.icc_3_1_ci[0], 0.001)
102
+ assert_in_delta(0.946, @icc.icc_3_1_ci[1], 0.001)
103
+ end
104
+ should "icc(3,k) confidence interval should be correct" do
105
+ assert_in_delta(0.676, @icc.icc_3_k_ci[0], 0.001)
106
+ assert_in_delta(0.986, @icc.icc_3_k_ci[1], 0.001)
107
+ end
108
+ end
109
+
110
+ begin
111
+ require 'rserve'
112
+ require 'statsample/rserve_extension'
113
+ context "McGraw and Wong" do
114
+ setup do
115
+ if($reliability_icc.nil?)
116
+ size=100
117
+ a=size.times.map {rand(10)}.to_scale
118
+ b=a.recode{|i|i+rand(4)-2}
119
+ c=a.recode{|i|i+rand(4)-2}
120
+ d=a.recode{|i|i+rand(4)-2}
121
+ @ds={'a'=>a,'b'=>b,'c'=>c,'d'=>d}.to_dataset
122
+
123
+
124
+
125
+ @icc=Statsample::Reliability::ICC.new(@ds)
126
+ @r=Rserve::Connection.new
127
+ @r.assign('ds',@ds)
128
+ @r.void_eval("library(irr);
129
+ iccs=list(
130
+ icc_1=icc(ds,'o','c','s'),
131
+ icc_k=icc(ds,'o','c','a'),
132
+ icc_c_1=icc(ds,'t','c','s'),
133
+ icc_c_k=icc(ds,'t','c','a'),
134
+ icc_a_1=icc(ds,'t','a','s'),
135
+ icc_a_k=icc(ds,'t','a','a'))
136
+ ")
137
+ @iccs=@r.eval('iccs').to_ruby
138
+ $reliability_icc={ :icc=>@icc, :iccs=>@iccs
139
+ }
140
+ end
141
+ @icc=$reliability_icc[:icc]
142
+ @iccs=$reliability_icc[:iccs]
143
+
144
+ end
145
+ [:icc_1, :icc_k, :icc_c_1, :icc_c_k, :icc_a_1, :icc_a_k].each do |t|
146
+ context "ICC Type #{t}" do
147
+ should "value be correct" do
148
+ @icc.type=t
149
+ @r_icc=@iccs[t.to_s]
150
+ assert_in_delta(@r_icc['value'],@icc.r)
151
+ end
152
+ should "fvalue be correct" do
153
+ @icc.type=t
154
+ @r_icc=@iccs[t.to_s]
155
+ assert_in_delta(@r_icc['Fvalue'],@icc.f.f)
156
+ end
157
+ should "num df be correct" do
158
+ @icc.type=t
159
+ @r_icc=@iccs[t.to_s]
160
+ assert_in_delta(@r_icc['df1'],@icc.f.df_num)
161
+ end
162
+ should "den df be correct" do
163
+ @icc.type=t
164
+ @r_icc=@iccs[t.to_s]
165
+ assert_in_delta(@r_icc['df2'],@icc.f.df_den)
166
+ end
167
+
168
+ should "f probability be correct" do
169
+ @icc.type=t
170
+ @r_icc=@iccs[t.to_s]
171
+ assert_in_delta(@r_icc['p.value'],@icc.f.probability)
172
+ end
173
+ should "bounds be equal" do
174
+ @icc.type=t
175
+ @r_icc=@iccs[t.to_s]
176
+ assert_in_delta(@r_icc['lbound'],@icc.lbound)
177
+ assert_in_delta(@r_icc['ubound'],@icc.ubound)
178
+
179
+ end
180
+ end
181
+ end
182
+ end
183
+ rescue
184
+ puts "requires rserve"
185
+ end
186
+
187
+ end
188
+ end