Class: Statsample::Test::BartlettSphericity
- 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
-
#df ⇒ Object
readonly
Returns the value of attribute df.
-
#name ⇒ Object
Returns the value of attribute name.
-
#ncases ⇒ Object
readonly
Returns the value of attribute ncases.
-
#nvars ⇒ Object
readonly
Returns the value of attribute nvars.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#compute ⇒ Object
Uses SPSS formula.
-
#initialize(matrix, ncases) ⇒ BartlettSphericity
constructor
Args * matrix: correlation matrix * ncases: number of cases.
- #probability ⇒ Object
-
#report_building(builder) ⇒ Object
:nodoc:.
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(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
#df ⇒ Object (readonly)
Returns the value of attribute df.
17 18 19 |
# File 'lib/statsample/test/bartlettsphericity.rb', line 17 def df @df end |
#name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'lib/statsample/test/bartlettsphericity.rb', line 13 def name @name end |
#ncases ⇒ Object (readonly)
Returns the value of attribute ncases.
14 15 16 |
# File 'lib/statsample/test/bartlettsphericity.rb', line 14 def ncases @ncases end |
#nvars ⇒ Object (readonly)
Returns the value of attribute nvars.
15 16 17 |
# File 'lib/statsample/test/bartlettsphericity.rb', line 15 def nvars @nvars end |
#value ⇒ Object (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
#compute ⇒ Object
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 |
#probability ⇒ Object
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 |