test/test_reliability.rb in statsample-0.13.1 vs test/test_reliability.rb in statsample-0.14.0

- old
+ new

@@ -120,55 +120,55 @@ @scales.times {|s| m.scale "scale_#{s}", @ds.clone(@items_per_scale.times.map {|i| "#{s}_#{i}"}), {:name=>"Scale #{s}"} } end end - should "Retrieve correct ScaleAnalysis for whole scale" do - sa=Statsample::Reliability::ScaleAnalysis.new(@ds, :name=>"Scale complete") - assert_equal(sa.variances_mean, @msa.scale("complete").variances_mean) - end - should "Retrieve correct ScaleAnalysis for each scale" do - @scales.times {|s| - sa=Statsample::Reliability::ScaleAnalysis.new(@ds.dup(@items_per_scale.times.map {|i| "#{s}_#{i}"}), :name=>"Scale #{s}") - assert_equal(sa.variances_mean,@msa.scale("scale_#{s}").variances_mean) - } - end - should "retrieve correct correlation matrix for each scale" do - vectors={'complete'=>@ds.vector_sum} - @scales.times {|s| - vectors["scale_#{s}"]=@ds.dup(@items_per_scale.times.map {|i| "#{s}_#{i}"}).vector_sum - } - ds2=vectors.to_dataset - assert_equal(Statsample::Bivariate.correlation_matrix(ds2), @msa.correlation_matrix) - end - should "delete scale using delete_scale" do - @msa.delete_scale("complete") - assert_equal(@msa.scales.keys.sort, @scales.times.map {|s| "scale_#{s}"}) - end - should "retrieve pca for scales" do - @msa.delete_scale("complete") - vectors=Hash.new - @scales.times {|s| - vectors["scale_#{s}"]=@ds.dup(@items_per_scale.times.map {|i| "#{s}_#{i}"}).vector_sum - } - ds2=vectors.to_dataset - cor_matrix=Statsample::Bivariate.correlation_matrix(ds2) - m=3 - pca=Statsample::Factor::PCA.new(cor_matrix, :m=>m) - assert_equal(pca.component_matrix, @msa.pca(:m=>m).component_matrix) - end - should "retrieve acceptable summary" do - @msa.delete_scale("scale_0") - @msa.delete_scale("scale_1") - @msa.delete_scale("scale_2") - - - #@msa.summary_correlation_matrix=true - #@msa.summary_pca=true - - - assert(@msa.summary.size>0) - end + should "Retrieve correct ScaleAnalysis for whole scale" do + sa=Statsample::Reliability::ScaleAnalysis.new(@ds, :name=>"Scale complete") + assert_equal(sa.variances_mean, @msa.scale("complete").variances_mean) + end + should "Retrieve correct ScaleAnalysis for each scale" do + @scales.times {|s| + sa=Statsample::Reliability::ScaleAnalysis.new(@ds.dup(@items_per_scale.times.map {|i| "#{s}_#{i}"}), :name=>"Scale #{s}") + assert_equal(sa.variances_mean,@msa.scale("scale_#{s}").variances_mean) + } + end + should "retrieve correct correlation matrix for each scale" do + vectors={'complete' => @ds.vector_sum} + @scales.times {|s| + vectors["scale_#{s}"]=@ds.dup(@items_per_scale.times.map {|i| "#{s}_#{i}"}).vector_sum + } + ds2=vectors.to_dataset + assert_equal(Statsample::Bivariate.correlation_matrix(ds2), @msa.correlation_matrix) + end + should "delete scale using delete_scale" do + @msa.delete_scale("complete") + assert_equal(@msa.scales.keys.sort, @scales.times.map {|s| "scale_#{s}"}) + end + should "retrieve pca for scales" do + @msa.delete_scale("complete") + vectors=Hash.new + @scales.times {|s| + vectors["scale_#{s}"]=@ds.dup(@items_per_scale.times.map {|i| "#{s}_#{i}"}).vector_sum + } + ds2=vectors.to_dataset + cor_matrix=Statsample::Bivariate.correlation_matrix(ds2) + m=3 + pca=Statsample::Factor::PCA.new(cor_matrix, :m=>m) + assert_equal(pca.component_matrix, @msa.pca(:m=>m).component_matrix) + end + should "retrieve acceptable summary" do + @msa.delete_scale("scale_0") + @msa.delete_scale("scale_1") + @msa.delete_scale("scale_2") + + + #@msa.summary_correlation_matrix=true + #@msa.summary_pca=true + + + assert(@msa.summary.size>0) + end end context Statsample::Reliability::ScaleAnalysis do setup do @x1=[1,1,1,1,2,2,2,2,3,3,3,30].to_scale @x2=[1,1,1,2,2,3,3,3,3,4,4,50].to_scale