Class: Num4GLMRegAnaLib::LogitRegAnaLib

Inherits:
Object
  • Object
show all
Defined in:
lib/num4glmregana.rb

Overview

(2項)ロジスティック回帰分析

Instance Method Summary collapse

Constructor Details

#initializeLogitRegAnaLib

Returns a new instance of LogitRegAnaLib.



15
16
17
# File 'lib/num4glmregana.rb', line 15

def initialize
    @multana = LogitRegAna.getInstance()
end

Instance Method Details

#get_aic(regcoe, xij) ⇒ Object

AIC

Examples:

reg = {
     :intercept=>  -6.2313,    # 定数項
     :slope=>      [2.5995, 0.1652],     # 回帰係数
}
xij = [
     [1, 24],
     [1, 18],
     [0, 15],
     [1, 16],
     [0, 10],
     [1, 26],
     [1, 2],
     [0, 24],
     [1, 18],
     [1, 22],
     [1, 3],
     [1, 6],
     [0, 15],
     [0, 12],
     [1, 6],
     [0, 6],
     [1, 12],
     [0, 12],
     [1, 18],
     [1, 3],
     [1, 8],
     [0, 9],
     [0, 12],
     [0, 6],
     [0, 8],
     [1, 12],
]
regana = Num4RegAnaLib::LogitRegAnaLib.new
regana.get_aic(reg, xij)
=> 155.612

Returns double AIC値.

Parameters:

  • regcoe (Hash)

    回帰係数(intercept:定数項 slope:回帰係数)

  • xij (Array)

Returns:

  • double AIC値



111
112
113
114
115
116
# File 'lib/num4glmregana.rb', line 111

def get_aic(regcoe, xij)
    o = HashMap.new
    o["intercept"] = regcoe[:intercept]
    o["slope"]     = regcoe[:slope].to_java(Java::double)
    @multana.getAIC(o, xij.to_java(Java::double[]))
end

#non_line_reg_ana(yi, xij) ⇒ Hash

(2項)ロジスティック回帰分析

Examples:

glsyi = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
glsxij = [
     [1, 24],
     [1, 18],
     [0, 15],
     [1, 16],
     [0, 10],
     [1, 26],
     [1, 2],
     [0, 24],
     [1, 18],
     [1, 22],
     [1, 3],
     [1, 6],
     [0, 15],
     [0, 12],
     [1, 6],
     [0, 6],
     [1, 12],
     [0, 12],
     [1, 18],
     [1, 3],
     [1, 8],
     [0, 9],
     [0, 12],
     [0, 6],
     [0, 8],
     [1, 12],
]
regana = Num4RegAnaLib::LogitRegAnaLib.new
regana.non_line_reg_ana(glsyi, glsxij)
=> 
  {
     "intercept":  -6.2313,              # 定数項
     "slope":      [2.5995, 0.1652],     # 回帰係数
  }

Returns (intercept:定数項 slope:回帰係数).

Parameters:

Returns:

  • (Hash)

    (intercept:定数項 slope:回帰係数)



61
62
63
64
65
66
67
68
# File 'lib/num4glmregana.rb', line 61

def non_line_reg_ana(yi, xij)
    multRet = @multana.nonLineRegAna(yi.to_java(Java::double), xij.to_java(Java::double[]))
    retRb = {
        "intercept":  multRet.getIntercept(), # 定数項
        "slope":      multRet.getSlope().to_a,     # 回帰係数
    }
    return retRb
end