examples/dominance_analysis_bootstrap.rb in statsample-0.18.0 vs examples/dominance_analysis_bootstrap.rb in statsample-1.0.0

- old
+ new

@@ -1,27 +1,33 @@ #!/usr/bin/ruby $:.unshift(File.dirname(__FILE__)+'/../lib/') require 'statsample' +Statsample::Analysis.store(Statsample::DominanceAnalysis::Bootstrap) do + + sample=300 + a=rnorm(sample) + b=rnorm(sample) + c=rnorm(sample) + d=rnorm(sample) + a.name="a" + b.name="b" + c.name="c" + d.name="d" + + ds={'a'=>a,'b'=>b,'cc'=>c,'d'=>d}.to_dataset + attach(ds) + ds['y1']=a*5+b*2+cc*2+d*2+rnorm(sample,0,10) + ds['y2']=a*10+rnorm(sample) + + dab=dominance_analysis_bootstrap(ds, ['y1','y2'], :debug=>true) + dab.bootstrap(100,nil) + summary(dab) + ds2=ds['a'..'y1'] + dab2=dominance_analysis_bootstrap(ds2, 'y1', :debug=>true) + dab2.bootstrap(100,nil) + summary(dab2) +end -a=100.times.collect {rand}.to_scale -b=100.times.collect {rand}.to_scale -c=100.times.collect {rand}.to_scale -d=100.times.collect {rand}.to_scale - -a.name="a" -b.name="b" -c.name="c" -d.name="d" - -ds={'a'=>a,'b'=>b,'c'=>c,'d'=>d}.to_dataset - -ds['y1']=ds.collect{|row| row['a']*5+row['b']*2+row['c']*2+row['d']*2+10*rand()} -ds['y2']=ds.collect{|row| row['a']*10+rand()} - -dab=Statsample::DominanceAnalysis::Bootstrap.new(ds, ['y1','y2'], :debug=>true) -dab.bootstrap(100,nil) -puts dab.summary -ds2=ds['a'..'y1'] -dab=Statsample::DominanceAnalysis::Bootstrap.new(ds2, 'y1', :debug=>true) -dab.bootstrap(100,nil) -puts dab.summary +if __FILE__==$0 + Statsample::Analysis.run_batch +end