Class: Statsample::DominanceAnalysis::ModelData
- Defined in:
- lib/statsample/dominanceanalysis.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#contributions ⇒ Object
readonly
Returns the value of attribute contributions.
Instance Method Summary collapse
- #add_contribution(f, v) ⇒ Object
- #add_table_row ⇒ Object
-
#initialize(independent, data, da) ⇒ ModelData
constructor
A new instance of ModelData.
- #name ⇒ Object
- #r2 ⇒ Object
- #summary ⇒ Object
Constructor Details
#initialize(independent, data, da) ⇒ ModelData
Returns a new instance of ModelData.
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'lib/statsample/dominanceanalysis.rb', line 364 def initialize(independent, data, da) @independent=independent @data=data @predictors=da.predictors @dependent=da.dependent @cases=da.cases @method=da.method_association @contributions=@independent.inject({}){|a,v| a[v]=nil;a} r_class=da.regression_class if @dependent.size==1 @lr=r_class.new(data, @dependent[0], :cases=>@cases) else @lr=r_class.new(data, @dependent, :cases=>@cases) end end |
Instance Attribute Details
#contributions ⇒ Object (readonly)
Returns the value of attribute contributions.
363 364 365 |
# File 'lib/statsample/dominanceanalysis.rb', line 363 def contributions @contributions end |
Instance Method Details
#add_contribution(f, v) ⇒ Object
381 382 383 |
# File 'lib/statsample/dominanceanalysis.rb', line 381 def add_contribution(f, v) @contributions[f]=v-r2 end |
#add_table_row ⇒ Object
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 |
# File 'lib/statsample/dominanceanalysis.rb', line 392 def add_table_row if @cases sign=sprintf("%0.3f", @lr.probability) else sign="???" end [name, sprintf("%0.3f",r2), sign] + @predictors.collect{|k| v=@contributions[k] if v.nil? "--" else sprintf("%0.3f",v) end } end |
#name ⇒ Object
387 388 389 390 391 |
# File 'lib/statsample/dominanceanalysis.rb', line 387 def name @independent.collect {|variable| DominanceAnalysis.predictor_name(variable) }.join("*") end |
#r2 ⇒ Object
384 385 386 |
# File 'lib/statsample/dominanceanalysis.rb', line 384 def r2 @lr.send(@method) end |
#summary ⇒ Object
408 409 410 411 412 413 414 415 416 417 418 419 420 |
# File 'lib/statsample/dominanceanalysis.rb', line 408 def summary out=sprintf("%s: r2=%0.3f(p=%0.2f)\n",name, r2, @lr.significance, @lr.sst) out << @predictors.collect{|k| v=@contributions[k] if v.nil? "--" else sprintf("%s=%0.3f",k,v) end }.join(" | ") out << "\n" return out end |