Class: Statsample::Test::BartlettSphericity

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

Overview

Bartlett's test of Sphericity.

Test the hyphotesis that the sample correlation matrix comes from a multivariate normal population where variables are independent. In other words, the population correlation matrix is the identity matrix.

Reference

  • Dziuban, C., & Shirkey E. (1974). When is a correlation matrix appropriate for factor analysis? Some decision rules. Psychological Bulletin, 81(6), 358-361.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Summarizable

#summary

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(matrix, ncases) ⇒ BartlettSphericity

Args

  • matrix: correlation matrix

  • ncases: number of cases


21
22
23
24
25
26
27
# File 'lib/statsample/test/bartlettsphericity.rb', line 21

def initialize(matrix,ncases)
  @matrix=matrix
  @ncases=ncases
  @nvars=@matrix.row_size
  @name=_("Bartlett's test of sphericity")
  compute
end

Instance Attribute Details

#dfObject (readonly)

Returns the value of attribute df


17
18
19
# File 'lib/statsample/test/bartlettsphericity.rb', line 17

def df
  @df
end

#nameObject

Returns the value of attribute name


13
14
15
# File 'lib/statsample/test/bartlettsphericity.rb', line 13

def name
  @name
end

#ncasesObject (readonly)

Returns the value of attribute ncases


14
15
16
# File 'lib/statsample/test/bartlettsphericity.rb', line 14

def ncases
  @ncases
end

#nvarsObject (readonly)

Returns the value of attribute nvars


15
16
17
# File 'lib/statsample/test/bartlettsphericity.rb', line 15

def nvars
  @nvars
end

#valueObject (readonly)

Returns the value of attribute value


16
17
18
# File 'lib/statsample/test/bartlettsphericity.rb', line 16

def value
  @value
end

Instance Method Details

#computeObject

Uses SPSS formula. On Dziuban & Shirkey, the minus between the first and second statement is a *!!!


32
33
34
35
# File 'lib/statsample/test/bartlettsphericity.rb', line 32

def compute
  @value=-((@ncases-1)-(2*@nvars+5).quo(6))*Math::log(@matrix.determinant)
  @df=(@nvars*(@nvars-1)) / 2
end

#probabilityObject


36
37
38
# File 'lib/statsample/test/bartlettsphericity.rb', line 36

def probability
  1-Distribution::ChiSquare.cdf(@value,@df)
end

#report_building(builder) ⇒ Object

:nodoc:


39
40
41
# File 'lib/statsample/test/bartlettsphericity.rb', line 39

def report_building(builder) # :nodoc:
  builder.text "%s : X(%d) = %0.4f , p = %0.4f" % [@name, @df, @value, probability]
end