# Class: Statsample::Test::Levene

Inherits:
Object
• Object
show all
Includes:
Summarizable, Statsample::Test
Defined in:
lib/statsample/test/levene.rb

# 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 = Daru::Vector.new([1,2,3,4,5,6,7,8,100,10])
b = Daru::Vector.new([30,40,50,60,70,80,90,100,110,120])

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

Output:

``````Levene Test
F: 0.778121319848449
p: 0.389344552595791
``````

Reference:

## Instance Attribute Summary collapse

Degrees of freedom 1 (k-1).

Degrees of freedom 2 (n-k).

• Name of test.

## Instance Method Summary collapse

• Value of the test.

• constructor

Input could be an array of vectors or a dataset.

• Probability.

• :nodoc:.

#summary

## Constructor Details

### #initialize(input, opts = Hash.new()) ⇒ Levene

Input could be an array of vectors or a dataset

 ``` 31 32 33 34 35 36 37 38 39 40 41 42``` ```# File 'lib/statsample/test/levene.rb', line 31 def initialize(input, opts=Hash.new()) if input.is_a? Daru::DataFrame @vectors = input.to_hash.values else @vectors = input end @name=_("Levene Test") opts.each{|k,v| self.send("#{k}=",v) if self.respond_to? k } compute end```

## Instance Attribute Details

Degrees of freedom 1 (k-1)

 ``` 25 26 27``` ```# File 'lib/statsample/test/levene.rb', line 25 def d1 @d1 end```

Degrees of freedom 2 (n-k)

 ``` 27 28 29``` ```# File 'lib/statsample/test/levene.rb', line 27 def d2 @d2 end```

### #name ⇒ Object

Name of test

 ``` 29 30 31``` ```# File 'lib/statsample/test/levene.rb', line 29 def name @name end```

## Instance Method Details

### #f ⇒ Object

Value of the test

 ``` 44 45 46``` ```# File 'lib/statsample/test/levene.rb', line 44 def f @w end```

### #probability ⇒ Object

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

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

### #report_building(builder) ⇒ Object

:nodoc:

 ``` 47 48 49``` ```# File 'lib/statsample/test/levene.rb', line 47 def report_building(builder) # :nodoc: builder.text "%s : F(%d, %d) = %0.4f , p = %0.4f" % [@name, @d1, @d2, f, probability] end```