Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/12/13 14:21:06 (11 years ago)
Author:
ascheibe
Message:

#2031 added Bonferroni-Holm adjusted p-values to the statistical testing view

File:
1 edited

Legend:

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

    r9937 r9950  
    3636  [Content(typeof(RunCollection), false)]
    3737  public sealed partial class StatisticalTestingView : ItemView {
     38    private const double significanceLevel = 0.05;
    3839    private double[][] data;
    3940
     
    297298      double pval = KruskalWallis.Test(data);
    298299      pValTextBox.Text = pval.ToString();
    299       if (pval < 0.05) {
     300      if (pval < significanceLevel) {
    300301        this.Invoke(new Action(() => { groupCompLabel.Image = HeuristicLab.Analysis.Statistics.Resources.Default; }));
    301302      } else {
     
    314315
    315316      // p-value is below significance level and thus the null hypothesis (data is normally distributed) is rejected.
    316       if (res.Any(x => x < 0.05)) {
     317      if (res.Any(x => x < significanceLevel)) {
    317318        this.Invoke(new Action(() => { normalityLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Warning; }));
    318319      } else {
     
    355356        if (i != colIndex) {
    356357          alglib.mannwhitneyutest(data[colIndex], data[colIndex].Length, data[i], data[i].Length, out mwuBothtails, out mwuLefttail, out mwuRighttail);
    357           if (mwuBothtails > 0.05) {
     358          if (mwuBothtails > significanceLevel) {
    358359            cnt++;
    359360          }
     
    383384      }
    384385
    385       DoubleMatrix pValsMatrix = new DoubleMatrix(5, stringConvertibleMatrixView.Content.Columns);
     386      var rowNames = new string[] { "p-Value of Mann-Whitney U", "Adjusted p-Value of Mann-Whitney U",
     387            "p-Value of T-Test", "Adjusted p-Value of T-Test", "Necessary Sample Size for T-Test", "Cohen's d", "Hedges' g" };
     388
     389      DoubleMatrix pValsMatrix = new DoubleMatrix(rowNames.Length, stringConvertibleMatrixView.Content.Columns);
    386390      pValsMatrix.ColumnNames = stringConvertibleMatrixView.Content.ColumnNames;
    387       pValsMatrix.RowNames = new string[] { "p-Value of Mann-Whitney U", "p-Value of T-Test", "Necessary Sample Size for T-Test", "Cohen's d", "Hedges' g" };
     391      pValsMatrix.RowNames = rowNames;
    388392
    389393      double mwuBothtails;
    390394      double mwuLefttail;
    391395      double mwuRighttail;
    392       double ttestLefttail;
     396      double tTestLefttail;
     397      double[] mwuPValues = new double[data.Length];
     398      double[] tTestPValues = new double[data.Length];
     399      bool[] decision = null;
     400      double[] adjustedMwuPValues = null;
     401      double[] adjustedTtestPValues = null;
     402
    393403      for (int i = 0; i < data.Length; i++) {
    394404        alglib.mannwhitneyutest(data[colIndex], data[colIndex].Length, data[i], data[i].Length, out mwuBothtails, out mwuLefttail, out mwuRighttail);
    395         ttestLefttail = TTest.Test(data[colIndex], data[i]);
    396         pValsMatrix[0, i] = mwuBothtails;
    397         pValsMatrix[1, i] = ttestLefttail;
    398         pValsMatrix[2, i] = TTest.GetOptimalSampleSize(data[colIndex], data[i]);
    399         pValsMatrix[3, i] = SampleSizeDetermination.CalculateCohensD(data[colIndex], data[i]);
    400         pValsMatrix[4, i] = SampleSizeDetermination.CalculateHedgesG(data[colIndex], data[i]);
     405        tTestLefttail = TTest.Test(data[colIndex], data[i]);
     406        mwuPValues[i] = mwuBothtails;
     407        tTestPValues[i] = tTestLefttail;
     408      }
     409
     410      adjustedMwuPValues = BonferroniHolm.Calculate(significanceLevel, mwuPValues, out decision);
     411      adjustedTtestPValues = BonferroniHolm.Calculate(significanceLevel, tTestPValues, out decision);
     412
     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]);
    401421      }
    402422
Note: See TracChangeset for help on using the changeset viewer.