statsample 0.11.2 → 0.12.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.
- data.tar.gz.sig +1 -2
- data/History.txt +11 -0
- data/Manifest.txt +4 -0
- data/README.txt +14 -5
- data/Rakefile +24 -3
- data/data/locale/es/LC_MESSAGES/statsample.mo +0 -0
- data/doc_latex/manual/equations.tex +78 -0
- data/examples/reliability.rb +1 -1
- data/lib/distribution.rb +5 -1
- data/lib/distribution/normalbivariate.rb +7 -1
- data/lib/distribution/normalmultivariate.rb +73 -0
- data/lib/distribution/t.rb +34 -1
- data/lib/statsample.rb +2 -1
- data/lib/statsample/anova/twoway.rb +1 -1
- data/lib/statsample/bivariate/polychoric.rb +190 -69
- data/lib/statsample/factor/pca.rb +1 -1
- data/lib/statsample/graph/svgscatterplot.rb +10 -1
- data/lib/statsample/reliability.rb +38 -191
- data/lib/statsample/reliability/multiscaleanalysis.rb +87 -0
- data/lib/statsample/reliability/scaleanalysis.rb +204 -0
- data/po/es/statsample.mo +0 -0
- data/po/es/statsample.po +193 -49
- data/po/statsample.pot +173 -40
- data/test/test_bivariate_polychoric.rb +6 -6
- data/test/test_distribution.rb +1 -1
- data/test/test_reliability.rb +87 -8
- data/test/test_vector.rb +0 -8
- metadata +44 -36
- metadata.gz.sig +0 -0
@@ -49,7 +49,7 @@ class StatsampleBivariatePolychoricTestCase < MiniTest::Unit::TestCase
|
|
49
49
|
assert_in_delta(1.137, @poly.threshold_x[1],0.001)
|
50
50
|
end
|
51
51
|
end
|
52
|
-
if Statsample.has_gsl?
|
52
|
+
if true and Statsample.has_gsl?
|
53
53
|
context "compute joint" do
|
54
54
|
setup do
|
55
55
|
@poly.method=:joint
|
@@ -57,11 +57,11 @@ class StatsampleBivariatePolychoricTestCase < MiniTest::Unit::TestCase
|
|
57
57
|
end
|
58
58
|
should "have correct values" do
|
59
59
|
assert_equal(:joint, @poly.method)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
assert_in_delta(0.4192, @poly.r, 0.0001)
|
61
|
+
assert_in_delta(-0.2421, @poly.threshold_y[0],0.0001)
|
62
|
+
assert_in_delta(-0.0297, @poly.threshold_x[0],0.0001)
|
63
|
+
assert_in_delta(1.5938, @poly.threshold_y[1],0.0001)
|
64
|
+
assert_in_delta(1.1331, @poly.threshold_x[1],0.0001)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
data/test/test_distribution.rb
CHANGED
@@ -39,7 +39,7 @@ class DistributionTestCase < MiniTest::Unit::TestCase
|
|
39
39
|
def test_normal_bivariate
|
40
40
|
if Distribution.has_gsl?
|
41
41
|
[0.2,0.4,0.6,0.8,0.9, 0.99,0.999,0.999999].each {|rho|
|
42
|
-
|
42
|
+
assert_in_delta(GSL::Ran::bivariate_gaussian_pdf(0, 0, 1,1,rho), Distribution::NormalBivariate.pdf(0,0, rho , 1,1),1e-8)
|
43
43
|
|
44
44
|
}
|
45
45
|
end
|
data/test/test_reliability.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
1
|
require(File.dirname(__FILE__)+'/helpers_tests.rb')
|
2
|
-
|
3
|
-
|
4
2
|
class StatsampleReliabilityTestCase < MiniTest::Unit::TestCase
|
5
3
|
context Statsample::Reliability do
|
6
4
|
context "Cronbach's alpha" do
|
@@ -30,6 +28,19 @@ class StatsampleReliabilityTestCase < MiniTest::Unit::TestCase
|
|
30
28
|
expected = @k.quo(@k-1) * (1-(ind_var.quo(total_sum)))
|
31
29
|
assert_in_delta(expected, @a,1e-10)
|
32
30
|
end
|
31
|
+
should "method cronbach_alpha_from_n_s2_cov return correct values" do
|
32
|
+
sa=Statsample::Reliability::ScaleAnalysis.new(@ds)
|
33
|
+
vm, cm = sa.variances_mean, sa.covariances_mean
|
34
|
+
assert_in_delta(sa.alpha, Statsample::Reliability.cronbach_alpha_from_n_s2_cov(@n_variables, vm,cm), 1e-10 )
|
35
|
+
|
36
|
+
end
|
37
|
+
should "return correct n for desired alpha, covariance and variance" do
|
38
|
+
sa=Statsample::Reliability::ScaleAnalysis.new(@ds)
|
39
|
+
vm, cm = sa.variances_mean, sa.covariances_mean
|
40
|
+
n_obtained=Statsample::Reliability.n_for_desired_alpha(@a, vm,cm)
|
41
|
+
#p n_obtained
|
42
|
+
assert_in_delta(Statsample::Reliability.cronbach_alpha_from_n_s2_cov(n_obtained, vm,cm) ,@a,0.001)
|
43
|
+
end
|
33
44
|
should "standarized alpha will be equal to sum of matrix covariance less the individual variances on standarized values" do
|
34
45
|
total_sum=@cme.total_sum
|
35
46
|
ind_var=@dse.fields.inject(0) {|ac,v| ac+@dse[v].variance}
|
@@ -87,14 +98,82 @@ class StatsampleReliabilityTestCase < MiniTest::Unit::TestCase
|
|
87
98
|
end
|
88
99
|
|
89
100
|
end
|
90
|
-
|
101
|
+
|
102
|
+
context Statsample::Reliability::MultiScaleAnalysis do
|
103
|
+
|
104
|
+
setup do
|
105
|
+
|
106
|
+
size=100
|
107
|
+
@scales=4
|
108
|
+
@items_per_scale=10
|
109
|
+
h={}
|
110
|
+
@scales.times {|s|
|
111
|
+
@items_per_scale.times {|i|
|
112
|
+
h["#{s}_#{i}"] = (size.times.map {(s*2)+rand}).to_scale
|
113
|
+
}
|
114
|
+
}
|
115
|
+
@ds=h.to_dataset
|
116
|
+
@msa=Statsample::Reliability::MultiScaleAnalysis.new(:name=>'Multiple Analysis') do |m|
|
117
|
+
m.scale "complete", @ds
|
118
|
+
@scales.times {|s|
|
119
|
+
m.scale "scale_#{s}", @ds.clone(@items_per_scale.times.map {|i| "#{s}_#{i}"}), {:name=>"Scale #{s}"}
|
120
|
+
}
|
121
|
+
end
|
122
|
+
end
|
123
|
+
should "Retrieve correct ScaleAnalysis for whole scale" do
|
124
|
+
sa=Statsample::Reliability::ScaleAnalysis.new(@ds, :name=>"Scale complete")
|
125
|
+
assert_equal(sa.variances_mean, @msa.scale("complete").variances_mean)
|
126
|
+
end
|
127
|
+
should "Retrieve correct ScaleAnalysis for each scale" do
|
128
|
+
@scales.times {|s|
|
129
|
+
sa=Statsample::Reliability::ScaleAnalysis.new(@ds.dup(@items_per_scale.times.map {|i| "#{s}_#{i}"}), :name=>"Scale #{s}")
|
130
|
+
assert_equal(sa.variances_mean,@msa.scale("scale_#{s}").variances_mean)
|
131
|
+
}
|
132
|
+
end
|
133
|
+
should "retrieve correct correlation matrix for each scale" do
|
134
|
+
vectors={'complete'=>@ds.vector_sum}
|
135
|
+
|
136
|
+
@scales.times {|s|
|
137
|
+
vectors["scale_#{s}"]=@ds.dup(@items_per_scale.times.map {|i| "#{s}_#{i}"}).vector_sum
|
138
|
+
}
|
139
|
+
ds2=vectors.to_dataset
|
140
|
+
assert_equal(Statsample::Bivariate.correlation_matrix(ds2), @msa.correlation_matrix)
|
141
|
+
end
|
142
|
+
should "delete scale using delete_scale" do
|
143
|
+
@msa.delete_scale("complete")
|
144
|
+
assert_equal(@msa.scales.keys.sort, @scales.times.map {|s| "scale_#{s}"})
|
145
|
+
end
|
146
|
+
should "retrieve pca for scales" do
|
147
|
+
@msa.delete_scale("complete")
|
148
|
+
vectors=Hash.new
|
149
|
+
@scales.times {|s|
|
150
|
+
vectors["scale_#{s}"]=@ds.dup(@items_per_scale.times.map {|i| "#{s}_#{i}"}).vector_sum
|
151
|
+
}
|
152
|
+
ds2=vectors.to_dataset
|
153
|
+
cor_matrix=Statsample::Bivariate.correlation_matrix(ds2)
|
154
|
+
m=3
|
155
|
+
pca=Statsample::Factor::PCA.new(cor_matrix, :m=>m)
|
156
|
+
assert_equal(pca.component_matrix, @msa.pca(:m=>m).component_matrix)
|
157
|
+
end
|
158
|
+
should "retrieve acceptable summary" do
|
159
|
+
@msa.delete_scale("scale_0")
|
160
|
+
@msa.delete_scale("scale_1")
|
161
|
+
@msa.delete_scale("scale_2")
|
162
|
+
|
163
|
+
|
164
|
+
#@msa.summary_correlation_matrix=true
|
165
|
+
#@msa.summary_pca=true
|
166
|
+
assert(@msa.summary.size>0)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
context Statsample::Reliability::ScaleAnalysis do
|
91
170
|
setup do
|
92
|
-
@x1=[1,1,1,1,2,2,2,2,3,3,3,30].
|
93
|
-
@x2=[1,1,1,2,2,3,3,3,3,4,4,50].
|
94
|
-
@x3=[2,2,1,1,1,2,2,2,3,4,5,40].
|
95
|
-
@x4=[1,2,3,4,4,4,4,3,4,4,5,30].
|
171
|
+
@x1=[1,1,1,1,2,2,2,2,3,3,3,30].to_scale
|
172
|
+
@x2=[1,1,1,2,2,3,3,3,3,4,4,50].to_scale
|
173
|
+
@x3=[2,2,1,1,1,2,2,2,3,4,5,40].to_scale
|
174
|
+
@x4=[1,2,3,4,4,4,4,3,4,4,5,30].to_scale
|
96
175
|
@ds={'x1'=>@x1,'x2'=>@x2,'x3'=>@x3,'x4'=>@x4}.to_dataset
|
97
|
-
@ia=Statsample::Reliability::
|
176
|
+
@ia=Statsample::Reliability::ScaleAnalysis.new(@ds)
|
98
177
|
@cov_matrix=Statsample::Bivariate.covariance_matrix(@ds)
|
99
178
|
end
|
100
179
|
should "return correct values for item analysis" do
|
data/test/test_vector.rb
CHANGED
@@ -200,14 +200,6 @@ class StatsampleTestVector < MiniTest::Unit::TestCase
|
|
200
200
|
|
201
201
|
assert_match(/#{@c.name}/, @c.summary)
|
202
202
|
end
|
203
|
-
should "have output dependent of #type" do
|
204
|
-
@c.type=:nominal
|
205
|
-
assert_match(/Distribution/, @c.summary())
|
206
|
-
@c.type=:ordinal
|
207
|
-
assert_match(/median/, @c.summary())
|
208
|
-
@c.type=:scale
|
209
|
-
assert_match(/mean/, @c.summary())
|
210
|
-
end
|
211
203
|
|
212
204
|
|
213
205
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 12
|
8
|
+
- 0
|
9
|
+
version: 0.12.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Claudio Bustos
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
rpP0jjs0
|
36
36
|
-----END CERTIFICATE-----
|
37
37
|
|
38
|
-
date: 2010-
|
38
|
+
date: 2010-06-14 00:00:00 -04:00
|
39
39
|
default_executable:
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -118,7 +118,7 @@ dependencies:
|
|
118
118
|
type: :runtime
|
119
119
|
version_requirements: *id006
|
120
120
|
- !ruby/object:Gem::Dependency
|
121
|
-
name:
|
121
|
+
name: extendmatrix
|
122
122
|
prerelease: false
|
123
123
|
requirement: &id007 !ruby/object:Gem::Requirement
|
124
124
|
requirements:
|
@@ -126,66 +126,51 @@ dependencies:
|
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
segments:
|
128
128
|
- 0
|
129
|
-
-
|
130
|
-
|
129
|
+
- 2
|
130
|
+
- 0
|
131
|
+
version: 0.2.0
|
131
132
|
type: :runtime
|
132
133
|
version_requirements: *id007
|
133
134
|
- !ruby/object:Gem::Dependency
|
134
|
-
name:
|
135
|
+
name: rubyforge
|
135
136
|
prerelease: false
|
136
137
|
requirement: &id008 !ruby/object:Gem::Requirement
|
137
138
|
requirements:
|
138
|
-
- -
|
139
|
+
- - ">="
|
139
140
|
- !ruby/object:Gem::Version
|
140
141
|
segments:
|
141
|
-
- 0
|
142
142
|
- 2
|
143
143
|
- 0
|
144
|
-
|
145
|
-
|
144
|
+
- 4
|
145
|
+
version: 2.0.4
|
146
|
+
type: :development
|
146
147
|
version_requirements: *id008
|
147
148
|
- !ruby/object:Gem::Dependency
|
148
|
-
name:
|
149
|
+
name: shoulda
|
149
150
|
prerelease: false
|
150
151
|
requirement: &id009 !ruby/object:Gem::Requirement
|
151
|
-
requirements:
|
152
|
-
- - ~>
|
153
|
-
- !ruby/object:Gem::Version
|
154
|
-
segments:
|
155
|
-
- 1
|
156
|
-
- 12
|
157
|
-
- 109
|
158
|
-
version: 1.12.109
|
159
|
-
type: :runtime
|
160
|
-
version_requirements: *id009
|
161
|
-
- !ruby/object:Gem::Dependency
|
162
|
-
name: rubyforge
|
163
|
-
prerelease: false
|
164
|
-
requirement: &id010 !ruby/object:Gem::Requirement
|
165
152
|
requirements:
|
166
153
|
- - ">="
|
167
154
|
- !ruby/object:Gem::Version
|
168
155
|
segments:
|
169
|
-
- 2
|
170
156
|
- 0
|
171
|
-
|
172
|
-
version: 2.0.4
|
157
|
+
version: "0"
|
173
158
|
type: :development
|
174
|
-
version_requirements: *
|
159
|
+
version_requirements: *id009
|
175
160
|
- !ruby/object:Gem::Dependency
|
176
161
|
name: hoe
|
177
162
|
prerelease: false
|
178
|
-
requirement: &
|
163
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
179
164
|
requirements:
|
180
165
|
- - ">="
|
181
166
|
- !ruby/object:Gem::Version
|
182
167
|
segments:
|
183
168
|
- 2
|
184
169
|
- 6
|
185
|
-
-
|
186
|
-
version: 2.6.
|
170
|
+
- 1
|
171
|
+
version: 2.6.1
|
187
172
|
type: :development
|
188
|
-
version_requirements: *
|
173
|
+
version_requirements: *id010
|
189
174
|
description: |-
|
190
175
|
A suite for basic and advanced statistics on Ruby. Tested on Ruby 1.8.7, 1.9.1, 1.9.2 (April, 2010) and JRuby 1.4 (Ruby 1.8.7 compatible).
|
191
176
|
|
@@ -197,6 +182,7 @@ description: |-
|
|
197
182
|
* Tests: F, T, Levene, U-Mannwhitney.
|
198
183
|
* Regression: Simple, Multiple (OLS), Probit and Logit
|
199
184
|
* Factorial Analysis: Extraction (PCA and Principal Axis), Rotation (Varimax, Equimax, Quartimax) and Parallel Analysis, for estimation of number of factors.
|
185
|
+
* Reliability analysis for simple scale and helpers to analyze multiple scales using factor analysis and correlations
|
200
186
|
* Dominance Analysis, with multivariate dependent and bootstrap (Azen & Budescu)
|
201
187
|
* Sample calculation related formulas
|
202
188
|
* Creates reports on text, html and rtf, using ReportBuilder gem
|
@@ -224,6 +210,7 @@ files:
|
|
224
210
|
- data/test_binomial.csv
|
225
211
|
- data/tetmat_matrix.txt
|
226
212
|
- data/tetmat_test.txt
|
213
|
+
- doc_latex/manual/equations.tex
|
227
214
|
- examples/correlation_matrix.rb
|
228
215
|
- examples/dataset.rb
|
229
216
|
- examples/dominance_analysis.rb
|
@@ -244,6 +231,7 @@ files:
|
|
244
231
|
- lib/distribution/f.rb
|
245
232
|
- lib/distribution/normal.rb
|
246
233
|
- lib/distribution/normalbivariate.rb
|
234
|
+
- lib/distribution/normalmultivariate.rb
|
247
235
|
- lib/distribution/t.rb
|
248
236
|
- lib/spss.rb
|
249
237
|
- lib/statsample.rb
|
@@ -293,6 +281,8 @@ files:
|
|
293
281
|
- lib/statsample/regression/multiple/rubyengine.rb
|
294
282
|
- lib/statsample/regression/simple.rb
|
295
283
|
- lib/statsample/reliability.rb
|
284
|
+
- lib/statsample/reliability/multiscaleanalysis.rb
|
285
|
+
- lib/statsample/reliability/scaleanalysis.rb
|
296
286
|
- lib/statsample/resample.rb
|
297
287
|
- lib/statsample/srs.rb
|
298
288
|
- lib/statsample/test.rb
|
@@ -347,7 +337,25 @@ has_rdoc: true
|
|
347
337
|
homepage: http://ruby-statsample.rubyforge.org/
|
348
338
|
licenses: []
|
349
339
|
|
350
|
-
post_install_message:
|
340
|
+
post_install_message: |
|
341
|
+
***************************************************
|
342
|
+
Thanks for installing statsample.
|
343
|
+
|
344
|
+
On *nix, you should install statsample-optimization
|
345
|
+
to retrieve gems gsl, statistics2 and a C extension
|
346
|
+
to speed some methods.
|
347
|
+
|
348
|
+
$sudo gem install statsample-optimization
|
349
|
+
|
350
|
+
To use it, on Ubuntu I recommend install
|
351
|
+
build-essential and libgsl0-dev using apt-get and
|
352
|
+
compile ruby 1.8 or 1.9 from source code first.
|
353
|
+
|
354
|
+
$sudo apt-get install build-essential libgsl0-dev
|
355
|
+
|
356
|
+
|
357
|
+
*****************************************************
|
358
|
+
|
351
359
|
rdoc_options:
|
352
360
|
- --main
|
353
361
|
- README.txt
|
metadata.gz.sig
CHANGED
Binary file
|