statsample-bivariate-extension 0.13.4 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,9 @@
1
+ === 0.16.0 / 2010-11-14
2
+ * Bug fix: Specs work without gsl. Counts iterations when using only ruby
3
+ * Updated specs to rspec 2
4
+ * Updated Manifest.txt
5
+ * Added grab_references to retrieve references on package
6
+
1
7
  === 0.13.4 / 2010-08-18
2
8
 
3
9
  * Added cache for tetrachoric correlation matrix
@@ -4,10 +4,12 @@ README.txt
4
4
  Rakefile
5
5
  data/tetmat_matrix.txt
6
6
  data/tetmat_test.txt
7
+ grab_references.rb
7
8
  lib/statsample/bivariate/extension_version.rb
8
9
  lib/statsample/bivariate/polychoric.rb
9
10
  lib/statsample/bivariate/polychoric/processor.rb
10
11
  lib/statsample/bivariate/tetrachoric.rb
12
+ references.txt
11
13
  spec/spec.opts
12
14
  spec/spec_helper.rb
13
15
  spec/statsample/bivariate/polychoric_processor_spec.rb
data/Rakefile CHANGED
@@ -2,7 +2,8 @@
2
2
  # -*- ruby -*-
3
3
 
4
4
  require 'rubygems'
5
- require 'spec/rake/spectask'
5
+ require 'rspec'
6
+ require 'rspec/core/rake_task'
6
7
  require 'hoe'
7
8
 
8
9
  Hoe.plugin :git
@@ -19,10 +20,12 @@ end
19
20
 
20
21
 
21
22
  desc "Run all spec with RCov"
22
- Spec::Rake::SpecTask.new('test_with_rcov') do |t|
23
- t.spec_files = FileList['spec/**/*.rb']
24
- t.rcov = true
25
- t.rcov_opts = ['--exclude', 'spec']
23
+ RSpec::Core::RakeTask.new do |t|
24
+ t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
25
+ t.pattern = 'spec/**/*_spec.rb'
26
+ #t.rcov = true
27
+ #t.rcov_opts = ['--exclude', 'spec']
28
+
26
29
  end
27
30
 
28
31
  # vim: syntax=ruby
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby1.9
2
+ require 'reportbuilder'
3
+ refs=[]
4
+ Dir.glob "**/*.rb" do |f|
5
+ reference=false
6
+ File.open(f).each_line do |l|
7
+
8
+ if l=~/== Reference/
9
+ reference=true
10
+ elsif reference
11
+ if l=~/\*\s+(.+)/
12
+ refs.push $1
13
+ else
14
+ reference=false
15
+ end
16
+ end
17
+
18
+ end
19
+ end
20
+
21
+
22
+ rb=ReportBuilder.new(:name=>"References") do |g|
23
+ refs.uniq.sort.each do |r|
24
+ g.text "* #{r}"
25
+ end
26
+ end
27
+
28
+ rb.save_text("references.txt")
@@ -1,7 +1,7 @@
1
1
  module Statsample
2
2
  module Bivariate
3
3
  # Version of bivariate extension
4
- EXTENSION_VERSION="0.13.4"
4
+ EXTENSION_VERSION="0.16.0"
5
5
  end
6
6
  end
7
7
 
@@ -85,8 +85,7 @@ module Statsample
85
85
  #
86
86
  # See extensive documentation on Uebersax(2002) and Drasgow(2006)
87
87
  #
88
- # == References
89
- #
88
+ # == Reference
90
89
  # * Drasgow F. (2006). Polychoric and polyserial correlations. In Kotz L, Johnson NL (Eds.), Encyclopedia of statistical sciences. Vol. 7 (pp. 69-74). New York: Wiley.
91
90
  # * Olsson, U. (1979) Maximum likelihood estimation of the polychoric correlation coefficient. Psychometrika 44, 443-460.
92
91
  # * Uebersax, J.S. (2006). The tetrachoric and polychoric correlation coefficients. Statistical Methods for Rater Agreement web site. 2006. Available at: http://john-uebersax.com/stat/tetra.htm . Accessed February, 11, 2010
@@ -307,6 +306,7 @@ module Statsample
307
306
  @log+=min.log.to_table.to_s
308
307
  @r=min.x_minimum
309
308
  @loglike_model=-min.f_minimum
309
+ @iteration=min.iterations
310
310
  puts @log if @debug
311
311
 
312
312
  end
@@ -61,17 +61,17 @@ module Statsample
61
61
  # tc.threshold_y # threshold for y variable
62
62
  # tc.threshold_x # threshold for x variable
63
63
  #
64
- # == References:
65
- #
64
+ # == Reference:
66
65
  # * Brown, MB. (1977) Algorithm AS 116: the tetrachoric correlation and its standard error. <em>Applied Statistics, 26</em>, 343-351.
67
66
  # * Drasgow F. (2006). Polychoric and polyserial correlations. In Kotz L, Johnson NL (Eds.), Encyclopedia of statistical sciences. Vol. 7 (pp. 69-74). New York: Wiley.
68
67
  # * Uebersax, J.S. (2006). The tetrachoric and polychoric correlation coefficients. Statistical Methods for Rater Agreement web site. 2006. Available at: http://john-uebersax.com/stat/tetra.htm . Accessed February, 11, 2010
69
68
 
70
69
  class Tetrachoric
70
+ RequerimentNotMeet=Class.new(Exception)
71
71
  include Summarizable
72
72
  attr_reader :r
73
73
  attr_accessor :name
74
-
74
+
75
75
  TWOPI=Math::PI*2
76
76
  SQT2PI= 2.50662827
77
77
  RLIMIT = 0.9999
@@ -94,8 +94,8 @@ module Statsample
94
94
  v1a, v2a=Statsample.only_valid(v1,v2)
95
95
  v1a=v1a.dichotomize
96
96
  v2a=v2a.dichotomize
97
- raise "v1 have only 0" if v1a.factors==[0]
98
- raise "v2 have only 0" if v2a.factors==[0]
97
+ raise RequerimentNotMeet, "v1 have only 0" if v1a.factors==[0]
98
+ raise RequerimentNotMeet, "v2 have only 0" if v2a.factors==[0]
99
99
  a,b,c,d = 0,0,0,0
100
100
  v1a.each_index{|i|
101
101
  x,y=v1a[i],v2a[i]
@@ -172,7 +172,7 @@ module Statsample
172
172
  # kdelta=4 MEANS TABLE HAS 0.0 ROW OR COLUMN, RUN IS TERMINATED
173
173
  #
174
174
 
175
- raise "Rows and columns should have more than 0 items" if @kdelta==4
175
+ raise RequerimentNotMeet, "Rows and columns should have more than 0 items" if @kdelta==4
176
176
 
177
177
  # GOTO (4, 1, 2 , 92), kdelta
178
178
  #
@@ -0,0 +1,5 @@
1
+ References
2
+ * Brown, MB. (1977) Algorithm AS 116: the tetrachoric correlation and its standard error. <em>Applied Statistics, 26</em>, 343-351.
3
+ * Drasgow F. (2006). Polychoric and polyserial correlations. In Kotz L, Johnson NL (Eds.), Encyclopedia of statistical sciences. Vol. 7 (pp. 69-74). New York: Wiley.
4
+ * Olsson, U. (1979) Maximum likelihood estimation of the polychoric correlation coefficient. Psychometrika 44, 443-460.
5
+ * Uebersax, J.S. (2006). The tetrachoric and polychoric correlation coefficients. Statistical Methods for Rater Agreement web site. 2006. Available at: http://john-uebersax.com/stat/tetra.htm . Accessed February, 11, 2010
@@ -2,8 +2,7 @@
2
2
 
3
3
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
4
  require "rubygems"
5
- require 'spec'
6
- require 'spec/autorun'
5
+ require 'rspec'
7
6
  require 'statsample'
8
7
  require 'statsample/bivariate/tetrachoric'
9
8
  require 'statsample/bivariate/polychoric'
@@ -22,12 +22,12 @@ describe Statsample::Bivariate::Polychoric::Processor do
22
22
  end
23
23
  it "fd a loglike should be equal usign eq.6 and eq.13" do
24
24
  2.times {|k|
25
- @processor.fd_loglike_a_eq6(k).should be_close @processor.fd_loglike_a_eq13(k), 1e-10
25
+ @processor.fd_loglike_a_eq6(k).should be_within(1e-10).of( @processor.fd_loglike_a_eq13(k))
26
26
  }
27
27
  end
28
28
  it "fd b loglike should be equal usign eq.6 and eq.14" do
29
29
  2.times {|m|
30
- @processor.fd_loglike_b_eq6(m).should be_close @processor.fd_loglike_b_eq14(m), 1e-10
30
+ @processor.fd_loglike_b_eq6(m).should be_within(1e-10).of( @processor.fd_loglike_b_eq14(m))
31
31
  }
32
32
  end
33
33
  it "fd rho should be equal usign fd_loglike_cell_rho and fd_loglike_rho" do
@@ -24,30 +24,33 @@ describe Statsample::Bivariate::Polychoric do
24
24
  @poly.summary.size.should>0
25
25
  end
26
26
  def check_joint
27
- @poly.r.should be_close(0.4192, 0.0001)
28
- @poly.threshold_x[0].should be_close(-0.0297, 0.0001)
29
- @poly.threshold_x[1].should be_close(1.1331, 0.0001)
27
+ @poly.r.should be_within( 0.0001).of(0.4192)
28
+ @poly.threshold_x[0].should be_within( 0.0001).of(-0.0297)
29
+ @poly.threshold_x[1].should be_within( 0.0001).of(1.1331)
30
30
 
31
- @poly.threshold_y[0].should be_close(-0.2421, 0.0001)
32
- @poly.threshold_y[1].should be_close(1.5938 ,0.0001)
33
- @poly.chi_square.should be_close(11.54,0.01)
31
+ @poly.threshold_y[0].should be_within( 0.0001).of(-0.2421)
32
+ @poly.threshold_y[1].should be_within(0.0001).of(1.5938 )
33
+ @poly.chi_square.should be_within(0.01).of(11.54)
34
34
  end
35
35
  it "compute joint estimation (without derivative) using gsl" do
36
+ pending("requires rb-gsl") unless Statsample.has_gsl?
37
+
36
38
  @poly.compute_one_step_mle_without_derivatives
37
39
  check_joint
38
-
39
40
  end
40
41
  it "compute joint estimation (with derivative) using gsl" do
42
+ pending("requires rb-gsl") unless Statsample.has_gsl?
43
+
41
44
  @poly.compute_one_step_mle_with_derivatives
42
45
  check_joint
43
46
  end
44
47
 
45
48
  def check_two_step
46
- @poly.r.should be_close(0.420, 0.001)
47
- @poly.threshold_y[0].should be_close(-0.240 ,0.001)
48
- @poly.threshold_x[0].should be_close(-0.027 ,0.001)
49
- @poly.threshold_y[1].should be_close(1.578 ,0.001)
50
- @poly.threshold_x[1].should be_close(1.137 ,0.001)
49
+ @poly.r.should be_within( 0.001).of(0.420)
50
+ @poly.threshold_y[0].should be_within(0.001).of(-0.240 )
51
+ @poly.threshold_x[0].should be_within(0.001).of(-0.027 )
52
+ @poly.threshold_y[1].should be_within(0.001).of(1.578 )
53
+ @poly.threshold_x[1].should be_within(0.001).of(1.137 )
51
54
  end
52
55
  it "should compute two step mle with ruby" do
53
56
  @poly.compute_two_step_mle_ruby
@@ -66,11 +69,11 @@ describe Statsample::Bivariate::Polychoric do
66
69
  @poly.method=:polychoric_series
67
70
  @poly.compute
68
71
 
69
- @poly.r.should be_close(0.556, 0.001)
70
- @poly.threshold_y[0].should be_close(-0.240 ,0.001)
71
- @poly.threshold_x[0].should be_close(-0.027 ,0.001)
72
- @poly.threshold_y[1].should be_close(1.578 ,0.001)
73
- @poly.threshold_x[1].should be_close(1.137 ,0.001)
72
+ @poly.r.should be_within( 0.001).of(0.556)
73
+ @poly.threshold_y[0].should be_within(0.001).of(-0.240 )
74
+ @poly.threshold_x[0].should be_within(0.001).of(-0.027 )
75
+ @poly.threshold_y[1].should be_within(0.001).of(1.578 )
76
+ @poly.threshold_x[1].should be_within(0.001).of(1.137 )
74
77
  end
75
78
 
76
79
  end
@@ -11,7 +11,7 @@ describe "Statsample::Bivariate tetrachoric extensions" do
11
11
  tcm_exp=Statsample::PlainText.read(File.dirname(__FILE__)+"/../../../data/tetmat_matrix.txt", %w{a b c d e}).to_matrix
12
12
  tcm_obs.row_size.times do |i|
13
13
  tcm_obs.column_size do |j|
14
- tcm_obs[i,j].should be_close(tcm_exp[i,k], 0.00001)
14
+ tcm_obs[i,j].should be_within( 0.00001).of(tcm_exp[i,k])
15
15
  end
16
16
  end
17
17
  end
@@ -27,12 +27,12 @@ describe Statsample::Bivariate::Tetrachoric do
27
27
  end
28
28
  it "should return similar values for two step ruby" do
29
29
  @poly.compute_two_step_mle_ruby
30
- @tetra.r.should be_close(@poly.r,0.0001)
30
+ @tetra.r.should be_within(0.0001).of(@poly.r)
31
31
  end
32
32
  if Statsample.has_gsl?
33
33
  it "should return similar values for two step using gsl" do
34
34
  @poly.compute_two_step_mle_gsl
35
- @tetra.r.should be_close(@poly.r,0.0001)
35
+ @tetra.r.should be_within(0.0001).of(@poly.r)
36
36
  end
37
37
  else
38
38
  it "shouldn't use two step gsl without rb-gsl"
@@ -43,17 +43,17 @@ describe Statsample::Bivariate::Tetrachoric do
43
43
  it "should raise error on contingence table without cases" do
44
44
  a,b,c,d=0,0,0,0
45
45
 
46
- lambda {Statsample::Bivariate::Tetrachoric.new(a,b,c,d)}.should raise_error(RuntimeError)
46
+ lambda {Statsample::Bivariate::Tetrachoric.new(a,b,c,d)}.should raise_error(Statsample::Bivariate::Tetrachoric::RequerimentNotMeet)
47
47
  end
48
48
  it "should raise error on contingence table without cases on a row" do
49
49
 
50
50
  a,b,c,d=10,10,0,0
51
51
 
52
- lambda {Statsample::Bivariate::Tetrachoric.new(a,b,c,d)}.should raise_error(RuntimeError)
52
+ lambda {Statsample::Bivariate::Tetrachoric.new(a,b,c,d)}.should raise_error(Statsample::Bivariate::Tetrachoric::RequerimentNotMeet)
53
53
  end
54
54
  it "should raise error on contingence table without cases on a column" do
55
55
  a,b,c,d=10,0,10,0
56
- lambda {Statsample::Bivariate::Tetrachoric.new(a,b,c,d)}.should raise_error(RuntimeError)
56
+ lambda {Statsample::Bivariate::Tetrachoric.new(a,b,c,d)}.should raise_error(Statsample::Bivariate::Tetrachoric::RequerimentNotMeet)
57
57
  end
58
58
  it "should return correct values for perfect correlation" do
59
59
  a,b,c,d=10,0,0,10
@@ -71,10 +71,10 @@ describe Statsample::Bivariate::Tetrachoric do
71
71
  it "should return correct value for standard contingence table" do
72
72
  a,b,c,d = 30,40,70,20
73
73
  tc = Statsample::Bivariate::Tetrachoric.new(a,b,c,d)
74
- tc.r.should be_close(-0.53980,0.0001)
75
- tc.se.should be_close(0.09940,0.0001)
76
- tc.threshold_x.should be_close(-0.15731, 0.0001)
77
- tc.threshold_y.should be_close( 0.31864, 0.0001)
74
+ tc.r.should be_within(0.0001).of(-0.53980)
75
+ tc.se.should be_within(0.0001).of(0.09940)
76
+ tc.threshold_x.should be_within( 0.0001).of(-0.15731)
77
+ tc.threshold_y.should be_within( 0.0001).of( 0.31864)
78
78
  end
79
79
  it "should return equal values for dataset and crosstab inputs" do
80
80
  x=%w{a a a a b b b a b b a a b b}.to_vector
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statsample-bivariate-extension
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 95
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 13
8
- - 4
9
- version: 0.13.4
8
+ - 16
9
+ - 0
10
+ version: 0.16.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Claudio Bustos
@@ -35,16 +36,18 @@ cert_chain:
35
36
  rpP0jjs0
36
37
  -----END CERTIFICATE-----
37
38
 
38
- date: 2010-08-18 00:00:00 -04:00
39
+ date: 2010-11-14 00:00:00 -03:00
39
40
  default_executable:
40
41
  dependencies:
41
42
  - !ruby/object:Gem::Dependency
42
43
  name: rubyforge
43
44
  prerelease: false
44
45
  requirement: &id001 !ruby/object:Gem::Requirement
46
+ none: false
45
47
  requirements:
46
48
  - - ">="
47
49
  - !ruby/object:Gem::Version
50
+ hash: 7
48
51
  segments:
49
52
  - 2
50
53
  - 0
@@ -56,14 +59,16 @@ dependencies:
56
59
  name: hoe
57
60
  prerelease: false
58
61
  requirement: &id002 !ruby/object:Gem::Requirement
62
+ none: false
59
63
  requirements:
60
64
  - - ">="
61
65
  - !ruby/object:Gem::Version
66
+ hash: 19
62
67
  segments:
63
68
  - 2
64
69
  - 6
65
- - 1
66
- version: 2.6.1
70
+ - 2
71
+ version: 2.6.2
67
72
  type: :development
68
73
  version_requirements: *id002
69
74
  description: |-
@@ -80,6 +85,7 @@ extra_rdoc_files:
80
85
  - History.txt
81
86
  - Manifest.txt
82
87
  - README.txt
88
+ - references.txt
83
89
  files:
84
90
  - History.txt
85
91
  - Manifest.txt
@@ -87,10 +93,12 @@ files:
87
93
  - Rakefile
88
94
  - data/tetmat_matrix.txt
89
95
  - data/tetmat_test.txt
96
+ - grab_references.rb
90
97
  - lib/statsample/bivariate/extension_version.rb
91
98
  - lib/statsample/bivariate/polychoric.rb
92
99
  - lib/statsample/bivariate/polychoric/processor.rb
93
100
  - lib/statsample/bivariate/tetrachoric.rb
101
+ - references.txt
94
102
  - spec/spec.opts
95
103
  - spec/spec_helper.rb
96
104
  - spec/statsample/bivariate/polychoric_processor_spec.rb
@@ -107,23 +115,27 @@ rdoc_options:
107
115
  require_paths:
108
116
  - lib
109
117
  required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
110
119
  requirements:
111
120
  - - ">="
112
121
  - !ruby/object:Gem::Version
122
+ hash: 3
113
123
  segments:
114
124
  - 0
115
125
  version: "0"
116
126
  required_rubygems_version: !ruby/object:Gem::Requirement
127
+ none: false
117
128
  requirements:
118
129
  - - ">="
119
130
  - !ruby/object:Gem::Version
131
+ hash: 3
120
132
  segments:
121
133
  - 0
122
134
  version: "0"
123
135
  requirements: []
124
136
 
125
137
  rubyforge_project: ruby-statsample
126
- rubygems_version: 1.3.6
138
+ rubygems_version: 1.3.7
127
139
  signing_key:
128
140
  specification_version: 3
129
141
  summary: "Provides advanced bivariate statistics: * Tetrachoric correlation * Polychoric correlation"
metadata.gz.sig CHANGED
Binary file