|
SAGA API
v9.6
|
Go to the documentation of this file.
230 int nPredictors = Samples.
Get_NX() - 1;
232 if( nPredictors < 1 || Samples.
Get_NY() <= nPredictors )
238 for(
int i=0; i<=nPredictors; i++)
276 for(
int i=0; i<nPredictors; i++)
362 P_out = P_in + 0.001;
433 SubSet[i] = i % nSubSamples;
442 for(i=Samples.Get_NY()-1; i>=0; i--)
444 if( SubSet[i] == iSubSet )
446 Validation.
Add_Row(Samples.Get_Row(i));
451 Samples_Stats += Samples[i][0];
462 double dObsrv = Validation[i][0];
495 double Value;
Get_Value(Predictors, Value);
return( Value );
520 double Value;
Get_Residual(iSample, Value);
return( Value );
549 for(
int i=0; i<Residuals.
Get_N(); i++)
554 return( Residuals.
Get_N() > 0 );
565 return( (nSamples - nPredictors - 1) * (r2_full - r2_reduced) / (1. - r2_full) );
571 double f =
_Get_F(nPredictors, nSamples, r2_full, r2_reduced);
584 int nPredictors = Samples.
Get_NX() - 1;
585 int nSamples = Samples.
Get_NY();
589 double Ym, SSR, SSE, SST, MSR, MSE, SE, R2, F;
597 for(i=0, Ym=0.; i<nSamples; i++)
599 Ym += Y[i] = Samples[i][0];
605 for(j=1; j<=nPredictors; j++)
607 X[i][j] = Samples[i][j];
612 for(j=0; j<nPredictors; j++)
614 X[i][j] = Samples[i][j + 1];
624 C = (Xt * X).Get_Inverse();
631 for(i=0, SSE=0., SSR=0., SST=0.; i<nSamples; i++)
640 MSR = SSR / nPredictors;
641 MSE = SSE / (nSamples - nPredictors - 1);
642 SE = sqrt(SSE / (nSamples - nPredictors));
668 for(j=0; j<
B.Get_N(); j++)
670 double se = SE * sqrt(fabs(
C[j][j]));
674 double r = -P[k][0] / sqrt(P[k][k] * P[0][0]);
703 int iBest, iPredictor;
double rBest;
710 for(iPredictor=0, iBest=-1, rBest=0.; iPredictor<Samples.
Get_NX()-1; iPredictor++)
747 int iBest, iPredictor;
double rBest;
759 for(iPredictor=0, iBest=-1, rBest=0.; iPredictor<
m_nPredictors; iPredictor++)
763 X_reduced.
Del_Col(1 + iPredictor);
783 for(iPredictor=iBest; iPredictor<
m_nPredictors; iPredictor++)
880 if( iVariable >= 0 && iVariable < m_pRegression->Get_Count() - 1 )
902 if( iVariable >= 0 && iVariable < m_pRegression->Get_Count() - 1 && Parameter >= 0 && Parameter <=
MLR_VAR_P )
929 s +=
CSG_String::Format(
"No. \tR \tR2 \tR2 adj\tStdErr\tF \tP \tF step\tP step\tVariable\n");
930 s +=
CSG_String::Format(
"------\t------\t------\t------\t------\t------\t------\t------\t------\t------\n");
936 s +=
CSG_String::Format(
"%d.\t%.2f\t%.2f\t%.2f\t%.3f\t%.3f\t%.3f\t%.3f\t%.3f\t%s %s\n",
954 s +=
CSG_String::Format(
"No. \tR \tR2 \tR2 adj\tStdErr\tt \tSig. \tb \t\tVariable\n");
955 s +=
CSG_String::Format(
"------\t------\t------\t------\t------\t------\t---------\t---------\t\t---------\n");
double Get_RCoeff(int iVariable) const
double asDouble(int Field) const
static double Get_F_Tail(double F, int dfn, int dfd, TSG_Test_Distribution_Type Type=TESTDIST_TYPE_Right)
class CSG_Table * m_pModel
virtual bool Assign(CSG_Data_Object *pTable)
double Get_Value(const CSG_Vector &Predictors) const
CSG_Matrix Get_Inverse(bool bSilent=true, int nSubSquare=0) const
virtual bool Del_Records(void)
double Get_Residual(int iSample) const
bool Get_Model_Stepwise(const CSG_Matrix &Samples, double P_in, double P_out, CSG_Strings *pNames=NULL)
CSG_Matrix m_Samples_Model
double Get_R2(void) const
virtual ~CSG_Regression_Multiple(void)
int Get_nPredictors(void) const
sLong Get_NRows(void) const
virtual CSG_Table_Record * Get_Record(sLong Index) const
bool _Set_Step_Info(const CSG_Matrix &X)
bool SG_UI_Process_Get_Okay(bool bBlink)
bool Get_Residuals(CSG_Vector &Residuals) const
bool _Initialize(bool bInclude)
double Get_StdError(void) const
double _Get_F(int nPredictors, int nSamples, double r2_full, double r2_reduced)
bool Set_Data(const CSG_Matrix &Samples, CSG_Strings *pNames=NULL)
bool Get_Model_Backward(const CSG_Matrix &Samples, double P_out, CSG_Strings *pNames=NULL)
bool Get_Model_Forward(const CSG_Matrix &Samples, double P_in, CSG_Strings *pNames=NULL)
CSG_Vector Get_Col(sLong Col) const
int Get_nSamples(void) const
bool Add_Cols(sLong nCols)
int Get_DegFreedom(void) const
sLong Get_NCols(void) const
double Get_CV_R2(void) const
bool Create(const CSG_Matrix &Matrix)
const SG_Char * asString(int Field, int Decimals=-99) const
CSG_String Get_Info(void) const
const SG_Char * Get_Name(int iVariable) const
bool Create(const CSG_Vector &Vector)
sLong Get_Count(void) const
double _Get_P(int nPredictors, int nSamples, double r2_full, double r2_reduced)
ESG_Multiple_Regression_Info_Steps
int _Get_Step_Out(CSG_Matrix &X, double P_out, double &R2)
CSG_Regression_Multiple(bool bIntercept=true)
double Get_Parameter(int iVariable, int Parameter) const
int Get_CV_nSamples(void) const
bool Set_Col(sLong Col, const double *Data)
static CSG_String Format(const char *Format,...)
CSG_String & Get_String(int Index) const
CSG_Matrix Get_Transpose(void) const
virtual bool Add_Field(const CSG_String &Name, TSG_Data_Type Type, int Position=-1)
int asInt(int Field) const
double Get_CV_RMSE(void) const
class CSG_Table * m_pSteps
bool Get_Model(const CSG_Matrix &Samples, CSG_Strings *pNames=NULL)
bool Set_Value(int Field, const CSG_String &Value)
double Get_RConst(void) const
ESG_Multiple_Regression_Info_Model
class CSG_Table * m_pRegression
bool Add_Row(const double *Data=NULL)
int _Get_Step_In(CSG_Matrix &X, double P_in, double &R2, const CSG_Matrix &Samples)
double Get_R2_Adj(void) const
static double Get_F_Tail_from_R2(double R2, int nPredictors, int nSamples, TSG_Test_Distribution_Type Type=TESTDIST_TYPE_Right)
int Get_Count(void) const
double Get_CV_NRMSE(void) const
bool _Get_Regression(const class CSG_Matrix &Samples)
virtual CSG_Table_Record * Add_Record(CSG_Table_Record *pCopy=NULL)
double SG_Regression_Get_Adjusted_R2(double r2, int n, int p, TSG_Regression_Correction Correction)
static double Get_T_Tail(double T, int df, TSG_Test_Distribution_Type Type=TESTDIST_TYPE_Right)
bool Get_CrossValidation(int nSubSamples=0)
bool Set_NoData(int Field)