class Statsample::Test::Levene

Levene Test for Equality of Variances

From NIST/SEMATECH: <blockquote>Levene's test ( Levene, 1960) is used to test if k samples have equal variances. Equal variances across samples is called homogeneity of variance. Some statistical tests, for example the analysis of variance, assume that variances are equal across groups or samples. The Levene test can be used to verify that assumption.</blockquote> Use:

require 'statsample'
a=[1,2,3,4,5,6,7,8,100,10].to_scale
b=[30,40,50,60,70,80,90,100,110,120].to_scale

levene=Statsample::Test::Levene.new([a,b])
puts levene.summary

Output:

Levene Test
F: 0.778121319848449
p: 0.389344552595791

Reference:

Levene Test for Equality of Variances

From NIST/SEMATECH: <blockquote>Levene's test ( Levene, 1960) is used to test if k samples have equal variances. Equal variances across samples is called homogeneity of variance. Some statistical tests, for example the analysis of variance, assume that variances are equal across groups or samples. The Levene test can be used to verify that assumption.</blockquote> Use:

require 'statsample'
a=[1,2,3,4,5,6,7,8,100,10].to_scale
b=[30,40,50,60,70,80,90,100,110,120].to_scale

levene=Statsample::Test::Levene.new([a,b])
puts levene.summary

Output:

Levene Test
F: 0.778121319848449
p: 0.389344552595791

Reference:

Attributes

d1[R]

Degrees of freedom 1 (k-1)

d2[R]

Degrees of freedom 2 (n-k)

name[RW]

Name of test

Public Class Methods

new(input, opts=Hash.new()) click to toggle source

Input could be an array of vectors or a dataset

# File lib/statsample/test/levene.rb, line 31
def initialize(input, opts=Hash.new())
  if input.is_a? Statsample::Dataset
    @vectors=input.vectors.values
  else
    @vectors=input
  end
  @name=_("Levene Test")
  opts.each{|k,v|
    self.send("#{k}=",v) if self.respond_to? k
  }
  compute
end

Public Instance Methods

f() click to toggle source

Value of the test

# File lib/statsample/test/levene.rb, line 44
def f
  @w
end
probability() click to toggle source

Probability. With H_0 = Sum(s2)=0, probability of getting a value of the test upper or equal to the obtained on the sample

# File lib/statsample/test/levene.rb, line 81
def probability
  p_using_cdf(Distribution::F.cdf(f, @d1, @d2), :right)
end