68 m_Log_Epsilon = 0.001;
69 m_Log_Difference = 1000.;
119 for(
int i=0; i<Predictors.
Get_N(); i++)
121 y[i + 1] = Predictors[i];
139 for(
int i=0; i<Weights.
Get_N(); i++)
155 if( nSamples <= nPredictors || nSamples < 2 )
163 m_b = _Log_Get_Beta(m_X, m_y, m_w);
165 if( m_b.
Get_N() == 0 )
174 for(
sLong i=0; i<nSamples; i++)
178 for(
sLong j=1; j<=nPredictors; j++)
180 YtW[j][i] = m_w[i] * m_X[i][j];
184 m_b = (YtW * m_X).Get_Inverse() * (YtW * m_y);
190 double rss = 0., tss = 0.;
192 for(
sLong i=0; i<nSamples; i++)
196 for(
sLong j=1; j<=nPredictors; j++)
198 yr += m_b[j] * m_X[i][j];
203 yr = 1. / (1. + exp(-yr));
211 if( tss > 0.0 && tss >= rss )
213 m_r2 = fabs(tss - rss) / tss;
239 m_Log_maxIter = maxIter;
252 m_Log_Epsilon = Epsilon;
263 if( Difference > 0. )
265 m_Log_Difference = Difference;
280 for(
int i=0; i<m_Log_maxIter; ++i)
282 CSG_Vector b_new = _Log_Get_Beta(b, X, y, w, p);
284 if( b_new.
Get_N() == 0 )
289 for(
int j=0; j<b_new.
Get_N(); ++j)
297 if( _Log_NoChange(b, b_new) )
302 if( _Log_OutOfControl(b, b_new) )
307 p = _Log_Get_Props(X, b_new);
342 Xwp[i][j] = w[i] * p[i] * (1. - p[i]) * X[i][j];
357 for(
int i=0; i<Ywp.Get_N(); i++)
359 Ywp[i] = w[i] * (y[i] - p[i]);
380 p[i] = 1. / (1. + exp(-z));
389 for(
int i=0; i<b_old.
Get_N(); ++i)
391 if( fabs(b_old[i] - b_new[i]) > m_Log_Epsilon )
401 bool CSG_Regression_Weighted::_Log_OutOfControl(
const CSG_Vector &b_old,
const CSG_Vector &b_new)
403 for(
int i=0; i<b_old.
Get_N(); ++i)
405 if( b_old[i] == 0.0 )
410 if( fabs(b_old[i] - b_new[i]) / fabs(b_old[i]) > m_Log_Difference )