test/test_reliability.rb in statsample-0.14.1 vs test/test_reliability.rb in statsample-0.15.0

- old
+ new

@@ -1,8 +1,18 @@ require(File.dirname(__FILE__)+'/helpers_tests.rb') class StatsampleReliabilityTestCase < MiniTest::Unit::TestCase context Statsample::Reliability do + should "return correct r according to Spearman-Brown prophecy" do + r=0.6849 + n=62.quo(15) + assert_in_delta(0.9, Statsample::Reliability.sbp(r,n), 0.001) + end + should "return correct n for desired realiability" do + r=0.6849 + r_d=0.9 + assert_in_delta(62, Statsample::Reliability.n_for_desired_reliability(r, r_d, 15),0.5) + end context "Cronbach's alpha" do setup do @samples=40 @n_variables=rand(10)+2 @ds=Statsample::Dataset.new() @@ -42,9 +52,10 @@ vm, cm = sa.variances_mean, sa.covariances_mean n_obtained=Statsample::Reliability.n_for_desired_alpha(@a, vm,cm) #p n_obtained assert_in_delta(Statsample::Reliability.cronbach_alpha_from_n_s2_cov(n_obtained, vm,cm) ,@a,0.001) end + should "standarized alpha will be equal to sum of matrix covariance less the individual variances on standarized values" do total_sum=@cme.total_sum ind_var=@dse.fields.inject(0) {|ac,v| ac+@dse[v].variance} expected = @k.quo(@k-1) * (1-(ind_var.quo(total_sum))) assert_in_delta(expected, @as, 1e-10)