Method: Statsample::Regression::Multiple::AlglibEngine#initialize

Defined in:
lib/statsample/regression/multiple/alglibengine.rb

#initialize(ds, y_var, opts = Hash.new) ⇒ AlglibEngine

Returns a new instance of AlglibEngine.


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/statsample/regression/multiple/alglibengine.rb', line 20

def initialize(ds,y_var, opts=Hash.new)
  super    
  @ds       = ds.reject_values(*Daru::MISSING_VALUES)
  @ds_valid = @ds
  @dy       = @ds[@y_var]
  @ds_indep = ds.dup(ds.vectors.to_a - [y_var])
  # Create a custom matrix
  columns = []
  @fields = []
  @ds.vectors.each do |f|
    if f != @y_var
      columns.push(@ds[f].to_a)
      @fields.push(f)
    end
  end
  @dep_columns = columns.dup
  columns.push(@ds[@y_var])
  matrix=Matrix.columns(columns)
  @lr_s=nil
  @lr=::Alglib::LinearRegression.build_from_matrix(matrix)
  @coeffs=assign_names(@lr.coeffs)
end