Parent

Included Modules

Class/Module Index [+]

Quicksearch

Statsample::Reliability::MultiScaleAnalysis

DSL for analysis of multiple scales analysis. Retrieves reliability analysis for each scale and provides fast accessors to correlations matrix, PCA and Factor Analysis.

Usage

@x1=[1,1,1,1,2,2,2,2,3,3,3,30].to_vector(:scale)
@x2=[1,1,1,2,2,3,3,3,3,4,4,50].to_vector(:scale)
@x3=[2,2,1,1,1,2,2,2,3,4,5,40].to_vector(:scale)
@x4=[1,2,3,4,4,4,4,3,4,4,5,30].to_vector(:scale)
ds={'x1'=>@x1,'x2'=>@x2,'x3'=>@x3,'x4'=>@x4}.to_dataset
opts={:name=>"Scales", # Name of analysis
      :summary_correlation_matrix=>true, # Add correlation matrix
      :summary_pca } # Add PCA between scales
msa=Statsample::Reliability::MultiScaleAnalysis.new(opts) do |m|
  m.scale :s1, ds.clone(%w{x1 x2})
  m.scale :s2, ds.clone(%w{x3 x4}), {:name=>"Scale 2"}
end
# Retrieve summary
puts msa.summary

Attributes

scales[R]

Hash with scales

name[RW]

Name of analysis

summary_correlation_matrix[RW]

Add a correlation matrix on summary

summary_pca[RW]

Add PCA to summary

summary_principal_axis[RW]

Add Principal Axis to summary

pca_options[RW]

Options for Factor::PCA object

principal_axis_options[RW]

Options for Factor::PrincipalAxis

summary_parallel_analysis[RW]

Add Parallel Analysis to summary

parallel_analysis_options[RW]

Options for Parallel Analysis

summary_map[RW]

Add MPA to summary

map_options[RW]

Options for MAP

Public Class Methods

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

Generates a new MultiScaleAnalysis Opts could be any accessor of the class

If block given, all methods should be called inside object environment.

# File lib/statsample/reliability/multiscaleanalysis.rb, line 64
def initialize(opts=Hash.new, &block)
  @scales=Hash.new
  @scales_keys=Array.new
  opts_default={  :name=>_("Multiple Scale analysis"),
                  :summary_correlation_matrix=>false,
                  :summary_pca=>false,
                  :summary_principal_axis=>false,
                  :summary_parallel_analysis=>false,
                  :summary_map=>false,
                  :pca_options=>Hash.new,
                  :principal_axis_options=>Hash.new,
                  :parallel_analysis_options=>Hash.new,
                  :map_options=>Hash.new
  }
  @opts=opts_default.merge(opts)
  @opts.each{|k,v|
    self.send("#{k}=",v) if self.respond_to? k
  }

  if block
    block.arity<1 ? instance_eval(&block) : block.call(self)
  end
end

Public Instance Methods

correlation_matrix() click to toggle source

Retrieves a Correlation Matrix between scales.

# File lib/statsample/reliability/multiscaleanalysis.rb, line 138
def correlation_matrix
  Statsample::Bivariate.correlation_matrix(dataset_from_scales)
end
dataset_from_scales() click to toggle source
# File lib/statsample/reliability/multiscaleanalysis.rb, line 123
def dataset_from_scales
  ds=Dataset.new(@scales_keys)
  @scales.each_pair do |code,scale|
    ds[code.to_s]=scale.ds.vector_sum
    ds[code.to_s].name=scale.name
  end
  ds.update_valid_data
  ds
end
delete_scale(code) click to toggle source

Delete ScaleAnalysis named code

# File lib/statsample/reliability/multiscaleanalysis.rb, line 103
def delete_scale(code)
  @scales_keys.delete code
  @scales.delete code
end
map(opts=nil) click to toggle source
# File lib/statsample/reliability/multiscaleanalysis.rb, line 113
def map(opts=nil)
  opts||=map_options
  Statsample::Factor::MAP.new(correlation_matrix, opts)
end
parallel_analysis(opts=nil) click to toggle source
# File lib/statsample/reliability/multiscaleanalysis.rb, line 132
def parallel_analysis(opts=nil)
  opts||=parallel_analysis_options
  Statsample::Factor::ParallelAnalysis.new(dataset_from_scales, opts)
end
pca(opts=nil) click to toggle source

Retrieves a Principal Component Analysis (Factor::PCA) using all scales, using opts a options.

# File lib/statsample/reliability/multiscaleanalysis.rb, line 109
def pca(opts=nil)
  opts||=pca_options        
  Statsample::Factor::PCA.new(correlation_matrix, opts)
end
principal_axis_analysis(opts=nil) click to toggle source

Retrieves a PrincipalAxis Analysis (Factor::PrincipalAxis) using all scales, using opts a options.

# File lib/statsample/reliability/multiscaleanalysis.rb, line 119
def principal_axis_analysis(opts=nil)
  opts||=principal_axis_options
  Statsample::Factor::PrincipalAxis.new(correlation_matrix, opts)
end
scale(code, ds=nil, opts=nil) click to toggle source

Add or retrieve a scale to analysis. If second parameters is a dataset, generates a ScaleAnalysis for ds, named code with options opts.

If second parameters is empty, returns the ScaleAnalysis code.

# File lib/statsample/reliability/multiscaleanalysis.rb, line 93
def scale(code, ds=nil, opts=nil)
  if ds.nil?
    @scales[code]
  else
    opts={:name=>_("Scale %s") % code} if opts.nil?
    @scales_keys.push(code)
    @scales[code]=ScaleAnalysis.new(ds, opts)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.