Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4143


Ignore:
Timestamp:
08/04/10 14:21:47 (13 years ago)
Author:
gkronber
Message:

Fixed calculation of p-values for variable impacts (the calculation procedure was implemented incorrectly because in r4121). #1011

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/RunCollectionVariableImpactView.cs

    r4124 r4143  
    9292                                         .ToList();
    9393
    94         List<string> statictics = new List<string> { "Median Rank", "pValue", "Mean", "StdDev", };
     94        List<string> statictics = new List<string> { "Median Rank", "Mean", "StdDev", "pValue" };
    9595        List<string> columnNames = runsWithVariables.Select(r => r.Name).ToList();
    9696        columnNames.AddRange(statictics);
     
    120120                                        .ToList();
    121121        if (variableImpactsOverRuns.Count() > 0) {
    122           // reference median is the worst median rank
    123           double referenceMedian = (from impacts in variableRanks
    124                                     let med = impacts.Median()
    125                                     orderby med
    126                                     select med)
    127                                            .Last();
     122          // the variable with the worst median impact value is chosen as the reference variable
     123          // this is problematic if all variables are relevant, however works often in practice
     124          List<double> referenceImpacts = (from impacts in variableImpactsOverRuns
     125                                           let avg = impacts.Median()
     126                                           orderby avg
     127                                           select impacts)
     128                                           .First();
    128129          // for all variables
    129130          for (int row = 0; row < variableImpactsOverRuns.Count; row++) {
     131            // median rank
    130132            matrix[row, runs] = variableRanks[row].Median();
     133            // also show mean and std.dev. of relative variable impacts to indicate the relative difference in impacts of variables
     134            matrix[row, runs + 1] = variableImpactsOverRuns[row].Average();
     135            matrix[row, runs + 2] = variableImpactsOverRuns[row].StandardDeviation();
    131136
    132             // check if the median of the ranks is significantly different to the reference median rank
    133137            double leftTail = 0; double rightTail = 0; double bothTails = 0;
    134             double[] ranksArray = variableRanks[row].ToArray();
    135 
    136             // wilcoxon signed rank test is used because the ranks of two variables in a single run are not independent
    137             alglib.wsr.wilcoxonsignedranktest(ranksArray, ranksArray.Length, referenceMedian, ref bothTails, ref leftTail, ref rightTail);
    138             matrix[row, runs + 1] = bothTails;
    139 
    140             // also show mean and std.dev. of relative variable impacts to indicate the relative difference in impacts of variables
    141             matrix[row, runs + 2] = variableImpactsOverRuns[row].Average();
    142             matrix[row, runs + 3] = variableImpactsOverRuns[row].StandardDeviation();
    143 
     138            // calc differences of impacts for current variable and reference variable
     139            double[] z = new double[referenceImpacts.Count];
     140            for (int i = 0; i < z.Length; i++) {
     141              z[i] = variableImpactsOverRuns[row][i] - referenceImpacts[i];
     142            }
     143            // wilcoxon signed rank test is used because the impact values of two variables in a single run are not independent
     144            alglib.wsr.wilcoxonsignedranktest(z, z.Length, 0, ref bothTails, ref leftTail, ref rightTail);
     145            matrix[row, runs + 3] = bothTails;
    144146          }
    145147        }
Note: See TracChangeset for help on using the changeset viewer.