Statsample::Bivariate

Constants

EXTENSION_VERSION

Version of bivariate extension

Public Class Methods

polychoric(v1,v2) click to toggle source

Calculate Polychoric correlation for two vectors.

   # File lib/statsample/bivariate/polychoric.rb, line 6
6:     def self.polychoric(v1,v2)
7:       pc=Polychoric.new_with_vectors(v1,v2)
8:       pc.r
9:     end
polychoric_correlation_matrix(ds) click to toggle source

Polychoric correlation matrix. Order of rows and columns depends on Dataset#fields order

    # File lib/statsample/bivariate/polychoric.rb, line 13
13:     def self.polychoric_correlation_matrix(ds)
14:       cache={}
15:       matrix=ds.collect_matrix do |row,col|
16:         if row==col
17:           1.0
18:         else
19:           begin
20:             if cache[[col,row]].nil?
21:               poly=polychoric(ds[row],ds[col])
22:               cache[[row,col]]=poly
23:               poly
24:             else
25:               cache[[col,row]]
26:             end
27:           rescue RuntimeError
28:             nil
29:           end
30:         end
31:       end
32:       matrix.extend CovariateMatrix
33:       matrix.fields=ds.fields
34:       matrix
35:     end
tetrachoric(v1,v2) click to toggle source

Calculate Tetrachoric correlation for two vectors.

   # File lib/statsample/bivariate/tetrachoric.rb, line 4
4:     def self.tetrachoric(v1,v2)
5:       tc=Tetrachoric.new_with_vectors(v1,v2)
6:       tc.r
7:     end
tetrachoric_correlation_matrix(ds) click to toggle source

Tetrachoric correlation matrix. Order of rows and columns depends on Dataset#fields order

    # File lib/statsample/bivariate/tetrachoric.rb, line 11
11:     def self.tetrachoric_correlation_matrix(ds)
12:       cache={}
13:       matrix=ds.collect_matrix do |row,col|
14:         if row==col
15:           1.0
16:         else
17:           begin
18:             if cache[[col,row]].nil?
19:               r=tetrachoric(ds[row],ds[col])
20:               cache[[row,col]]=r
21:               r
22:             else
23:               cache[[col,row]]
24:             end
25:           rescue RuntimeError
26:             nil
27:           end
28:         end
29:       end
30:       
31:       matrix.extend CovariateMatrix
32:       matrix.fields=ds.fields
33:       matrix
34:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.