module Statsample::Factor

Factor Analysis toolbox.

About number of components, O'Connor(2000) said:

The two procedures [PA and MAP ] complement each other nicely,
in that the MAP tends to err (when it does err) in the direction
of underextraction, whereas parallel analysis tends to err
(when it does err) in the direction of overextraction.
Optimal decisions are thus likely to be made after considering
the results of both analytic procedures. (p.10)

Factor Analysis toolbox.

About number of components, O'Connor(2000) said:

The two procedures [PA and MAP ] complement each other nicely,
in that the MAP tends to err (when it does err) in the direction
of underextraction, whereas parallel analysis tends to err
(when it does err) in the direction of overextraction.
Optimal decisions are thus likely to be made after considering
the results of both analytic procedures. (p.10)

Public Class Methods

anti_image_correlation_matrix(matrix) click to toggle source
# File lib/statsample/factor.rb, line 43
def self.anti_image_correlation_matrix(matrix)
  matrix=matrix.to_matrix
  s=Matrix.diag(*(matrix.inverse.diagonal)).sqrt.inverse
  aicm=s*matrix.inverse*s
  
  aicm.extend(Statsample::CovariateMatrix)
  aicm.fields=matrix.fields if matrix.respond_to? :fields
  aicm
  
end
anti_image_covariance_matrix(matrix) click to toggle source

Anti-image covariance matrix. Useful for inspection of desireability of data for factor analysis. According to Dziuban & Shirkey (1974, p.359):

"If this matrix does not exhibit many zero off-diagonal elements,
the investigator has evidence that the correlation
matrix is not appropriate for factor analysis."
# File lib/statsample/factor.rb, line 36
def self.anti_image_covariance_matrix(matrix)
  s2=Matrix.diag(*(matrix.inverse.diagonal)).inverse
  aicm=(s2)*matrix.inverse*(s2)
  aicm.extend(Statsample::CovariateMatrix)
  aicm.fields=matrix.fields if matrix.respond_to? :fields
  aicm
end
kmo(matrix) click to toggle source

Kaiser-Meyer-Olkin measure of sampling adequacy for correlation matrix.

Kaiser's (1974, cited on Dziuban & Shirkey, 1974) present calibration of the index is as follows :

  • .90s—marvelous

  • .80s— meritorious

  • .70s—middling

  • .60s—mediocre

  • .50s—miserable

  • .50 •—unacceptable

# File lib/statsample/factor.rb, line 63
def self.kmo(matrix)
  q=anti_image_correlation_matrix(matrix)
  n=matrix.row_size
  sum_r,sum_q=0,0
  n.times do |j|
    n.times do |k|
      if j!=k
        sum_r+=matrix[j,k]**2
        sum_q+=q[j,k]**2
      end
    end
  end
  sum_r.quo(sum_r+sum_q)
end
kmo_univariate(matrix, var) click to toggle source

Kaiser-Meyer-Olkin measure of sampling adequacy for one variable.

# File lib/statsample/factor.rb, line 79
def self.kmo_univariate(matrix, var)
  if var.is_a? String
    if matrix.respond_to? :fields
      j=matrix.fields.index(var)
      raise "Matrix doesn't have field #{var}" if j.nil?
    else
      raise "Matrix doesn't respond to fields"
    end
  else
    j=var
  end
  
  q=anti_image_correlation_matrix(matrix)
  n=matrix.row_size
  
  sum_r,sum_q=0,0
  
  n.times do |k|
    if j!=k
      sum_r+=matrix[j,k]**2
      sum_q+=q[j,k]**2
    end
  end
  sum_r.quo(sum_r+sum_q)
end