public void Compute() { if (YesYesValue.HasValue && YesNoValue.HasValue && NoYesValue.HasValue && NoNoValue.HasValue && tooManyCases.HasValue && tooFewCases.HasValue && tooManyControls.HasValue && tooFewControls.HasValue) { Epi.Statistics.pmccTable pmccTable = new Epi.Statistics.pmccTable(); Epi.Statistics.pmccTable.SingleTableResults statTable = pmccTable.statTable((double)ynVal.Value, (double)nyVal.Value); pmccTable = null; string fisherExact = Epi.SharedStrings.UNDEFINED; string fisherExact2P = Epi.SharedStrings.UNDEFINED; string fisherLower = Epi.SharedStrings.UNDEFINED; string fisherUpper = Epi.SharedStrings.UNDEFINED; string oddsRatioEstimate = Epi.SharedStrings.UNDEFINED; string oddsRatioLower = Epi.SharedStrings.UNDEFINED; string oddsRatioUpper = Epi.SharedStrings.UNDEFINED; if (!Double.IsNaN(statTable.FisherExactP) && statTable.FisherExactP != -1) { fisherExact = ((double)statTable.FisherExactP).ToString("F10"); clOneTailP.Text = "1 Tailed P"; clTwoTailP.Text = "2 Tailed P"; tblockFisherExactPLabel.Text = "Fisher Exact"; fisherBorderLine.Visibility = System.Windows.Visibility.Visible; } else { fisherExact = ""; fisherExact2P = ""; tblockFisherExactPLabel.Text = ""; clOneTailP.Text = ""; clTwoTailP.Text = ""; fisherBorderLine.Visibility = System.Windows.Visibility.Hidden; } if (!Double.IsNaN(statTable.FisherExact2P) && statTable.FisherExact2P != -1) { fisherExact2P = ((double)statTable.FisherExact2P).ToString("F10"); } if (!Double.IsNaN(statTable.OddsRatioFisherLower) && statTable.OddsRatioFisherLower != -1) { fisherLower = ((double)statTable.OddsRatioFisherLower).ToString("F4"); tblockFisherExactLabel.Text = "Exact"; } else { fisherLower = ""; fisherUpper = ""; tblockFisherExactLabel.Text = ""; } if (!Double.IsNaN(statTable.OddsRatioFisherUpper) && statTable.OddsRatioFisherUpper != -1) { fisherUpper = ((double)statTable.OddsRatioFisherUpper).ToString("F4"); } if (statTable.OddsRatioEstimate != null) { oddsRatioEstimate = ((double)statTable.OddsRatioEstimate).ToString("F4"); } if (statTable.OddsRatioLower != null) { oddsRatioLower = ((double)statTable.OddsRatioLower).ToString("F4"); } if (statTable.OddsRatioUpper != null) { oddsRatioUpper = ((double)statTable.OddsRatioUpper).ToString("F4"); } int discordantPairs = (int)ynVal.Value + (int)nyVal.Value; int totalPairs = (int)yyVal.Value + (int)ynVal.Value + (int)nyVal.Value + (int)nnVal.Value; txtChiSqCorP.Text = statTable.McNemarCor2P.ToString("F10"); txtChiSqCorVal.Text = statTable.McNemarCorVal.ToString("F4"); txtChiSqUncP.Text = statTable.McNemarUncorrected2P.ToString("F10"); txtChiSqUncVal.Text = statTable.McNemarUncorrectedVal.ToString("F4"); txtOddsRatioEstimate.Text = oddsRatioEstimate; txtOddsRatioLower.Text = oddsRatioLower; txtOddsRatioUpper.Text = oddsRatioUpper; txtFisherLower.Text = fisherLower; txtFisherUpper.Text = fisherUpper; txtFisherExact.Text = fisherExact; txtFisherExact2P.Text = fisherExact2P; testDisclaimer0.Visibility = System.Windows.Visibility.Visible; testDisclaimer0.Text = "There are " + discordantPairs + " discordant pairs. Because this number"; if (discordantPairs < 20) { testDisclaimer1.Visibility = System.Windows.Visibility.Visible; testDisclaimer1.Text = "is fewer than 20, it is recommended that"; testDisclaimer2.Visibility = System.Windows.Visibility.Visible; testDisclaimer2.Text = "only the exact results be used."; } else { testDisclaimer1.Visibility = System.Windows.Visibility.Visible; testDisclaimer1.Text = "is >= 20, the McNemar test can be used."; testDisclaimer2.Text = ""; testDisclaimer2.Visibility = System.Windows.Visibility.Collapsed; } if (totalPairs == 0) { testDisclaimer0.Text = "No pairs were counted. Confirm that case/control and "; testDisclaimer1.Visibility = System.Windows.Visibility.Visible; testDisclaimer1.Text = "exposure variables have 2 possible values."; testDisclaimer2.Text = ""; testDisclaimer2.Visibility = System.Windows.Visibility.Collapsed; } if ((int)ynVal.Value == 0 || (int)nyVal.Value == 0) { zeroDisclaimer0.Visibility = System.Windows.Visibility.Visible; } else { zeroDisclaimer0.Visibility = System.Windows.Visibility.Collapsed; } if (tMCa == 1) { testDisclaimer3.Visibility = System.Windows.Visibility.Visible; testDisclaimer3.Text = "1 group has more than one case."; } else if (tMCa > 1) { testDisclaimer3.Visibility = System.Windows.Visibility.Visible; testDisclaimer3.Text = tMCa + " groups have more than one case."; } else { testDisclaimer3.Visibility = System.Windows.Visibility.Collapsed; } if (tFCa == 1) { testDisclaimer4.Visibility = System.Windows.Visibility.Visible; testDisclaimer4.Text = "1 group has no case."; } else if (tFCa > 1) { testDisclaimer4.Visibility = System.Windows.Visibility.Visible; testDisclaimer4.Text = tFCa + " groups have no case."; } else { testDisclaimer4.Visibility = System.Windows.Visibility.Collapsed; } if (tMCo == 1) { testDisclaimer5.Visibility = System.Windows.Visibility.Visible; testDisclaimer5.Text = "1 group has more than one control."; } else if (tMCo > 1) { testDisclaimer5.Visibility = System.Windows.Visibility.Visible; testDisclaimer5.Text = tMCo + " groups have more than one control."; } else { testDisclaimer5.Visibility = System.Windows.Visibility.Collapsed; } if (tFCo == 1) { testDisclaimer6.Visibility = System.Windows.Visibility.Visible; testDisclaimer6.Text = "1 group has no control."; } else if (tFCo > 1) { testDisclaimer6.Visibility = System.Windows.Visibility.Visible; testDisclaimer6.Text = tFCo + " groups have no control."; } else { testDisclaimer6.Visibility = System.Windows.Visibility.Collapsed; } } }
public void Compute() { if (YesYesValue.HasValue && YesNoValue.HasValue && NoYesValue.HasValue && NoNoValue.HasValue && tooManyCases.HasValue && tooFewCases.HasValue && tooManyControls.HasValue && tooFewControls.HasValue) { Epi.Statistics.pmccTable pmccTable = new Epi.Statistics.pmccTable(); Epi.Statistics.pmccTable.SingleTableResults statTable = pmccTable.statTable((double)ynVal.Value, (double)nyVal.Value); pmccTable = null; string fisherExact = Epi.SharedStrings.UNDEFINED; string fisherExact2P = Epi.SharedStrings.UNDEFINED; string fisherLower = Epi.SharedStrings.UNDEFINED; string fisherUpper = Epi.SharedStrings.UNDEFINED; string oddsRatioEstimate = Epi.SharedStrings.UNDEFINED; string oddsRatioLower = Epi.SharedStrings.UNDEFINED; string oddsRatioUpper = Epi.SharedStrings.UNDEFINED; if (!Double.IsNaN(statTable.FisherExactP) && statTable.FisherExactP != -1) { fisherExact = ((double)statTable.FisherExactP).ToString("F10"); clOneTailP.Text = "1 Tailed P"; clTwoTailP.Text = "2 Tailed P"; tblockFisherExactPLabel.Text = "Fisher Exact"; fisherBorderLine.Visibility = System.Windows.Visibility.Visible; } else { fisherExact = ""; fisherExact2P = ""; tblockFisherExactPLabel.Text = ""; clOneTailP.Text = ""; clTwoTailP.Text = ""; fisherBorderLine.Visibility = System.Windows.Visibility.Hidden; } if (!Double.IsNaN(statTable.FisherExact2P) && statTable.FisherExact2P != -1) { fisherExact2P = ((double)statTable.FisherExact2P).ToString("F10"); } if (!Double.IsNaN(statTable.OddsRatioFisherLower) && statTable.OddsRatioFisherLower != -1) { fisherLower = ((double)statTable.OddsRatioFisherLower).ToString("F4"); tblockFisherExactLabel.Text = "Exact"; } else { fisherLower = ""; fisherUpper = ""; tblockFisherExactLabel.Text = ""; } if (!Double.IsNaN(statTable.OddsRatioFisherUpper) && statTable.OddsRatioFisherUpper != -1) { fisherUpper = ((double)statTable.OddsRatioFisherUpper).ToString("F4"); } if (statTable.OddsRatioEstimate != null) { oddsRatioEstimate = ((double)statTable.OddsRatioEstimate).ToString("F4"); } if (statTable.OddsRatioLower != null) { oddsRatioLower = ((double)statTable.OddsRatioLower).ToString("F4"); } if (statTable.OddsRatioUpper != null) { oddsRatioUpper = ((double)statTable.OddsRatioUpper).ToString("F4"); } int discordantPairs = (int) ynVal.Value + (int) nyVal.Value; int totalPairs = (int)yyVal.Value + (int)ynVal.Value + (int)nyVal.Value + (int)nnVal.Value; txtChiSqCorP.Text = statTable.McNemarCor2P.ToString("F10"); txtChiSqCorVal.Text = statTable.McNemarCorVal.ToString("F4"); txtChiSqUncP.Text = statTable.McNemarUncorrected2P.ToString("F10"); txtChiSqUncVal.Text = statTable.McNemarUncorrectedVal.ToString("F4"); txtOddsRatioEstimate.Text = oddsRatioEstimate; txtOddsRatioLower.Text = oddsRatioLower; txtOddsRatioUpper.Text = oddsRatioUpper; txtFisherLower.Text = fisherLower; txtFisherUpper.Text = fisherUpper; txtFisherExact.Text = fisherExact; txtFisherExact2P.Text = fisherExact2P; testDisclaimer0.Visibility = System.Windows.Visibility.Visible; testDisclaimer0.Text = "There are " + discordantPairs + " discordant pairs. Because this number"; if (discordantPairs < 20) { testDisclaimer1.Visibility = System.Windows.Visibility.Visible; testDisclaimer1.Text = "is fewer than 20, it is recommended that"; testDisclaimer2.Visibility = System.Windows.Visibility.Visible; testDisclaimer2.Text = "only the exact results be used."; } else { testDisclaimer1.Visibility = System.Windows.Visibility.Visible; testDisclaimer1.Text = "is >= 20, the McNemar test can be used."; testDisclaimer2.Text = ""; testDisclaimer2.Visibility = System.Windows.Visibility.Collapsed; } if (totalPairs == 0) { testDisclaimer0.Text = "No pairs were counted. Confirm that case/control and "; testDisclaimer1.Visibility = System.Windows.Visibility.Visible; testDisclaimer1.Text = "exposure variables have 2 possible values."; testDisclaimer2.Text = ""; testDisclaimer2.Visibility = System.Windows.Visibility.Collapsed; } if ((int) ynVal.Value == 0 || (int) nyVal.Value == 0) { zeroDisclaimer0.Visibility = System.Windows.Visibility.Visible; } else { zeroDisclaimer0.Visibility = System.Windows.Visibility.Collapsed; } if (tMCa == 1) { testDisclaimer3.Visibility = System.Windows.Visibility.Visible; testDisclaimer3.Text = "1 group has more than one case."; } else if (tMCa > 1) { testDisclaimer3.Visibility = System.Windows.Visibility.Visible; testDisclaimer3.Text = tMCa + " groups have more than one case."; } else testDisclaimer3.Visibility = System.Windows.Visibility.Collapsed; if (tFCa == 1) { testDisclaimer4.Visibility = System.Windows.Visibility.Visible; testDisclaimer4.Text = "1 group has no case."; } else if (tFCa > 1) { testDisclaimer4.Visibility = System.Windows.Visibility.Visible; testDisclaimer4.Text = tFCa + " groups have no case."; } else testDisclaimer4.Visibility = System.Windows.Visibility.Collapsed; if (tMCo == 1) { testDisclaimer5.Visibility = System.Windows.Visibility.Visible; testDisclaimer5.Text = "1 group has more than one control."; } else if (tMCo > 1) { testDisclaimer5.Visibility = System.Windows.Visibility.Visible; testDisclaimer5.Text = tMCo + " groups have more than one control."; } else testDisclaimer5.Visibility = System.Windows.Visibility.Collapsed; if (tFCo == 1) { testDisclaimer6.Visibility = System.Windows.Visibility.Visible; testDisclaimer6.Text = "1 group has no control."; } else if (tFCo > 1) { testDisclaimer6.Visibility = System.Windows.Visibility.Visible; testDisclaimer6.Text = tFCo + " groups have no control."; } else testDisclaimer6.Visibility = System.Windows.Visibility.Collapsed; } }