Class: Statsample::Anova::OneWay
- Includes:
- Summarizable
- Defined in:
- lib/statsample/anova/oneway.rb
Overview
Generic Anova one-way.
You could enter the sum of squares or the mean squares. You should enter the degrees of freedom for numerator and denominator.
Usage
anova=Statsample::Anova::OneWay(:ss_num=>10,:ss_den=>20, :df_num=>2, :df_den=>10, @name=>"ANOVA for....")
Direct Known Subclasses
Instance Attribute Summary collapse
-
#df_den ⇒ Object
readonly
Returns the value of attribute df_den.
-
#df_num ⇒ Object
readonly
Returns the value of attribute df_num.
-
#df_total ⇒ Object
readonly
Returns the value of attribute df_total.
-
#ms_den ⇒ Object
readonly
Returns the value of attribute ms_den.
-
#ms_num ⇒ Object
readonly
Returns the value of attribute ms_num.
-
#ms_total ⇒ Object
readonly
Returns the value of attribute ms_total.
-
#name ⇒ Object
Name of ANOVA Analisys.
-
#name_denominator ⇒ Object
Returns the value of attribute name_denominator.
-
#name_numerator ⇒ Object
Returns the value of attribute name_numerator.
-
#ss_den ⇒ Object
readonly
Returns the value of attribute ss_den.
-
#ss_num ⇒ Object
readonly
Returns the value of attribute ss_num.
-
#ss_total ⇒ Object
readonly
Returns the value of attribute ss_total.
Instance Method Summary collapse
-
#f ⇒ Object
F value.
-
#initialize(opts = Hash.new) ⇒ OneWay
constructor
A new instance of OneWay.
-
#probability ⇒ Object
P-value of F test.
-
#report_building(builder) ⇒ Object
:nodoc:.
-
#report_building_table(builder) ⇒ Object
:nodoc:.
Methods included from Summarizable
Constructor Details
#initialize(opts = Hash.new) ⇒ OneWay
Returns a new instance of OneWay.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/statsample/anova/oneway.rb', line 15 def initialize(opts=Hash.new) @name=@name_numerator=@name_denominator=nil # First see if sum of squares or mean squares are entered raise ArgumentError, "You should set d.f." unless (opts.has_key? :df_num and opts.has_key? :df_den) @df_num=opts.delete :df_num @df_den=opts.delete :df_den @df_total=@df_num+@df_den if(opts.has_key? :ss_num and opts.has_key? :ss_den) @ss_num = opts.delete :ss_num @ss_den =opts.delete :ss_den @ms_num =@ss_num.quo(@df_num) @ms_den =@ss_den.quo(@df_den) elsif (opts.has_key? :ms_num and opts.has_key? :ms_den) @ms_num =opts.delete :ms_num @ms_den =opts.delete :ms_den @ss_num =@ms_num * @df_num @ss_den =@ss_den * @df_den end @ss_total=@ss_num+@ss_den @ms_total=@ms_num+@ms_den opts_default={:name=>"ANOVA", :name_denominator=>_("Explained variance"), :name_numerator=>_("Unexplained variance")} @opts=opts_default.merge(opts) opts.keys.each {|k| send("#{k}=", @opts[k]) if self.respond_to? "#{k}=" } @f_object=Statsample::Test::F.new(@ms_num, @ms_den, @df_num,@df_den) end |
Instance Attribute Details
#df_den ⇒ Object (readonly)
Returns the value of attribute df_den.
10 11 12 |
# File 'lib/statsample/anova/oneway.rb', line 10 def df_den @df_den end |
#df_num ⇒ Object (readonly)
Returns the value of attribute df_num.
10 11 12 |
# File 'lib/statsample/anova/oneway.rb', line 10 def df_num @df_num end |
#df_total ⇒ Object (readonly)
Returns the value of attribute df_total.
10 11 12 |
# File 'lib/statsample/anova/oneway.rb', line 10 def df_total @df_total end |
#ms_den ⇒ Object (readonly)
Returns the value of attribute ms_den.
10 11 12 |
# File 'lib/statsample/anova/oneway.rb', line 10 def ms_den @ms_den end |
#ms_num ⇒ Object (readonly)
Returns the value of attribute ms_num.
10 11 12 |
# File 'lib/statsample/anova/oneway.rb', line 10 def ms_num @ms_num end |
#ms_total ⇒ Object (readonly)
Returns the value of attribute ms_total.
10 11 12 |
# File 'lib/statsample/anova/oneway.rb', line 10 def ms_total @ms_total end |
#name ⇒ Object
Name of ANOVA Analisys
12 13 14 |
# File 'lib/statsample/anova/oneway.rb', line 12 def name @name end |
#name_denominator ⇒ Object
Returns the value of attribute name_denominator.
13 14 15 |
# File 'lib/statsample/anova/oneway.rb', line 13 def name_denominator @name_denominator end |
#name_numerator ⇒ Object
Returns the value of attribute name_numerator.
14 15 16 |
# File 'lib/statsample/anova/oneway.rb', line 14 def name_numerator @name_numerator end |
#ss_den ⇒ Object (readonly)
Returns the value of attribute ss_den.
10 11 12 |
# File 'lib/statsample/anova/oneway.rb', line 10 def ss_den @ss_den end |
#ss_num ⇒ Object (readonly)
Returns the value of attribute ss_num.
10 11 12 |
# File 'lib/statsample/anova/oneway.rb', line 10 def ss_num @ss_num end |
#ss_total ⇒ Object (readonly)
Returns the value of attribute ss_total.
10 11 12 |
# File 'lib/statsample/anova/oneway.rb', line 10 def ss_total @ss_total end |
Instance Method Details
#probability ⇒ Object
P-value of F test
50 51 52 |
# File 'lib/statsample/anova/oneway.rb', line 50 def probability @f_object.probability end |
#report_building(builder) ⇒ Object
:nodoc:
53 54 55 56 57 |
# File 'lib/statsample/anova/oneway.rb', line 53 def report_building(builder) #:nodoc: builder.section(:name=>@name) do |b| report_building_table(b) end end |
#report_building_table(builder) ⇒ Object
:nodoc:
58 59 60 61 62 63 64 |
# File 'lib/statsample/anova/oneway.rb', line 58 def report_building_table(builder) #:nodoc: builder.table(:name=>_("%s Table") % @name, :header=>%w{source ss df ms f p}.map {|v| _(v)}) do |t| t.row([@name_numerator, sprintf("%0.3f",@ss_num), @df_num, sprintf("%0.3f",@ms_num), sprintf("%0.3f",f), sprintf("%0.3f", probability)]) t.row([@name_denominator, sprintf("%0.3f",@ss_den), @df_den, sprintf("%0.3f",@ms_den), "", ""]) t.row([_("Total"), sprintf("%0.3f",@ss_total), @df_total, sprintf("%0.3f",@ms_total),"",""]) end end |