Skip to content

Commit

Permalink
Merge commit 'b2f5abc4ff3f8bbbd8d2bacff1b02602ec62009b'
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomei committed Feb 14, 2024
2 parents c1b99cd + b2f5abc commit d526180
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions agrolib/mathFunctions/statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ namespace statistics

void weightedMultiRegressionLinearWithStats(const std::vector <std::vector <float>> &x, std::vector <float> &y, const std::vector <float> &weight,float* q,std::vector <float> &m,bool calculateR2, bool calculateStdError,float* R2, float* stdError, float *qSE,std::vector <float> &mSE)
{
int nrPredictors = x[0].size();
int nrItems = x.size();
int nrPredictors = int(x[0].size());
int nrItems = int(x.size());
double** XT = (double**)calloc(nrPredictors+1, sizeof(double*));
double** X = (double**)calloc(nrItems, sizeof(double*));
double** X2 = (double**)calloc(nrPredictors+1, sizeof(double*));
Expand Down Expand Up @@ -590,7 +590,7 @@ namespace statistics
yObs[i]=y[i];
weightDouble[i]=weight[i];
}
*R2 = interpolation::computeWeighted_R2(yObs,ySim,weightDouble);
*R2 = float(interpolation::computeWeighted_R2(yObs,ySim,weightDouble));
}
if (calculateStdError)
{
Expand All @@ -607,7 +607,7 @@ namespace statistics
yObs[i]=y[i];
weightDouble[i]=weight[i];
}
*stdError = interpolation::computeWeighted_StandardError(yObs,ySim,weightDouble,nrPredictors+1);
*stdError = float(interpolation::computeWeighted_StandardError(yObs,ySim,weightDouble,nrPredictors+1));
matricial::transposedMatrix(XT,nrPredictors+1,nrItems,X);
for (int j=0;j<nrPredictors+1;j++)
{
Expand All @@ -618,10 +618,10 @@ namespace statistics
}
matricial::matrixProduct(XT,X,nrItems,nrPredictors+1,nrPredictors+1,nrItems,X2);
matricial::inverse(X2,X2Inverse,nrPredictors+1);
*qSE = (*stdError)*sqrt(X2Inverse[0][0]);
*qSE = (*stdError) * float(sqrt(X2Inverse[0][0]));
for (int j=1;j<nrPredictors+1;j++)
{
mSE[j-1]=(*stdError)*sqrt(X2Inverse[j][j]);
mSE[j-1]= (*stdError) * float(sqrt(X2Inverse[j][j]));
}
}

Expand Down

0 comments on commit d526180

Please sign in to comment.