Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9957 for branches


Ignore:
Timestamp:
09/13/13 12:24:04 (11 years ago)
Author:
ascheibe
Message:

#2031 fixed pairwise tests

Location:
branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/StatisticalTestingView.cs

    r9950 r9957  
    348348      }
    349349
     350      double[][] newData = FilterDataForPairwiseTest(colIndex);
     351
    350352      double mwuBothtails;
    351353      double mwuLefttail;
     
    353355      int cnt = 0;
    354356
    355       for (int i = 0; i < data.Length; i++) {
    356         if (i != colIndex) {
    357           alglib.mannwhitneyutest(data[colIndex], data[colIndex].Length, data[i], data[i].Length, out mwuBothtails, out mwuLefttail, out mwuRighttail);
    358           if (mwuBothtails > significanceLevel) {
    359             cnt++;
    360           }
     357      for (int i = 0; i < newData.Length; i++) {
     358        alglib.mannwhitneyutest(data[colIndex], data[colIndex].Length, newData[i], newData[i].Length, out mwuBothtails, out mwuLefttail, out mwuRighttail);
     359        if (mwuBothtails > significanceLevel) {
     360          cnt++;
    361361        }
    362362      }
     
    372372    }
    373373
     374    private double[][] FilterDataForPairwiseTest(int columnToRemove) {
     375      double[][] newData = new double[data.Length - 1][];
     376
     377      int i = 0;
     378      int l = 0;
     379      while (i < data.Length) {
     380        if (i != columnToRemove) {
     381          double[] row = new double[data[i].Length - 1];
     382          newData[l] = row;
     383
     384          int j = 0, k = 0;
     385          while (j < row.Length) {
     386            if (i != columnToRemove) {
     387              newData[l][j] = data[i][k];
     388              j++;
     389              k++;
     390            } else {
     391              k++;
     392            }
     393          }
     394          i++;
     395          l++;
     396        } else {
     397          i++;
     398        }
     399      }
     400      return newData;
     401    }
     402
    374403    private void CalculatePairwiseTestDetails(string groupName) {
    375404      int colIndex = 0;
     
    384413      }
    385414
     415      double[][] newData = FilterDataForPairwiseTest(colIndex);
     416
     417      columnNames = columnNames.Where(x => x != groupName).ToList();
     418
    386419      var rowNames = new string[] { "p-Value of Mann-Whitney U", "Adjusted p-Value of Mann-Whitney U",
    387420            "p-Value of T-Test", "Adjusted p-Value of T-Test", "Necessary Sample Size for T-Test", "Cohen's d", "Hedges' g" };
    388421
    389       DoubleMatrix pValsMatrix = new DoubleMatrix(rowNames.Length, stringConvertibleMatrixView.Content.Columns);
    390       pValsMatrix.ColumnNames = stringConvertibleMatrixView.Content.ColumnNames;
     422      DoubleMatrix pValsMatrix = new DoubleMatrix(rowNames.Length, columnNames.Count());
     423      pValsMatrix.ColumnNames = columnNames;
    391424      pValsMatrix.RowNames = rowNames;
    392425
     
    395428      double mwuRighttail;
    396429      double tTestLefttail;
    397       double[] mwuPValues = new double[data.Length];
    398       double[] tTestPValues = new double[data.Length];
     430      double[] mwuPValues = new double[newData.Length];
     431      double[] tTestPValues = new double[newData.Length];
    399432      bool[] decision = null;
    400433      double[] adjustedMwuPValues = null;
    401434      double[] adjustedTtestPValues = null;
    402435
    403       for (int i = 0; i < data.Length; i++) {
    404         alglib.mannwhitneyutest(data[colIndex], data[colIndex].Length, data[i], data[i].Length, out mwuBothtails, out mwuLefttail, out mwuRighttail);
    405         tTestLefttail = TTest.Test(data[colIndex], data[i]);
    406         mwuPValues[i] = mwuBothtails;
    407         tTestPValues[i] = tTestLefttail;
     436      for (int i = 0; i < newData.Length; i++) {
     437        if (i != colIndex) {
     438          alglib.mannwhitneyutest(data[colIndex], data[colIndex].Length, newData[i], newData[i].Length, out mwuBothtails,
     439            out mwuLefttail, out mwuRighttail);
     440          tTestLefttail = TTest.Test(data[colIndex], newData[i]);
     441          mwuPValues[i] = mwuBothtails;
     442          tTestPValues[i] = tTestLefttail;
     443        }
    408444      }
    409445
     
    411447      adjustedTtestPValues = BonferroniHolm.Calculate(significanceLevel, tTestPValues, out decision);
    412448
    413       for (int i = 0; i < data.Length; i++) {
    414         pValsMatrix[0, i] = mwuPValues[i];
    415         pValsMatrix[1, i] = adjustedMwuPValues[i];
    416         pValsMatrix[2, i] = tTestPValues[i];
    417         pValsMatrix[3, i] = adjustedTtestPValues[i];
    418         pValsMatrix[4, i] = TTest.GetOptimalSampleSize(data[colIndex], data[i]);
    419         pValsMatrix[5, i] = SampleSizeDetermination.CalculateCohensD(data[colIndex], data[i]);
    420         pValsMatrix[6, i] = SampleSizeDetermination.CalculateHedgesG(data[colIndex], data[i]);
     449      for (int i = 0; i < newData.Length; i++) {
     450        if (i != colIndex) {
     451          pValsMatrix[0, i] = mwuPValues[i];
     452          pValsMatrix[1, i] = adjustedMwuPValues[i];
     453          pValsMatrix[2, i] = tTestPValues[i];
     454          pValsMatrix[3, i] = adjustedTtestPValues[i];
     455          pValsMatrix[4, i] = TTest.GetOptimalSampleSize(data[colIndex], newData[i]);
     456          pValsMatrix[5, i] = SampleSizeDetermination.CalculateCohensD(data[colIndex], newData[i]);
     457          pValsMatrix[6, i] = SampleSizeDetermination.CalculateHedgesG(data[colIndex], newData[i]);
     458        }
    421459      }
    422460
  • branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/StatisticalTestingView.designer.cs

    r9937 r9957  
    339339      this.allGroupTestGroupBox.TabIndex = 21;
    340340      this.allGroupTestGroupBox.TabStop = false;
    341       this.allGroupTestGroupBox.Text = "3. Equal Distributions Check using all Groups";
     341      this.allGroupTestGroupBox.Text = "3. Kruskal Wallis Test for Inequalities in Distributions";
    342342      //
    343343      // groupCompLabel
     
    365365      this.normalityGroupBox.TabIndex = 20;
    366366      this.normalityGroupBox.TabStop = false;
    367       this.normalityGroupBox.Text = "2. Normal Distribution Check";
     367      this.normalityGroupBox.Text = "2. Jarque-Bera Test for Normal Distribution";
    368368      //
    369369      // label4
Note: See TracChangeset for help on using the changeset viewer.