Class/Module Index [+]

Quicksearch

Statsample::Anova::OneWayWithVectors

One Way Anova with vectors Example:

v1=[2,3,4,5,6].to_scale
v2=[3,3,4,5,6].to_scale
v3=[5,3,1,5,6].to_scale
anova=Statsample::Anova::OneWayWithVectors.new([v1,v2,v3])
anova.f
=> 0.0243902439024391
anova.probability
=> 0.975953044203438
anova.sst 
=> 32.9333333333333

Attributes

summary_levene[RW]

Show on summary Levene test

summary_descriptives[RW]

Show on summary descriptives for vectors

Public Class Methods

new(*args) click to toggle source
# File lib/statsample/anova/oneway.rb, line 83
def initialize(*args)
  if args[0].is_a? Array
    @vectors=args.shift
  else
    @vectors=args.find_all {|v| v.is_a? Statsample::Vector}
    opts=args.find {|v| v.is_a? Hash}
  end
  opts||=Hash.new
  opts_default={:name=>_("Anova One-Way"), 
                :name_numerator=>_("Between Groups"),
                :name_denominator=>_("Within Groups"),
                :summary_descriptives=>false,
                :summary_levene=>true}
  @opts=opts_default.merge(opts).merge(:ss_num=>ssbg, :ss_den=>sswg, :df_num=>df_bg, :df_den=>df_wg)
  super(@opts)
end

Public Instance Methods

df_bg() click to toggle source

Degrees of freedom between groups

# File lib/statsample/anova/oneway.rb, line 127
def df_bg
    k-1
end
df_wg() click to toggle source

Degrees of freedom within groups

# File lib/statsample/anova/oneway.rb, line 120
def df_wg
  @dk_wg||=n-k
end
k() click to toggle source
# File lib/statsample/anova/oneway.rb, line 123
def k
  @k||=@vectors.size
end
levene() click to toggle source
# File lib/statsample/anova/oneway.rb, line 100
def levene
  Statsample::Test.levene(@vectors, :name=>_("Test of Homogeneity of variances (Levene)"))
end
n() click to toggle source

Total number of cases

# File lib/statsample/anova/oneway.rb, line 131
def n
    @vectors.inject(0){|a,v| a+v.size}
end
ssbg() click to toggle source

Sum of squares between groups

# File lib/statsample/anova/oneway.rb, line 113
def ssbg
  m=total_mean
  @vectors.inject(0) do |total,vector|
    total + (vector.mean-m).square * vector.size 
  end
end
sswg() click to toggle source

Sum of squares within groups

# File lib/statsample/anova/oneway.rb, line 109
def sswg
  @sswg||=@vectors.inject(0) {|total,vector| total+vector.ss }
end
total_mean() click to toggle source

Total mean

# File lib/statsample/anova/oneway.rb, line 104
def total_mean
  sum=@vectors.inject(0){|a,v| a+v.sum}
  sum.quo(n)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.