public void BonferroniHolmUnitTest2() { /* example taken from * http://en.wikipedia.org/wiki/Holm-Bonferroni_method#Example * * p = 0.01, 0.04, 0.03, 0.005 * a = 0.05 * cor_p = 0.03, 0.06, 0.06, 0.02 * h = 1, 0, 0, 1 * */ double[] correctedPValues = new double[] { 0.03, 0.06, 0.06, 0.02 }; double[] pVals = new[] { 0.01, 0.04, 0.03, 0.005 }; bool[] h = new bool[] { true, false, false, true }; bool[] decision; var result = BonferroniHolm.Calculate(0.05, pVals, out decision); for (int i = 0; i < pVals.Length; i++) { Assert.AreEqual(correctedPValues[i], result[i]); Assert.AreEqual(h[i], decision[i]); } }
public void BonferroniHolmUnitTest1() { /* example taken from * http://www.mathworks.com/matlabcentral/fileexchange/28303-bonferroni-holm-correction-for-multiple-comparisons * * p = 0.56, 0.22, 0.001, 0.04, 0.01 * a = 0.05 * cor_p = 0.560, 0.440, 0.005, 0.120, 0.040 * h = 0, 0, 1, 0, 1 * */ double[] correctedPValues = new double[] { 0.56, 0.44, 0.005, 0.12, 0.04 }; double[] pVals = new[] { 0.56, 0.22, 0.001, 0.04, 0.01 }; bool[] h = new bool[] { false, false, true, false, true }; bool[] decision; var result = BonferroniHolm.Calculate(0.05, pVals, out decision); for (int i = 0; i < pVals.Length; i++) { Assert.AreEqual(correctedPValues[i], result[i]); Assert.AreEqual(h[i], decision[i]); } }
private void CalculatePairwiseTest(string groupName) { var columnNames = stringConvertibleMatrixView.Content.ColumnNames.ToList(); int colIndex = columnNames.IndexOf(groupName); columnNames = columnNames.Where(x => x != groupName).ToList(); double[][] newData = FilterDataForPairwiseTest(colIndex); var rowNames = new[] { "p-Value of Mann-Whitney U", "Adjusted p-Value of Mann-Whitney U", "p-Value of T-Test", "Adjusted p-Value of T-Test", "Cohen's d", "Hedges' g" }; DoubleMatrix pValsMatrix = new DoubleMatrix(rowNames.Length, columnNames.Count()); pValsMatrix.ColumnNames = columnNames; pValsMatrix.RowNames = rowNames; double mwuBothTails; double tTestBothTails; double[] mwuPValues = new double[newData.Length]; double[] tTestPValues = new double[newData.Length]; bool[] decision = null; double[] adjustedMwuPValues = null; double[] adjustedTtestPValues = null; int cnt = 0; for (int i = 0; i < newData.Length; i++) { mwuBothTails = PairwiseTest.MannWhitneyUTest(data[colIndex], newData[i]); tTestBothTails = PairwiseTest.TTest(data[colIndex], newData[i]); mwuPValues[i] = mwuBothTails; tTestPValues[i] = tTestBothTails; if (mwuBothTails > significanceLevel) { cnt++; } } adjustedMwuPValues = BonferroniHolm.Calculate(significanceLevel, mwuPValues, out decision); adjustedTtestPValues = BonferroniHolm.Calculate(significanceLevel, tTestPValues, out decision); for (int i = 0; i < newData.Length; i++) { pValsMatrix[0, i] = mwuPValues[i]; pValsMatrix[1, i] = adjustedMwuPValues[i]; pValsMatrix[2, i] = tTestPValues[i]; pValsMatrix[3, i] = adjustedTtestPValues[i]; pValsMatrix[4, i] = SampleSizeDetermination.CalculateCohensD(data[colIndex], newData[i]); pValsMatrix[5, i] = SampleSizeDetermination.CalculateHedgesG(data[colIndex], newData[i]); } Invoke(new Action(() => { pairwiseStringConvertibleMatrixView.Content = pValsMatrix; pairwiseStringConvertibleMatrixView.DataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); })); ShowPairwiseResult(cnt); }
public void BonferroniHolmUnitTest3() { // comparison with R's p.adjust(p, "holm") method double[] correctedPValues = new double[] { 0.23262159, 0.05204139 }; double[] pVals = new[] { 0.232621592948806, 0.0260206949805373 }; bool[] decision; var result = BonferroniHolm.Calculate(0.05, pVals, out decision); for (int i = 0; i < pVals.Length; i++) { Assert.AreEqual(correctedPValues[i], Math.Round(result[i], 8)); } }
public void BonferroniHolmUnitTest5() { // comparison with R's p.adjust(p, "holm") method double[] correctedPValues = new double[] { 1.389563e-05, 7.293675e-05, 2.330999e-04, 2.330999e-04, 4.370736e-04, 5.539326e-04 }; double[] pVals = new[] { 2.315938e-06, 1.458735e-05, 5.827497e-05, 7.166659e-05, 2.185368e-04, 5.539326e-04 }; bool[] decision; var result = BonferroniHolm.Calculate(0.05, pVals, out decision); for (int i = 0; i < pVals.Length; i++) { Assert.AreEqual(Math.Round(correctedPValues[i], 10), Math.Round(result[i], 10)); } }
public void BonferroniHolmUnitTest4() { // comparison with R's p.adjust(p, "holm") method double[] correctedPValues = new double[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; double[] pVals = new[] { 0.1108139, 0.1241641, 0.2805913, 0.3715633, 0.3967397, 0.6165547, 0.7272018, 0.8774432, 0.9495787, 0.9755199 }; bool[] decision; var result = BonferroniHolm.Calculate(0.05, pVals, out decision); for (int i = 0; i < pVals.Length; i++) { Assert.AreEqual(correctedPValues[i], Math.Round(result[i], 8)); } }