Class: GLM::Linear

Inherits:
Base
  • Object
show all
Defined in:
lib/glm/linear.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#T, #a, #b, #est, #eta, #format, #gradient, #h, #initialize, #output, #single_update, #sto_update, #theta

Constructor Details

This class inherits a constructor from GLM::Base

Class Method Details

.g(eta) ⇒ Object

Canonical response function It’s identity function here, obviously



13
14
15
# File 'lib/glm/linear.rb', line 13

def self.g(eta)
  return eta
end

Instance Method Details

#hiObject



6
7
8
# File 'lib/glm/linear.rb', line 6

def hi
  return "Hi, this is #{self.class}"
end

#ne_est(x) ⇒ Object

Normal equation estimation



18
19
20
21
# File 'lib/glm/linear.rb', line 18

def ne_est(x)
  @theta = ne_fit
  [@theta, x * @theta]
end

#ne_fitObject

Normal equation fit



24
25
26
# File 'lib/glm/linear.rb', line 24

def ne_fit
  ( @x.transpose * @x ).invert * @x.transpose * @y
end