statsample 0.14.0 → 0.14.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,8 +6,8 @@
6
6
  #, fuzzy
7
7
  msgid ""
8
8
  msgstr ""
9
- "Project-Id-Version: statsample 0.13.1\n"
10
- "POT-Creation-Date: 2010-08-10 17:00-0400\n"
9
+ "Project-Id-Version: statsample 0.14.0\n"
10
+ "POT-Creation-Date: 2010-08-17 18:46-0400\n"
11
11
  "PO-Revision-Date: 2009-08-04 15:36-0400\n"
12
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -24,8 +24,8 @@ msgstr ""
24
24
  msgid "Mean and standard deviation"
25
25
  msgstr ""
26
26
 
27
- #: lib/statsample/test/t.rb:209 lib/statsample/factor/pca.rb:169
28
- #: lib/statsample/factor/principalaxis.rb:190
27
+ #: lib/statsample/test/t.rb:209 lib/statsample/factor/pca.rb:163
28
+ #: lib/statsample/factor/principalaxis.rb:202
29
29
  msgid "Variable"
30
30
  msgstr ""
31
31
 
@@ -38,7 +38,8 @@ msgstr ""
38
38
  msgid "sd"
39
39
  msgstr ""
40
40
 
41
- #: lib/statsample/test/t.rb:209 lib/statsample/factor/parallelanalysis.rb:79
41
+ #: lib/statsample/test/t.rb:209 lib/statsample/factor/parallelanalysis.rb:100
42
+ #: lib/statsample/factor/parallelanalysis.rb:108
42
43
  msgid "n"
43
44
  msgstr ""
44
45
 
@@ -91,6 +92,10 @@ msgstr ""
91
92
  msgid "Levene Test"
92
93
  msgstr ""
93
94
 
95
+ #: lib/statsample/test/bartlettsphericity.rb:25
96
+ msgid "Bartlett's test of sphericity"
97
+ msgstr ""
98
+
94
99
  #: lib/statsample/regression/multiple/baseengine.rb:25
95
100
  msgid "Multiple Regression: %s over %s"
96
101
  msgstr ""
@@ -266,11 +271,11 @@ msgstr ""
266
271
  msgid "Descriptives"
267
272
  msgstr ""
268
273
 
269
- #: lib/statsample/bivariate/pearson.rb:33
274
+ #: lib/statsample/bivariate/pearson.rb:32
270
275
  msgid "Correlation (%s - %s)"
271
276
  msgstr ""
272
277
 
273
- #: lib/statsample/bivariate/pearson.rb:51
278
+ #: lib/statsample/bivariate/pearson.rb:50
274
279
  msgid "%s : r=%0.3f (t:%0.3f, g.l.=%d, p:%0.3f / %s tails)"
275
280
  msgstr ""
276
281
 
@@ -278,143 +283,186 @@ msgstr ""
278
283
  msgid "Histogram %s"
279
284
  msgstr ""
280
285
 
281
- #: lib/statsample/factor/parallelanalysis.rb:51
286
+ #: lib/statsample/factor/parallelanalysis.rb:70
282
287
  msgid "Parallel Analysis"
283
288
  msgstr ""
284
289
 
285
- #: lib/statsample/factor/parallelanalysis.rb:73
290
+ #: lib/statsample/factor/parallelanalysis.rb:93
286
291
  msgid "Bootstrap Method: %s"
287
292
  msgstr ""
288
293
 
289
- #: lib/statsample/factor/parallelanalysis.rb:74
294
+ #: lib/statsample/factor/parallelanalysis.rb:94
295
+ msgid "Uses SMC: %s"
296
+ msgstr ""
297
+
298
+ #: lib/statsample/factor/parallelanalysis.rb:94
299
+ msgid "Yes"
300
+ msgstr ""
301
+
302
+ #: lib/statsample/factor/parallelanalysis.rb:94
303
+ msgid "No"
304
+ msgstr ""
305
+
306
+ #: lib/statsample/factor/parallelanalysis.rb:95
290
307
  msgid "Correlation Matrix type : %s"
291
308
  msgstr ""
292
309
 
293
- #: lib/statsample/factor/parallelanalysis.rb:75
310
+ #: lib/statsample/factor/parallelanalysis.rb:96
294
311
  msgid "Number of variables: %d"
295
312
  msgstr ""
296
313
 
297
- #: lib/statsample/factor/parallelanalysis.rb:76
314
+ #: lib/statsample/factor/parallelanalysis.rb:97
298
315
  msgid "Number of cases: %d"
299
316
  msgstr ""
300
317
 
301
- #: lib/statsample/factor/parallelanalysis.rb:77
318
+ #: lib/statsample/factor/parallelanalysis.rb:98
302
319
  msgid "Number of iterations: %d"
303
320
  msgstr ""
304
321
 
305
- #: lib/statsample/factor/parallelanalysis.rb:78
306
- msgid "Number or factors to preserve: %d"
322
+ #: lib/statsample/factor/parallelanalysis.rb:100
323
+ #: lib/statsample/factor/parallelanalysis.rb:108
324
+ #: lib/statsample/factor/map.rb:90
325
+ msgid "Eigenvalues"
307
326
  msgstr ""
308
327
 
309
- #: lib/statsample/factor/parallelanalysis.rb:79
310
- msgid "Eigenvalues"
328
+ #: lib/statsample/factor/parallelanalysis.rb:100
329
+ #: lib/statsample/factor/parallelanalysis.rb:108
330
+ msgid "generated eigenvalue"
311
331
  msgstr ""
312
332
 
313
- #: lib/statsample/factor/parallelanalysis.rb:79
314
- msgid "data eigenvalue"
333
+ #: lib/statsample/factor/parallelanalysis.rb:107
334
+ msgid "Number or factors to preserve: %d"
315
335
  msgstr ""
316
336
 
317
- #: lib/statsample/factor/parallelanalysis.rb:79
318
- msgid "generated eigenvalue"
337
+ #: lib/statsample/factor/parallelanalysis.rb:108
338
+ msgid "data eigenvalue"
319
339
  msgstr ""
320
340
 
321
- #: lib/statsample/factor/parallelanalysis.rb:79
341
+ #: lib/statsample/factor/parallelanalysis.rb:108
322
342
  msgid "preserve?"
323
343
  msgstr ""
324
344
 
325
- #: lib/statsample/factor/pca.rb:51
345
+ #: lib/statsample/factor/map.rb:54
346
+ msgid "Velicer's MAP"
347
+ msgstr ""
348
+
349
+ #: lib/statsample/factor/map.rb:90
350
+ msgid "Value"
351
+ msgstr ""
352
+
353
+ #: lib/statsample/factor/map.rb:95
354
+ msgid "Velicer's Average Squared Correlations"
355
+ msgstr ""
356
+
357
+ #: lib/statsample/factor/map.rb:95
358
+ msgid "number of components"
359
+ msgstr ""
360
+
361
+ #: lib/statsample/factor/map.rb:95
362
+ msgid "average square correlation"
363
+ msgstr ""
364
+
365
+ #: lib/statsample/factor/map.rb:100
366
+ msgid "The smallest average squared correlation is : %0.6f"
367
+ msgstr ""
368
+
369
+ #: lib/statsample/factor/map.rb:101
370
+ msgid "The number of components is : %d"
371
+ msgstr ""
372
+
373
+ #: lib/statsample/factor/pca.rb:50
326
374
  msgid "Principal Component Analysis"
327
375
  msgstr ""
328
376
 
329
- #: lib/statsample/factor/pca.rb:118
377
+ #: lib/statsample/factor/pca.rb:117
330
378
  msgid "Component matrix"
331
379
  msgstr ""
332
380
 
333
- #: lib/statsample/factor/pca.rb:168 lib/statsample/factor/principalaxis.rb:188
381
+ #: lib/statsample/factor/pca.rb:162 lib/statsample/factor/principalaxis.rb:200
334
382
  msgid "Number of factors: %d"
335
383
  msgstr ""
336
384
 
337
- #: lib/statsample/factor/pca.rb:169 lib/statsample/factor/principalaxis.rb:190
385
+ #: lib/statsample/factor/pca.rb:163 lib/statsample/factor/principalaxis.rb:202
338
386
  msgid "Communalities"
339
387
  msgstr ""
340
388
 
341
- #: lib/statsample/factor/pca.rb:169 lib/statsample/factor/principalaxis.rb:190
389
+ #: lib/statsample/factor/pca.rb:163 lib/statsample/factor/principalaxis.rb:202
342
390
  msgid "Initial"
343
391
  msgstr ""
344
392
 
345
- #: lib/statsample/factor/pca.rb:169 lib/statsample/factor/principalaxis.rb:190
393
+ #: lib/statsample/factor/pca.rb:163 lib/statsample/factor/principalaxis.rb:202
346
394
  msgid "Extraction"
347
395
  msgstr ""
348
396
 
349
- #: lib/statsample/factor/pca.rb:175
397
+ #: lib/statsample/factor/pca.rb:169
350
398
  msgid "Total Variance Explained"
351
399
  msgstr ""
352
400
 
353
- #: lib/statsample/factor/pca.rb:175
401
+ #: lib/statsample/factor/pca.rb:169
354
402
  msgid "Component"
355
403
  msgstr ""
356
404
 
357
- #: lib/statsample/factor/pca.rb:175
405
+ #: lib/statsample/factor/pca.rb:169
358
406
  msgid "E.Total"
359
407
  msgstr ""
360
408
 
361
- #: lib/statsample/factor/pca.rb:175
409
+ #: lib/statsample/factor/pca.rb:169
362
410
  msgid "%"
363
411
  msgstr ""
364
412
 
365
- #: lib/statsample/factor/pca.rb:175
413
+ #: lib/statsample/factor/pca.rb:169
366
414
  msgid "Cum. %"
367
415
  msgstr ""
368
416
 
369
- #: lib/statsample/factor/pca.rb:179
417
+ #: lib/statsample/factor/pca.rb:173
370
418
  msgid "Component %d"
371
419
  msgstr ""
372
420
 
373
- #: lib/statsample/factor/principalaxis.rb:64
421
+ #: lib/statsample/factor/principalaxis.rb:71
374
422
  msgid "Variable %d"
375
423
  msgstr ""
376
424
 
377
- #: lib/statsample/factor/principalaxis.rb:140
425
+ #: lib/statsample/factor/principalaxis.rb:147
378
426
  msgid "Factor Matrix"
379
427
  msgstr ""
380
428
 
381
- #: lib/statsample/factor/principalaxis.rb:189
429
+ #: lib/statsample/factor/principalaxis.rb:201
382
430
  msgid "Iterations: %d"
383
431
  msgstr ""
384
432
 
385
- #: lib/statsample/factor/principalaxis.rb:195
433
+ #: lib/statsample/factor/principalaxis.rb:207
386
434
  msgid "Total Variance"
387
435
  msgstr ""
388
436
 
389
- #: lib/statsample/factor/principalaxis.rb:195
437
+ #: lib/statsample/factor/principalaxis.rb:207
390
438
  msgid "Factor"
391
439
  msgstr ""
392
440
 
393
- #: lib/statsample/factor/principalaxis.rb:195
441
+ #: lib/statsample/factor/principalaxis.rb:207
394
442
  msgid "I.E.Total"
395
443
  msgstr ""
396
444
 
397
- #: lib/statsample/factor/principalaxis.rb:195
445
+ #: lib/statsample/factor/principalaxis.rb:207
398
446
  msgid "I.E. %"
399
447
  msgstr ""
400
448
 
401
- #: lib/statsample/factor/principalaxis.rb:195
449
+ #: lib/statsample/factor/principalaxis.rb:207
402
450
  msgid "I.E.Cum. %"
403
451
  msgstr ""
404
452
 
405
- #: lib/statsample/factor/principalaxis.rb:196
453
+ #: lib/statsample/factor/principalaxis.rb:208
406
454
  msgid "S.L.Total"
407
455
  msgstr ""
408
456
 
409
- #: lib/statsample/factor/principalaxis.rb:196
457
+ #: lib/statsample/factor/principalaxis.rb:208
410
458
  msgid "S.L. %"
411
459
  msgstr ""
412
460
 
413
- #: lib/statsample/factor/principalaxis.rb:196
461
+ #: lib/statsample/factor/principalaxis.rb:208
414
462
  msgid "S.L.Cum. %"
415
463
  msgstr ""
416
464
 
417
- #: lib/statsample/factor/principalaxis.rb:203
465
+ #: lib/statsample/factor/principalaxis.rb:215
418
466
  msgid "Factor %d"
419
467
  msgstr ""
420
468
 
@@ -430,31 +478,31 @@ msgstr ""
430
478
  msgid "Component transformation matrix"
431
479
  msgstr ""
432
480
 
433
- #: lib/statsample/reliability/multiscaleanalysis.rb:57
481
+ #: lib/statsample/reliability/multiscaleanalysis.rb:58
434
482
  msgid "Multiple Scale analysis"
435
483
  msgstr ""
436
484
 
437
- #: lib/statsample/reliability/multiscaleanalysis.rb:85
485
+ #: lib/statsample/reliability/multiscaleanalysis.rb:86
438
486
  msgid "Scale %s"
439
487
  msgstr ""
440
488
 
441
- #: lib/statsample/reliability/multiscaleanalysis.rb:125
489
+ #: lib/statsample/reliability/multiscaleanalysis.rb:128
442
490
  msgid "Reliability analysis of scales"
443
491
  msgstr ""
444
492
 
445
- #: lib/statsample/reliability/multiscaleanalysis.rb:131
493
+ #: lib/statsample/reliability/multiscaleanalysis.rb:134
446
494
  msgid "Correlation matrix for %s"
447
495
  msgstr ""
448
496
 
449
- #: lib/statsample/reliability/multiscaleanalysis.rb:136
497
+ #: lib/statsample/reliability/multiscaleanalysis.rb:139
450
498
  msgid "PCA for %s"
451
499
  msgstr ""
452
500
 
453
- #: lib/statsample/reliability/multiscaleanalysis.rb:141
501
+ #: lib/statsample/reliability/multiscaleanalysis.rb:144
454
502
  msgid "Principal Axis for %s"
455
503
  msgstr ""
456
504
 
457
- #: lib/statsample/reliability/multiscaleanalysis.rb:147
505
+ #: lib/statsample/reliability/multiscaleanalysis.rb:150
458
506
  msgid "Parallel Analysis for %s"
459
507
  msgstr ""
460
508
 
@@ -0,0 +1,17 @@
1
+ # Retrieve Correlation matrix for eigth variables
2
+ module Statsample
3
+ module Fixtures
4
+ def harman_817
5
+ Matrix[
6
+ [1.0, 0.84, 0.62, -0.53, 0.03, 0.57, -0.33, -0.63],
7
+ [0.84, 1.00, 0.84, -0.68, -0.05, 0.76, -0.35, -0.73],
8
+ [0.62, 0.84, 1.00, -0.76, 0.08, 0.81, -0.51, -0.81],
9
+ [-0.53, -0.68, -0.76, 1.00, -0.25, -0.80, 0.62, 0.88],
10
+ [0.03, -0.05, 0.08, -0.25, 1.00, 0.25, -0.72, -0.36],
11
+ [0.57, 0.76, 0.81, -0.80, 0.25, 1.00, -0.58, -0.84],
12
+ [-0.33, -0.35, -0.51, 0.62, -0.72, -0.58, 1.00, 0.68],
13
+ [-0.63, -0.73, -0.81, 0.88, -0.36, -0.84, 0.68, 1.00]
14
+ ].extend(Statsample::CovariateMatrix)
15
+ end
16
+ end
17
+ end
@@ -1,10 +1,12 @@
1
1
  $:.unshift(File.dirname(__FILE__)+'/../lib/')
2
+ $:.unshift(File.dirname(__FILE__)+'/')
2
3
 
3
4
  require 'statsample'
4
5
  require 'minitest/unit'
5
6
  require 'tempfile'
6
7
  require 'tmpdir'
7
8
  require 'shoulda'
9
+ require 'fixtures/correlation_matrix'
8
10
 
9
11
  module MiniTest
10
12
  class Unit
@@ -0,0 +1,26 @@
1
+ require(File.dirname(__FILE__)+'/helpers_tests.rb')
2
+
3
+
4
+ class StatsampleBartlettSphericityTestCase < MiniTest::Unit::TestCase
5
+ include Statsample::Test
6
+ context Statsample::Test::BartlettSphericity do
7
+ setup do
8
+ @v1=[1 ,2 ,3 ,4 ,7 ,8 ,9 ,10,14,15,20,50,60,70].to_scale
9
+ @v2=[5 ,6 ,11,12,13,16,17,18,19,20,30,0,0,0].to_scale
10
+ @v3=[10,3 ,20,30,40,50,80,10,20,30,40,2,3,4].to_scale
11
+ # KMO: 0.490
12
+ ds={'v1'=>@v1,'v2'=>@v2,'v3'=>@v3}.to_dataset
13
+ cor=Statsample::Bivariate.correlation_matrix(ds)
14
+ @bs=Statsample::Test::BartlettSphericity.new(cor, 14)
15
+ end
16
+ should "have correct value for chi" do
17
+ assert_in_delta(9.477, @bs.value,0.001)
18
+ end
19
+ should "have correct value for df" do
20
+ assert_equal(3, @bs.df)
21
+ end
22
+ should "have correct value for probability" do
23
+ assert_in_delta(0.024,@bs.probability,0.001)
24
+ end
25
+ end
26
+ end
@@ -1,11 +1,70 @@
1
1
  require(File.dirname(__FILE__)+'/helpers_tests.rb')
2
2
 
3
3
  class StatsampleFactorTestCase < MiniTest::Unit::TestCase
4
+ include Statsample::Fixtures
5
+ def test_antiimage
6
+ cor=Matrix[[1,0.964, 0.312],[0.964,1,0.411],[0.312,0.411,1]]
7
+ expected=Matrix[[0.062,-0.057, 0.074],[-0.057, 0.057, -0.089], [0.074, -0.089, 0.729]]
8
+ ai=Statsample::Factor.anti_image_covariance_matrix(cor)
9
+ assert(Matrix.equal_in_delta?(expected, ai, 0.01), "#{expected.to_s} not equal to #{ai.to_s}")
10
+ end
11
+ def test_kmo
12
+ @v1=[1 ,2 ,3 ,4 ,7 ,8 ,9 ,10,14,15,20,50,60,70].to_scale
13
+ @v2=[5 ,6 ,11,12,13,16,17,18,19,20,30,0,0,0].to_scale
14
+ @v3=[10,3 ,20,30,40,50,80,10,20,30,40,2,3,4].to_scale
15
+ # KMO: 0.490
16
+ ds={'v1'=>@v1,'v2'=>@v2,'v3'=>@v3}.to_dataset
17
+ cor=Statsample::Bivariate.correlation_matrix(ds)
18
+ kmo=Statsample::Factor.kmo(cor)
19
+ assert_in_delta(0.667, kmo,0.001)
20
+ assert_in_delta(0.81, Statsample::Factor.kmo(harman_817),0.01)
21
+
22
+ end
23
+ def test_kmo_univariate
24
+ m=harman_817
25
+ expected=[0.73,0.76,0.84,0.87,0.53,0.93,0.78,0.86]
26
+ m.row_size.times.map {|i|
27
+ assert_in_delta(expected[i], Statsample::Factor.kmo_univariate(m,i),0.01)
28
+ }
29
+ end
30
+ def test_parallelanalysis_with_data
31
+ samples=100
32
+ variables=10
33
+ iterations=50
34
+ rng = GSL::Rng.alloc()
35
+ f1=samples.times.collect {rng.ugaussian()}.to_scale
36
+ f2=samples.times.collect {rng.ugaussian()}.to_scale
37
+ vectors={}
38
+ variables.times do |i|
39
+ if i<5
40
+ vectors["v#{i}"]=samples.times.collect {|nv|
41
+ f1[nv]*5+f2[nv]*2+rng.ugaussian()
42
+ }.to_scale
43
+ else
44
+ vectors["v#{i}"]=samples.times.collect {|nv|
45
+ f2[nv]*5+f1[nv]*2+rng.ugaussian()
46
+ }.to_scale
47
+ end
48
+
49
+ end
50
+ ds=vectors.to_dataset
51
+
52
+ pa1=Statsample::Factor::ParallelAnalysis.new(ds, :bootstrap_method=>:data, :iterations=>iterations)
53
+ pa2=Statsample::Factor::ParallelAnalysis.with_random_data(samples,variables,:iterations=>iterations,:percentil=>95)
54
+ 3.times do |n|
55
+ var="ev_0000#{n+1}"
56
+ assert_in_delta(pa1.ds_eigenvalues[var].mean,pa2.ds_eigenvalues[var].mean,0.04)
57
+ end
58
+ end
4
59
  def test_parallelanalysis
5
- pa=Statsample::Factor::ParallelAnalysis.with_random_data(305,8,150)
60
+ pa=Statsample::Factor::ParallelAnalysis.with_random_data(305,8,:iterations=>100,:percentil=>95)
6
61
  assert_in_delta(1.2454, pa.ds_eigenvalues['ev_00001'].mean, 0.01)
7
62
  assert_in_delta(1.1542, pa.ds_eigenvalues['ev_00002'].mean, 0.01)
8
63
  assert_in_delta(1.0836, pa.ds_eigenvalues['ev_00003'].mean, 0.01)
64
+ #puts pa.summary
65
+ assert(pa.summary.size>0)
66
+ #pa=Statsample::Factor::ParallelAnalysis.with_random_data(305,8,100, 95, true)
67
+ #puts pa.summary
9
68
  end
10
69
  def test_map
11
70
  fields=%w{height arm.span forearm lower.leg weight bitro.diameter chest.girth chest.width}
@@ -69,8 +128,10 @@ class StatsampleFactorTestCase < MiniTest::Unit::TestCase
69
128
  def test_principalaxis
70
129
  matrix=::Matrix[
71
130
  [1.0, 0.709501601093587, 0.877596585880047, 0.272219316266807], [0.709501601093587, 1.0, 0.291633797330304, 0.871141831433844], [0.877596585880047, 0.291633797330304, 1.0, -0.213373722977167], [0.272219316266807, 0.871141831433844, -0.213373722977167, 1.0]]
72
- fa=Statsample::Factor::PrincipalAxis.new(matrix,:m=>1, :max_iterations=>50)
73
131
 
132
+
133
+ fa=Statsample::Factor::PrincipalAxis.new(matrix,:m=>1, :max_iterations=>50)
134
+
74
135
  cm=::Matrix[[0.923],[0.912],[0.507],[0.483]]
75
136
 
76
137
  _test_matrix(cm,fa.component_matrix)