Class: Statsample::Test::F
- Includes:
- Summarizable, Statsample::Test
- Defined in:
- lib/statsample/test/f.rb
Overview
From Wikipedia: An F-test is any statistical test in which the test statistic has an F-distribution under the null hypothesis. It is most often used when comparing statistical models that have been fit to a data set, in order to identify the model that best fits the population from which the data were sampled.
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.
-
#name ⇒ Object
Name of F analysis.
-
#tails ⇒ Object
Tails for probability (:both, :left or :right).
-
#var_den ⇒ Object
readonly
Returns the value of attribute var_den.
-
#var_num ⇒ Object
readonly
Returns the value of attribute var_num.
-
#var_total ⇒ Object
readonly
Returns the value of attribute var_total.
Instance Method Summary collapse
- #f ⇒ Object
-
#initialize(var_num, var_den, df_num, df_den, opts = Hash.new) ⇒ F
constructor
Parameters: * var_num: variance numerator * var_den: variance denominator * df_num: degrees of freedom numerator * df_den: degrees of freedom denominator.
-
#probability ⇒ Object
probability.
-
#report_building(builder) ⇒ Object
:nodoc:.
- #to_f ⇒ Object
Methods included from Summarizable
Methods included from Statsample::Test
chi_square, levene, #p_using_cdf, #t_critical, t_one_sample, t_two_samples_independent, u_mannwhitney, wilcoxon_signed_rank, #z_critical
Constructor Details
#initialize(var_num, var_den, df_num, df_den, opts = Hash.new) ⇒ F
Parameters:
-
var_num: variance numerator
-
var_den: variance denominator
-
df_num: degrees of freedom numerator
-
df_den: degrees of freedom denominator
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/statsample/test/f.rb', line 19 def initialize(var_num, var_den, df_num, df_den, opts=Hash.new) @var_num=var_num @var_den=var_den @df_num=df_num @df_den=df_den @var_total=var_num+var_den @df_total=df_num+df_den opts_default={:tails=>:right, :name=>_("F Test")} @opts=opts_default.merge(opts) raise "Tails should be right or left, not both" if @opts[:tails]==:both opts_default.keys.each {|k| send("#{k}=", @opts[k]) } end |
Instance Attribute Details
#df_den ⇒ Object (readonly)
Returns the value of attribute df_den.
8 9 10 |
# File 'lib/statsample/test/f.rb', line 8 def df_den @df_den end |
#df_num ⇒ Object (readonly)
Returns the value of attribute df_num.
8 9 10 |
# File 'lib/statsample/test/f.rb', line 8 def df_num @df_num end |
#df_total ⇒ Object (readonly)
Returns the value of attribute df_total.
8 9 10 |
# File 'lib/statsample/test/f.rb', line 8 def df_total @df_total end |
#name ⇒ Object
Name of F analysis
12 13 14 |
# File 'lib/statsample/test/f.rb', line 12 def name @name end |
#tails ⇒ Object
Tails for probability (:both, :left or :right)
10 11 12 |
# File 'lib/statsample/test/f.rb', line 10 def tails @tails end |
#var_den ⇒ Object (readonly)
Returns the value of attribute var_den.
8 9 10 |
# File 'lib/statsample/test/f.rb', line 8 def var_den @var_den end |
#var_num ⇒ Object (readonly)
Returns the value of attribute var_num.
8 9 10 |
# File 'lib/statsample/test/f.rb', line 8 def var_num @var_num end |
#var_total ⇒ Object (readonly)
Returns the value of attribute var_total.
8 9 10 |
# File 'lib/statsample/test/f.rb', line 8 def var_total @var_total end |
Instance Method Details
#f ⇒ Object
33 34 35 |
# File 'lib/statsample/test/f.rb', line 33 def f @var_num.quo(@var_den) end |
#probability ⇒ Object
probability
40 41 42 |
# File 'lib/statsample/test/f.rb', line 40 def probability p_using_cdf(Distribution::F.cdf(f, @df_num, @df_den), tails) end |
#report_building(builder) ⇒ Object
:nodoc:
43 44 45 46 47 48 49 |
# File 'lib/statsample/test/f.rb', line 43 def report_building(builder) #:nodoc: if @df_num.is_a? Integer and @df_den.is_a? Integer builder.text "%s : F(%d, %d) = %0.4f , p = %0.4f" % [@name, @df_num, @df_den, f, probability] else builder.text "%s : F(%0.2f, %0.2f) = %0.4f , p = %0.4f" % [@name, @df_num, @df_den, f, probability] end end |
#to_f ⇒ Object
36 37 38 |
# File 'lib/statsample/test/f.rb', line 36 def to_f f end |