File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -498,7 +498,9 @@ func (r *Regression) Run() (*Model, error) {
498
498
}
499
499
500
500
// BackwardElimination : 変数減少法で解析する
501
- func (r * Regression ) BackwardElimination (p float64 ) ([]Model , error ) {
501
+ //
502
+ // `forcedExpVarsIndexesSet`に指定したインデックスの説明変数は強制投入(必ず使用)される
503
+ func (r * Regression ) BackwardElimination (p float64 , forcedExpVarsIndexesSet map [int ]struct {}) ([]Model , error ) {
502
504
originalDisregardingExplanatoryVarsSet := make (map [int ]struct {}, len (r .disregardingExplanatoryVarsSet ))
503
505
for k , v := range r .disregardingExplanatoryVarsSet {
504
506
originalDisregardingExplanatoryVarsSet [k ] = v
@@ -519,6 +521,10 @@ func (r *Regression) BackwardElimination(p float64) ([]Model, error) {
519
521
}
520
522
eliminationTarget , border := (* ExplanatoryVarResult )(nil ), p
521
523
for i := range model .ExplanatoryVars {
524
+ // 強制投入する変数は除かない
525
+ if _ , ok := forcedExpVarsIndexesSet [model .ExplanatoryVars [i ].OriginalIndex ]; ok {
526
+ continue
527
+ }
522
528
if model .ExplanatoryVars [i ].Prob > border {
523
529
eliminationTarget = & model .ExplanatoryVars [i ]
524
530
border = model .ExplanatoryVars [i ].Prob
You can’t perform that action at this time.
0 commit comments