Sha256: e58377883f6223e855c698744c44dfb9a8e92885e9e5f99792a51914465f80cf

Contents?: true

Size: 839 Bytes

Versions: 10

Compression:

Stored size: 839 Bytes

Contents

#!/usr/bin/ruby
$:.unshift(File.dirname(__FILE__)+'/../lib/')

require 'statsample'

Statsample::Analysis.store(Statsample::Factor::MAP) do
  
  rng=Distribution::Normal.rng
  samples=100
  variables=10
  
  f1=rnorm(samples)
  f2=rnorm(samples)
  
  vectors={}
  
  variables.times do |i|
  vectors["v#{i}"]=samples.times.collect {|nv|    
  if i<5
    f1[nv]*5 + f2[nv] *2 +rng.call
  else
    f1[nv]*2 + f2[nv] *3 +rng.call
  end
  }.to_scale
  end
  
  
  ds=vectors.to_dataset
  cor=cor(ds)
  pca=pca(cor)
  
  map=Statsample::Factor::MAP.new(cor)
  
  echo ("There are 2 real factors on data")
  summary(pca)
  echo("Traditional Kaiser criterion (k>1) returns #{pca.m} factors")
  summary(map)
  echo("Velicer's MAP Test returns #{map.number_of_factors} factors to preserve")
end
if __FILE__==$0
  Statsample::Analysis.run_batch
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
statsample-1.4.3 examples/velicer_map_test.rb
statsample-1.4.2 examples/velicer_map_test.rb
statsample-1.4.1 examples/velicer_map_test.rb
statsample-1.4.0 examples/velicer_map_test.rb
statsample-1.3.1 examples/velicer_map_test.rb
statsample-1.3.0 examples/velicer_map_test.rb
statsample-1.2.0 examples/velicer_map_test.rb
statsample-1.1.0 examples/velicer_map_test.rb
statsample-1.0.1 examples/velicer_map_test.rb
statsample-1.0.0 examples/velicer_map_test.rb