statsample 1.5.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.build.sh +15 -0
  3. data/.gitignore +1 -0
  4. data/.travis.yml +19 -7
  5. data/CONTRIBUTING.md +33 -0
  6. data/History.txt +5 -0
  7. data/README.md +41 -53
  8. data/benchmarks/correlation_matrix_15_variables.rb +6 -5
  9. data/benchmarks/correlation_matrix_5_variables.rb +6 -5
  10. data/benchmarks/correlation_matrix_methods/correlation_matrix.rb +23 -26
  11. data/examples/boxplot.rb +17 -5
  12. data/examples/correlation_matrix.rb +36 -7
  13. data/examples/dataset.rb +25 -5
  14. data/examples/dominance_analysis.rb +8 -7
  15. data/examples/dominance_analysis_bootstrap.rb +16 -11
  16. data/examples/histogram.rb +16 -2
  17. data/examples/icc.rb +5 -6
  18. data/examples/levene.rb +17 -3
  19. data/examples/multiple_regression.rb +6 -3
  20. data/examples/parallel_analysis.rb +11 -6
  21. data/examples/polychoric.rb +26 -13
  22. data/examples/principal_axis.rb +8 -4
  23. data/examples/reliability.rb +10 -10
  24. data/examples/scatterplot.rb +8 -0
  25. data/examples/t_test.rb +7 -0
  26. data/examples/u_test.rb +10 -2
  27. data/examples/vector.rb +9 -6
  28. data/examples/velicer_map_test.rb +12 -8
  29. data/lib/statsample.rb +13 -47
  30. data/lib/statsample/analysis/suite.rb +1 -1
  31. data/lib/statsample/anova/oneway.rb +6 -6
  32. data/lib/statsample/anova/twoway.rb +26 -24
  33. data/lib/statsample/bivariate.rb +78 -61
  34. data/lib/statsample/bivariate/pearson.rb +2 -2
  35. data/lib/statsample/codification.rb +45 -32
  36. data/lib/statsample/converter/csv.rb +15 -53
  37. data/lib/statsample/converter/spss.rb +6 -5
  38. data/lib/statsample/converters.rb +50 -211
  39. data/lib/statsample/crosstab.rb +26 -25
  40. data/lib/statsample/daru.rb +117 -0
  41. data/lib/statsample/dataset.rb +70 -942
  42. data/lib/statsample/dominanceanalysis.rb +16 -17
  43. data/lib/statsample/dominanceanalysis/bootstrap.rb +26 -28
  44. data/lib/statsample/factor/parallelanalysis.rb +17 -19
  45. data/lib/statsample/factor/pca.rb +21 -20
  46. data/lib/statsample/factor/principalaxis.rb +3 -3
  47. data/lib/statsample/graph/boxplot.rb +8 -16
  48. data/lib/statsample/graph/histogram.rb +4 -4
  49. data/lib/statsample/graph/scatterplot.rb +8 -7
  50. data/lib/statsample/histogram.rb +128 -119
  51. data/lib/statsample/matrix.rb +20 -16
  52. data/lib/statsample/multiset.rb +39 -38
  53. data/lib/statsample/regression.rb +3 -3
  54. data/lib/statsample/regression/multiple.rb +8 -10
  55. data/lib/statsample/regression/multiple/alglibengine.rb +96 -89
  56. data/lib/statsample/regression/multiple/baseengine.rb +32 -32
  57. data/lib/statsample/regression/multiple/gslengine.rb +33 -36
  58. data/lib/statsample/regression/multiple/matrixengine.rb +7 -9
  59. data/lib/statsample/regression/multiple/rubyengine.rb +39 -41
  60. data/lib/statsample/reliability.rb +23 -25
  61. data/lib/statsample/reliability/icc.rb +8 -7
  62. data/lib/statsample/reliability/multiscaleanalysis.rb +14 -12
  63. data/lib/statsample/reliability/scaleanalysis.rb +58 -60
  64. data/lib/statsample/reliability/skillscaleanalysis.rb +34 -29
  65. data/lib/statsample/resample.rb +1 -1
  66. data/lib/statsample/shorthand.rb +29 -25
  67. data/lib/statsample/test/kolmogorovsmirnov.rb +5 -3
  68. data/lib/statsample/test/levene.rb +28 -27
  69. data/lib/statsample/test/t.rb +7 -9
  70. data/lib/statsample/test/umannwhitney.rb +28 -28
  71. data/lib/statsample/test/wilcoxonsignedrank.rb +45 -43
  72. data/lib/statsample/vector.rb +70 -1013
  73. data/lib/statsample/version.rb +1 -1
  74. data/statsample.gemspec +12 -16
  75. data/test/helpers_tests.rb +1 -1
  76. data/test/test_analysis.rb +17 -17
  77. data/test/test_anova_contrast.rb +6 -6
  78. data/test/test_anovatwowaywithdataset.rb +8 -8
  79. data/test/test_anovawithvectors.rb +8 -8
  80. data/test/test_awesome_print_bug.rb +1 -1
  81. data/test/test_bartlettsphericity.rb +4 -4
  82. data/test/test_bivariate.rb +48 -43
  83. data/test/test_codification.rb +33 -33
  84. data/test/test_crosstab.rb +9 -9
  85. data/test/test_dataset.rb +28 -458
  86. data/test/test_factor.rb +46 -38
  87. data/test/test_factor_pa.rb +22 -13
  88. data/test/test_ggobi.rb +4 -4
  89. data/test/test_gsl.rb +4 -4
  90. data/test/test_histogram.rb +3 -3
  91. data/test/test_matrix.rb +13 -13
  92. data/test/test_multiset.rb +103 -91
  93. data/test/test_regression.rb +57 -52
  94. data/test/test_reliability.rb +55 -45
  95. data/test/test_reliability_icc.rb +8 -8
  96. data/test/test_reliability_skillscale.rb +26 -24
  97. data/test/test_resample.rb +1 -1
  98. data/test/test_statistics.rb +3 -13
  99. data/test/test_stest.rb +9 -9
  100. data/test/test_stratified.rb +3 -3
  101. data/test/test_test_t.rb +12 -12
  102. data/test/test_umannwhitney.rb +2 -2
  103. data/test/test_vector.rb +76 -613
  104. data/test/test_wilcoxonsignedrank.rb +4 -4
  105. metadata +57 -28
  106. data/lib/statsample/rserve_extension.rb +0 -20
  107. data/lib/statsample/vector/gsl.rb +0 -106
  108. data/test/fixtures/repeated_fields.csv +0 -7
  109. data/test/fixtures/scientific_notation.csv +0 -4
  110. data/test/fixtures/test_csv.csv +0 -7
  111. data/test/fixtures/test_xls.xls +0 -0
  112. data/test/test_csv.rb +0 -63
  113. data/test/test_rserve_extension.rb +0 -42
  114. data/test/test_xls.rb +0 -52
@@ -25,8 +25,8 @@ module Statsample
25
25
  # * x: independent Vector
26
26
  # * y: dependent Vector
27
27
  # <b>Usage:</b>
28
- # x=100.times.collect {|i| rand(100)}.to_numeric
29
- # y=100.times.collect {|i| 2+x[i]*2+rand()}.to_numeric
28
+ # x = Daru::Vector.new(100.times.collect {|i| rand(100)})
29
+ # y = Daru::Vector.new(100.times.collect {|i| 2+x[i]*2+rand()})
30
30
  # sr=Statsample::Regression.simple(x,y)
31
31
  # sr.a
32
32
  # => 2.51763295177808
@@ -49,7 +49,7 @@ module Statsample
49
49
  # * :pairwise: uses correlation matrix. Use with caution.
50
50
  #
51
51
  # <b>Usage:</b>
52
- # lr=Statsample::Regression::multiple(ds,'y')
52
+ # lr=Statsample::Regression::multiple(ds,:y)
53
53
  def self.multiple(ds,y_var, opts=Hash.new)
54
54
  missing_data= (opts[:missing_data].nil? ) ? :listwise : opts.delete(:missing_data)
55
55
  if missing_data==:pairwise
@@ -6,12 +6,12 @@ module Statsample
6
6
  # Use:.
7
7
  #
8
8
  # require 'statsample'
9
- # a=1000.times.collect {rand}.to_numeric
10
- # b=1000.times.collect {rand}.to_numeric
11
- # c=1000.times.collect {rand}.to_numeric
12
- # ds={'a'=>a,'b'=>b,'c'=>c}.to_dataset
13
- # ds['y']=ds.collect{|row| row['a']*5+row['b']*3+row['c']*2+rand()}
14
- # lr=Statsample::Regression.multiple(ds,'y')
9
+ # a = Daru::Vector.new(1000.times.collect {rand})
10
+ # b = Daru::Vector.new(1000.times.collect {rand})
11
+ # c = Daru::Vector.new(1000.times.collect {rand})
12
+ # ds= Daru::DataFrame.new({:a => a,:b => b,:c => c})
13
+ # ds[:y]=ds.collect{|row| row[:a]*5 + row[:b]*3 + row[:c]*2 + rand()}
14
+ # lr=Statsample::Regression.multiple(ds, :y)
15
15
  # puts lr.summary
16
16
  # Summary for regression of a,b,c over y
17
17
  # *************************************************************
@@ -53,8 +53,8 @@ module Statsample
53
53
  def initialize(matrix,y_var, opts=Hash.new)
54
54
  matrix.extend Statsample::CovariateMatrix
55
55
  @matrix=matrix
56
- @fields=matrix.fields-y_var
57
- @y_var=y_var
56
+ @fields=matrix.fields - y_var
57
+ @y_var = y_var
58
58
  @q=@y_var.size
59
59
  @matrix_cor=matrix.correlation
60
60
  @matrix_cor_xx = @matrix_cor.submatrix(@fields)
@@ -84,8 +84,6 @@ module Statsample
84
84
  vxy.quo(@q)
85
85
  end
86
86
  end
87
-
88
-
89
87
  end
90
88
  end
91
89
  end
@@ -9,108 +9,115 @@ module Multiple
9
9
  # If you need pairwise, use RubyEngine
10
10
  # Example:
11
11
  #
12
- # @a=[1,3,2,4,3,5,4,6,5,7].to_vector(:numeric)
13
- # @b=[3,3,4,4,5,5,6,6,4,4].to_vector(:numeric)
14
- # @c=[11,22,30,40,50,65,78,79,99,100].to_vector(:numeric)
15
- # @y=[3,4,5,6,7,8,9,10,20,30].to_vector(:numeric)
16
- # ds={'a'=>@a,'b'=>@b,'c'=>@c,'y'=>@y}.to_dataset
17
- # lr=Statsample::Regression::Multiple::AlglibEngine.new(ds,'y')
12
+ # @a = Daru::Vector.new([1,3,2,4,3,5,4,6,5,7])
13
+ # @b = Daru::Vector.new([3,3,4,4,5,5,6,6,4,4])
14
+ # @c = Daru::Vector.new([11,22,30,40,50,65,78,79,99,100])
15
+ # @y = Daru::Vector.new([3,4,5,6,7,8,9,10,20,30])
16
+ # ds = Daru::DataFrame.new({:a => @a,:b => @b,:c => @c,:y => @y})
17
+ # lr=Statsample::Regression::Multiple::AlglibEngine.new(ds, :y)
18
18
  #
19
19
  class AlglibEngine < BaseEngine
20
20
  def initialize(ds,y_var, opts=Hash.new)
21
21
  super
22
- @ds=ds.dup_only_valid
23
- @ds_valid=@ds
24
- @dy=@ds[@y_var]
25
- @ds_indep=ds.dup(ds.fields-[y_var])
22
+ @ds = ds.dup_only_valid
23
+ @ds_valid = @ds
24
+ @dy = @ds[@y_var]
25
+ @ds_indep = ds.dup(ds.vectors.to_a - [y_var])
26
26
  # Create a custom matrix
27
- columns=[]
28
- @fields=[]
29
- @ds.fields.each{|f|
30
- if f!=@y_var
31
- columns.push(@ds[f].to_a)
32
- @fields.push(f)
33
- end
34
- }
35
- @dep_columns=columns.dup
27
+ columns = []
28
+ @fields = []
29
+ @ds.vectors.each do |f|
30
+ if f != @y_var
31
+ columns.push(@ds[f].to_a)
32
+ @fields.push(f)
33
+ end
34
+ end
35
+ @dep_columns = columns.dup
36
36
  columns.push(@ds[@y_var])
37
37
  matrix=Matrix.columns(columns)
38
38
  @lr_s=nil
39
39
  @lr=::Alglib::LinearRegression.build_from_matrix(matrix)
40
40
  @coeffs=assign_names(@lr.coeffs)
41
-
42
41
  end
43
42
 
44
- def _dump(i)
45
- Marshal.dump({'ds'=>@ds,'y_var'=>@y_var})
46
- end
47
- def self._load(data)
48
- h=Marshal.load(data)
49
- self.new(h['ds'], h['y_var'])
50
- end
51
-
52
- def coeffs
53
- @coeffs
54
- end
55
- # Coefficients using a constant
56
- # Based on http://www.xycoon.com/ols1.htm
57
- def matrix_resolution
58
- mse_p=mse
59
- columns=@dep_columns.dup.map {|xi| xi.map{|i| i.to_f}}
60
- columns.unshift([1.0]*@ds.cases)
61
- y=Matrix.columns([@dy.data.map {|i| i.to_f}])
62
- x=Matrix.columns(columns)
63
- xt=x.t
64
- matrix=((xt*x)).inverse*xt
65
- matrix*y
66
- end
67
- def r2
68
- r**2
69
- end
70
- def r
71
- Bivariate::pearson(@dy,predicted)
72
- end
73
- def sst
74
- @dy.ss
75
- end
76
- def constant
77
- @lr.constant
78
- end
79
- def standarized_coeffs
80
- l=lr_s
81
- assign_names(l.coeffs)
82
- end
83
- def lr_s
84
- if @lr_s.nil?
85
- build_standarized
86
- end
87
- @lr_s
88
- end
89
- def build_standarized
90
- @ds_s=@ds.standarize
91
- columns=[]
92
- @ds_s.fields.each{|f|
93
- columns.push(@ds_s[f].to_a) unless f==@y_var
94
- }
95
- @dep_columns_s=columns.dup
96
- columns.push(@ds_s[@y_var])
97
- matrix=Matrix.columns(columns)
98
- @lr_s=Alglib::LinearRegression.build_from_matrix(matrix)
99
- end
100
- def process(v)
101
- @lr.process(v)
102
- end
103
- def process_s(v)
104
- lr_s.process(v)
105
- end
106
- # ???? Not equal to SPSS output
107
- def standarized_residuals
108
- res=residuals
109
- red_sd=residuals.sds
110
- res.collect {|v|
111
- v.quo(red_sd)
112
- }.to_vector(:numeric)
43
+ def _dump(i)
44
+ Marshal.dump({'ds'=>@ds,'y_var'=>@y_var})
45
+ end
46
+
47
+ def self._load(data)
48
+ h=Marshal.load(data)
49
+ self.new(h['ds'], h['y_var'])
50
+ end
51
+
52
+ def coeffs
53
+ @coeffs
54
+ end
55
+ # Coefficients using a constant
56
+ # Based on http://www.xycoon.com/ols1.htm
57
+ def matrix_resolution
58
+ mse_p=mse
59
+ columns=@dep_columns.dup.map {|xi| xi.map{|i| i.to_f}}
60
+ columns.unshift([1.0]*@ds.cases)
61
+ y=Matrix.columns([@dy.data.map {|i| i.to_f}])
62
+ x=Matrix.columns(columns)
63
+ xt=x.t
64
+ matrix=((xt*x)).inverse*xt
65
+ matrix*y
66
+ end
67
+
68
+ def r2
69
+ r**2
70
+ end
71
+
72
+ def r
73
+ Bivariate::pearson(@dy,predicted)
74
+ end
75
+
76
+ def sst
77
+ @dy.ss
78
+ end
79
+
80
+ def constant
81
+ @lr.constant
82
+ end
83
+
84
+ def standarized_coeffs
85
+ l=lr_s
86
+ assign_names(l.coeffs)
87
+ end
88
+
89
+ def lr_s
90
+ if @lr_s.nil?
91
+ build_standarized
113
92
  end
93
+ @lr_s
94
+ end
95
+
96
+ def build_standarized
97
+ @ds_s=@ds.standardize
98
+ columns=[]
99
+ @ds_s.vectors.each{|f|
100
+ columns.push(@ds_s[f].to_a) unless f == @y_var
101
+ }
102
+ @dep_columns_s=columns.dup
103
+ columns.push(@ds_s[@y_var])
104
+ matrix=Matrix.columns(columns)
105
+ @lr_s=Alglib::LinearRegression.build_from_matrix(matrix)
106
+ end
107
+
108
+ def process(v)
109
+ @lr.process(v)
110
+ end
111
+
112
+ def process_s(v)
113
+ lr_s.process(v)
114
+ end
115
+ # ???? Not equal to SPSS output
116
+ def standarized_residuals
117
+ res = residuals
118
+ red_sd = residuals.sds
119
+ Daru::Vector.new(res.collect {|v| v.quo(red_sd) })
120
+ end
114
121
  end
115
122
  end
116
123
  end
@@ -19,13 +19,12 @@ module Statsample
19
19
  end
20
20
  def initialize(ds, y_var, opts = Hash.new)
21
21
  @ds=ds
22
- @predictors_n=@ds.fields.size-1
23
- @total_cases=@ds.cases
24
- @cases=@ds.cases
22
+ @predictors_n=@ds.vectors.size-1
23
+ @total_cases=@ds.nrows
24
+ @cases=@ds.nrows
25
25
  @y_var=y_var
26
26
  @r2=nil
27
- @name=_("Multiple Regression: %s over %s") % [ ds.fields.join(",") , @y_var]
28
-
27
+ @name=_("Multiple Regression: %s over %s") % [ ds.vectors.to_a.join(",") , @y_var]
29
28
 
30
29
  opts_default={:digits=>3}
31
30
  @opts=opts_default.merge opts
@@ -33,7 +32,6 @@ module Statsample
33
32
  @opts.each{|k,v|
34
33
  self.send("#{k}=",v) if self.respond_to? k
35
34
  }
36
-
37
35
  end
38
36
  # Calculate F Test
39
37
  def anova
@@ -45,15 +43,17 @@ module Statsample
45
43
  end
46
44
  # Retrieves a vector with predicted values for y
47
45
  def predicted
48
- @total_cases.times.collect { |i|
49
- invalid=false
50
- vect=@dep_columns.collect {|v| invalid=true if v[i].nil?; v[i]}
51
- if invalid
52
- nil
53
- else
54
- process(vect)
46
+ Daru::Vector.new(
47
+ @total_cases.times.collect do |i|
48
+ invalid = false
49
+ vect = @dep_columns.collect {|v| invalid = true if v[i].nil?; v[i]}
50
+ if invalid
51
+ nil
52
+ else
53
+ process(vect)
54
+ end
55
55
  end
56
- }.to_vector(:numeric)
56
+ )
57
57
  end
58
58
  # Retrieves a vector with standarized values for y
59
59
  def standarized_predicted
@@ -61,15 +61,17 @@ module Statsample
61
61
  end
62
62
  # Retrieves a vector with residuals values for y
63
63
  def residuals
64
- (0...@total_cases).collect{|i|
65
- invalid=false
66
- vect=@dep_columns.collect{|v| invalid=true if v[i].nil?; v[i]}
67
- if invalid or @ds[@y_var][i].nil?
68
- nil
69
- else
70
- @ds[@y_var][i] - process(vect)
64
+ Daru::Vector.new(
65
+ (0...@total_cases).collect do |i|
66
+ invalid=false
67
+ vect=@dep_columns.collect{|v| invalid=true if v[i].nil?; v[i]}
68
+ if invalid or @ds[@y_var][i].nil?
69
+ nil
70
+ else
71
+ @ds[@y_var][i] - process(vect)
72
+ end
71
73
  end
72
- }.to_vector(:numeric)
74
+ )
73
75
  end
74
76
  # R Multiple
75
77
  def r
@@ -131,12 +133,10 @@ module Statsample
131
133
  # Tolerance for a given variable
132
134
  # http://talkstats.com/showthread.php?t=5056
133
135
  def tolerance(var)
134
- ds=assign_names(@dep_columns)
135
- ds.each{|k,v|
136
- ds[k]=v.to_vector(:numeric)
137
- }
138
- lr=self.class.new(ds.to_dataset,var)
139
- 1-lr.r2
136
+ ds = assign_names(@dep_columns)
137
+ ds.each { |k,v| ds[k] = Daru::Vector.new(v) }
138
+ lr = self.class.new(Daru::DataFrame.new(ds),var)
139
+ 1 - lr.r2
140
140
  end
141
141
  # Tolerances for each coefficient
142
142
  def coeffs_tolerances
@@ -165,12 +165,12 @@ module Statsample
165
165
  def estimated_variance_covariance_matrix
166
166
  #mse_p=mse
167
167
  columns=[]
168
- @ds_valid.fields.each{|k|
169
- v=@ds_valid[k]
170
- columns.push(v.data) unless k==@y_var
168
+ @ds_valid.vectors.each{|k|
169
+ v = @ds_valid[k]
170
+ columns.push(v.to_a) unless k == @y_var
171
171
  }
172
172
  columns.unshift([1.0]*@valid_cases)
173
- x=Matrix.columns(columns)
173
+ x=::Matrix.columns(columns)
174
174
  matrix=((x.t*x)).inverse * mse
175
175
  matrix.collect {|i| Math::sqrt(i) if i>=0 }
176
176
  end
@@ -9,43 +9,44 @@ if Statsample.has_gsl?
9
9
  # If you need pairwise, use RubyEngine
10
10
  # Example:
11
11
  #
12
- # @a=[1,3,2,4,3,5,4,6,5,7].to_vector(:numeric)
13
- # @b=[3,3,4,4,5,5,6,6,4,4].to_vector(:numeric)
14
- # @c=[11,22,30,40,50,65,78,79,99,100].to_vector(:numeric)
15
- # @y=[3,4,5,6,7,8,9,10,20,30].to_vector(:numeric)
16
- # ds={'a'=>@a,'b'=>@b,'c'=>@c,'y'=>@y}.to_dataset
17
- # lr=Statsample::Regression::Multiple::GslEngine.new(ds,'y')
12
+ # @a = Daru::Vector.new([1,3,2,4,3,5,4,6,5,7])
13
+ # @b = Daru::Vector.new([3,3,4,4,5,5,6,6,4,4])
14
+ # @c = Daru::Vector.new([11,22,30,40,50,65,78,79,99,100])
15
+ # @y = Daru::Vector.new([3,4,5,6,7,8,9,10,20,30])
16
+ # ds = Daru::DataFrame.new({:a => @a,:b => @b,:c => @c,:y => @y})
17
+ # lr=Statsample::Regression::Multiple::GslEngine.new(ds,:y)
18
18
  #
19
19
  class GslEngine < BaseEngine
20
20
  def initialize(ds,y_var, opts=Hash.new)
21
21
  super
22
- @ds=ds.dup_only_valid
23
- @ds_valid=@ds
24
- @valid_cases=@ds_valid.cases
25
- @dy=@ds[@y_var]
26
- @ds_indep=ds.dup(ds.fields-[y_var])
22
+ @ds = ds.dup_only_valid
23
+ @ds_valid = @ds
24
+ @valid_cases = @ds_valid.nrows
25
+ @dy = @ds[@y_var]
26
+ @ds_indep = ds.dup(ds.vectors.to_a - [y_var])
27
27
  # Create a custom matrix
28
28
  columns=[]
29
29
  @fields=[]
30
- max_deps = GSL::Matrix.alloc(@ds.cases, @ds.fields.size)
31
- constant_col=@ds.fields.size-1
32
- for i in 0...@ds.cases
30
+ max_deps = GSL::Matrix.alloc(@ds.nrows, @ds.vectors.size)
31
+ constant_col=@ds.vectors.size-1
32
+ for i in 0...@ds.nrows
33
33
  max_deps.set(i,constant_col,1)
34
34
  end
35
- j=0
36
- @ds.fields.each{|f|
37
- if f!=@y_var
38
- @ds[f].each_index{|i1|
35
+ j = 0
36
+ @ds.vectors.each do |f|
37
+ if f != @y_var
38
+ @ds[f].each_index do |i1|
39
39
  max_deps.set(i1,j,@ds[f][i1])
40
- }
40
+ end
41
+
41
42
  columns.push(@ds[f].to_a)
42
43
  @fields.push(f)
43
- j+=1
44
+ j += 1
44
45
  end
45
- }
46
- @dep_columns=columns.dup
47
- @lr_s=nil
48
- c, @cov, @chisq, @status = GSL::MultiFit.linear(max_deps, @dy.gsl)
46
+ end
47
+ @dep_columns = columns.dup
48
+ @lr_s = nil
49
+ c, @cov, @chisq, @status = GSL::MultiFit.linear(max_deps, @dy.to_gsl)
49
50
  @constant=c[constant_col]
50
51
  @coeffs_a=c.to_a.slice(0...constant_col)
51
52
  @coeffs=assign_names(@coeffs_a)
@@ -97,7 +98,7 @@ if Statsample.has_gsl?
97
98
  @lr_s
98
99
  end
99
100
  def build_standarized
100
- @ds_s=@ds.standarize
101
+ @ds_s=@ds.standardize
101
102
  @lr_s=GslEngine.new(@ds_s,@y_var)
102
103
  end
103
104
  def process_s(v)
@@ -107,24 +108,20 @@ if Statsample.has_gsl?
107
108
  def standarized_residuals
108
109
  res=residuals
109
110
  red_sd=residuals.sds
110
- res.collect {|v|
111
- v.quo(red_sd)
112
- }.to_vector(:numeric)
111
+ Daru::Vector.new(res.collect {|v| v.quo(red_sd) })
113
112
  end
114
113
 
115
114
  # Standard error for coeffs
116
115
  def coeffs_se
117
- out={}
118
- evcm=estimated_variance_covariance_matrix
119
- @ds_valid.fields.each_with_index do |f,i|
120
-
121
- mi=i+1
122
- next if f==@y_var
123
- out[f]=evcm[mi,mi]
116
+ out = {}
117
+ evcm = estimated_variance_covariance_matrix
118
+ @ds_valid.vectors.to_a.each_with_index do |f,i|
119
+ mi = i+1
120
+ next if f == @y_var
121
+ out[f] = evcm[mi,mi]
124
122
  end
125
123
  out
126
124
  end
127
-
128
125
  end
129
126
  end
130
127
  end