[9950] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[11375] | 3 | * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[9950] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using HeuristicLab.Analysis.Statistics;
|
---|
| 23 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
| 24 |
|
---|
| 25 | namespace Statistics.UnitTests {
|
---|
| 26 | [TestClass]
|
---|
| 27 | public class BonferroniHolmUnitTest {
|
---|
| 28 | [TestMethod]
|
---|
| 29 | public void TestMethod1() {
|
---|
| 30 | /* example taken from
|
---|
| 31 | * http://www.mathworks.com/matlabcentral/fileexchange/28303-bonferroni-holm-correction-for-multiple-comparisons
|
---|
| 32 | *
|
---|
[10017] | 33 | * p = 0.56, 0.22, 0.001, 0.04, 0.01
|
---|
| 34 | * a = 0.05
|
---|
| 35 | * cor_p = 0.560, 0.440, 0.005, 0.120, 0.040
|
---|
[9950] | 36 | * h = 0, 0, 1, 0, 1
|
---|
| 37 | *
|
---|
| 38 | */
|
---|
| 39 |
|
---|
| 40 | double[] correctedPValues = new double[] { 0.56, 0.44, 0.005, 0.12, 0.04 };
|
---|
| 41 | double[] pVals = new[] { 0.56, 0.22, 0.001, 0.04, 0.01 };
|
---|
| 42 | bool[] h = new bool[] { false, false, true, false, true };
|
---|
| 43 | bool[] decision;
|
---|
| 44 |
|
---|
| 45 | var result = BonferroniHolm.Calculate(0.05, pVals, out decision);
|
---|
| 46 |
|
---|
| 47 | for (int i = 0; i < pVals.Length; i++) {
|
---|
| 48 | Assert.AreEqual(correctedPValues[i], result[i]);
|
---|
| 49 | Assert.AreEqual(h[i], decision[i]);
|
---|
| 50 | }
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | [TestMethod]
|
---|
| 54 | public void TestMethod2() {
|
---|
| 55 | /* example taken from
|
---|
| 56 | * http://en.wikipedia.org/wiki/Holm-Bonferroni_method#Example
|
---|
| 57 | *
|
---|
[10017] | 58 | * p = 0.01, 0.04, 0.03, 0.005
|
---|
| 59 | * a = 0.05
|
---|
| 60 | * cor_p = 0.03, 0.06, 0.06, 0.02
|
---|
[9950] | 61 | * h = 1, 0, 0, 1
|
---|
| 62 | *
|
---|
| 63 | */
|
---|
| 64 |
|
---|
[9951] | 65 | double[] correctedPValues = new double[] { 0.03, 0.06, 0.06, 0.02 };
|
---|
[9950] | 66 | double[] pVals = new[] { 0.01, 0.04, 0.03, 0.005 };
|
---|
| 67 | bool[] h = new bool[] { true, false, false, true };
|
---|
| 68 | bool[] decision;
|
---|
| 69 |
|
---|
[9951] | 70 | var result = BonferroniHolm.Calculate(0.05, pVals, out decision);
|
---|
[9950] | 71 |
|
---|
| 72 | for (int i = 0; i < pVals.Length; i++) {
|
---|
[9951] | 73 | Assert.AreEqual(correctedPValues[i], result[i]);
|
---|
[9950] | 74 | Assert.AreEqual(h[i], decision[i]);
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
| 78 | }
|
---|