Beispiel #1
0
        public static String NoDummyVariables(double[,] cm, String[] bLabels, double[] B, String lastVar1, String lastVar2, int interactions, int iaTerms, double[,] DataArray)
        {
            String iorOut  = "";
            double Z       = SharedResources.ZFromP(0.025);
            int    column2 = 1;

            for (int i = 0; i < bLabels.Length; i++)
            {
                if (bLabels[i] != null && bLabels[i].Equals(lastVar2))
                {
                    column2 += i;
                }
            }
            double ref2        = getColumnMean(column2, DataArray);
            int    singleIndex = getContinuousIndex(lastVar1, bLabels);

            int[] interactionIndexes = getInteractionIndexes(interactions, iaTerms, bLabels);
            iorOut = iorOut + "<table><tr><td class=\"stats\" colspan=4 align=\"left\"><strong>Odds Ratios for " + lastVar1 + " * " + lastVar2 + " Interaction</strong></td></tr><tr><td class=\"stats\" align=\"left\"><strong>Label</strong></td><td class=\"stats\" align=\"center\"><strong>Estimate</strong></td><td class=\"stats\" colspan=2 align=\"center\"><strong>95% Confidence Limits</strong></td></tr>";

            double est      = B[singleIndex] + ref2 * B[interactionIndexes[0]];
            double variance = cm[singleIndex, singleIndex] + Math.Pow(ref2, 2.0) * cm[interactionIndexes[0], interactionIndexes[0]] +
                              2 * ref2 * cm[singleIndex, interactionIndexes[0]];
            double lcl = est - Z * Math.Sqrt(variance);
            double ucl = est + Z * Math.Sqrt(variance);

            iorOut = iorOut + "<tr><td class=\"stats\"><strong>" + lastVar1 + " at " + lastVar2 + "=" + ref2.ToString("F3") + "</strong></td>";
            if (Math.Exp(est) < 1000)
            {
                iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("F4") + "</td>";
            }
            else
            {
                iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("0.##E+0") + "</td>";
            }
            if (Math.Exp(lcl) < 1000)
            {
                iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("F4") + "</td>";
            }
            else
            {
                iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("0.##E+0") + "</td>";
            }
            if (Math.Exp(ucl) < 1000)
            {
                iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("F4") + "</td></tr>";
            }
            else
            {
                iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("0.##E+0") + "</td></tr>";
            }

            return(iorOut + "</table>");
        }
Beispiel #2
0
        public static String DummyLast(double[,] cm, String[] bLabels, double[] B, String lastVar1, String lastVar2, int interactions, int iaTerms, double[,] DataArray)
        {
            String iorOut      = "";
            double Z           = SharedResources.ZFromP(0.025);
            String ref1        = getRef(lastVar1, bLabels);
            int    singleIndex = getContinuousIndex(lastVar2, bLabels);

            int[]    interactionIndexes = getInteractionIndexes(interactions, iaTerms, bLabels);
            String[] otherValues1       = getNonRef(lastVar1, bLabels);
            iorOut = iorOut + "<table><tr><td class=\"stats\" colspan=4 align=\"left\"><strong>Odds Ratios for " + lastVar2 + " * " + lastVar1 + " Interaction</strong></td></tr><tr><td class=\"stats\" align=\"left\"><strong>Label</strong></td><td class=\"stats\" align=\"center\"><strong>Estimate</strong></td><td class=\"stats\" colspan=2 align=\"center\"><strong>95% Confidence Limits</strong></td></tr>";

            double est0      = B[singleIndex];
            double variance0 = cm[singleIndex, singleIndex];
            double lcl0      = est0 - Z * Math.Sqrt(variance0);
            double ucl0      = est0 + Z * Math.Sqrt(variance0);

            iorOut = iorOut + "<tr><td class=\"stats\"><strong>" + lastVar2 + " at " + lastVar1 + "=" + ref1 + "</strong></td>";
            if (Math.Exp(0) < 1000)
            {
                iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est0).ToString("F4") + "</td>";
            }
            else
            {
                iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est0).ToString("0.##E+0") + "</td>";
            }
            if (Math.Exp(lcl0) < 1000)
            {
                iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl0).ToString("F4") + "</td>";
            }
            else
            {
                iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl0).ToString("0.##E+0") + "</td>";
            }
            if (Math.Exp(ucl0) < 1000)
            {
                iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl0).ToString("F4") + "</td></tr>";
            }
            else
            {
                iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl0).ToString("0.##E+0") + "</td></tr>";
            }

            for (int i = 0; i < otherValues1.Length / 2; i++)
            {
                double est      = B[singleIndex] + B[interactionIndexes[i]];
                double variance = cm[singleIndex, singleIndex] +
                                  cm[interactionIndexes[i], interactionIndexes[i]] +
                                  2 * cm[singleIndex, interactionIndexes[i]];
                double lcl = est - Z * Math.Sqrt(variance);
                double ucl = est + Z * Math.Sqrt(variance);
                iorOut = iorOut + "<tr><td class=\"stats\"><strong>" + lastVar2 + " at " + lastVar1 + "=" + otherValues1[2 * i + 1] + "</strong></td>";
                if (Math.Exp(est) < 1000)
                {
                    iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("F4") + "</td>";
                }
                else
                {
                    iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("0.##E+0") + "</td>";
                }
                if (Math.Exp(lcl) < 1000)
                {
                    iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("F4") + "</td>";
                }
                else
                {
                    iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("0.##E+0") + "</td>";
                }
                if (Math.Exp(ucl) < 1000)
                {
                    iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("F4") + "</td></tr>";
                }
                else
                {
                    iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("0.##E+0") + "</td></tr>";
                }
            }
            return(iorOut + "</table>");
        }
Beispiel #3
0
        public static String DummyFirst(double[,] cm, String[] bLabels, double[] B, String lastVar1, String lastVar2, int interactions, int iaTerms, double[,] DataArray)
        {
            String iorOut  = "";
            double Z       = SharedResources.ZFromP(0.025);
            String ref1    = getRef(lastVar1, bLabels);
            int    column2 = 1;

            for (int i = 0; i < bLabels.Length; i++)
            {
                if (bLabels[i] != null && bLabels[i].Equals(lastVar2))
                {
                    column2 += i;
                }
            }
            double ref2 = getColumnMean(column2, DataArray);

            String[] otherValues1       = getNonRef(lastVar1, bLabels);
            int[]    interactionIndexes = getInteractionIndexes(interactions, iaTerms, bLabels);
            iorOut = iorOut + "<table><tr><td class=\"stats\" colspan=4 align=\"left\"><strong>Odds Ratios for " + lastVar1 + " * " + lastVar2 + " Interaction</strong></td></tr><tr><td class=\"stats\" align=\"left\"><strong>Label</strong></td><td class=\"stats\" align=\"center\"><strong>Estimate</strong></td><td class=\"stats\" colspan=2 align=\"center\"><strong>95% Confidence Limits</strong></td></tr>";
            for (int i = 0; i < otherValues1.Length / 2; i++)
            {
                double est      = -B[Int32.Parse(otherValues1[2 * i])] - ref2 * B[interactionIndexes[i]];
                double variance = cm[Int32.Parse(otherValues1[2 * i]), Int32.Parse(otherValues1[2 * i])] + Math.Pow(ref2, 2.0) * cm[interactionIndexes[i], interactionIndexes[i]] +
                                  2 * ref2 * cm[Int32.Parse(otherValues1[2 * i]), interactionIndexes[i]];
                double lcl = est - Z * Math.Sqrt(variance);
                double ucl = est + Z * Math.Sqrt(variance);
                iorOut = iorOut + "<tr><td class=\"stats\"><strong>" + lastVar1 + " " + ref1 + " vs " + otherValues1[2 * i + 1] +
                         " at " + lastVar2 + "=" + ref2.ToString("F3") + "</strong></td>";
                if (Math.Exp(est) < 1000)
                {
                    iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("F4") + "</td>";
                }
                else
                {
                    iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("0.##E+0") + "</td>";
                }
                if (Math.Exp(lcl) < 1000)
                {
                    iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("F4") + "</td>";
                }
                else
                {
                    iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("0.##E+0") + "</td>";
                }
                if (Math.Exp(ucl) < 1000)
                {
                    iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("F4") + "</td></tr>";
                }
                else
                {
                    iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("0.##E+0") + "</td></tr>";
                }
            }
            for (int i = 0; i < otherValues1.Length / 2; i++)
            {
                for (int j = i + 1; j < otherValues1.Length / 2; j++)
                {
                    double est      = B[Int32.Parse(otherValues1[2 * i])] + ref2 * B[interactionIndexes[i]] - B[Int32.Parse(otherValues1[2 * j])] - ref2 * B[interactionIndexes[j]];
                    double variance = cm[Int32.Parse(otherValues1[2 * i]), Int32.Parse(otherValues1[2 * i])] +
                                      Math.Pow(ref2, 2.0) * cm[interactionIndexes[i], interactionIndexes[i]] +
                                      cm[Int32.Parse(otherValues1[2 * j]), Int32.Parse(otherValues1[2 * j])] +
                                      Math.Pow(ref2, 2.0) * cm[interactionIndexes[j], interactionIndexes[j]] +
                                      2 * ref2 * cm[Int32.Parse(otherValues1[2 * i]), interactionIndexes[i]] -
                                      2 * cm[Int32.Parse(otherValues1[2 * i]), Int32.Parse(otherValues1[2 * j])] -
                                      2 * ref2 * cm[Int32.Parse(otherValues1[2 * i]), interactionIndexes[j]] -
                                      2 * ref2 * cm[Int32.Parse(otherValues1[2 * j]), interactionIndexes[i]] -
                                      2 * ref2 * ref2 * cm[interactionIndexes[j], interactionIndexes[i]] +
                                      2 * ref2 * cm[Int32.Parse(otherValues1[2 * j]), interactionIndexes[j]];
                    double lcl = est - Z * Math.Sqrt(variance);
                    double ucl = est + Z * Math.Sqrt(variance);
                    iorOut = iorOut + "<tr><td class=\"stats\"><strong>" + lastVar1 + " " + otherValues1[2 * i + 1] + " vs " +
                             otherValues1[2 * j + 1] + " at " + lastVar2 + "=" + ref2.ToString("F3") + "</strong></td>";
                    if (Math.Exp(est) < 1000)
                    {
                        iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("F4") + "</td>";
                    }
                    else
                    {
                        iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("0.##E+0") + "</td>";
                    }
                    if (Math.Exp(lcl) < 1000)
                    {
                        iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("F4") + "</td>";
                    }
                    else
                    {
                        iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("0.##E+0") + "</td>";
                    }
                    if (Math.Exp(ucl) < 1000)
                    {
                        iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("F4") + "</td></tr>";
                    }
                    else
                    {
                        iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("0.##E+0") + "</td></tr>";
                    }
                }
            }
            return(iorOut + "</table>");
        }
Beispiel #4
0
        public static String TwoDummyVariables(double[,] cm, String[] bLabels, double[] B, String lastVar1, String lastVar2, int interactions, int iaTerms)
        {
            String iorOut = "";
            double Z      = SharedResources.ZFromP(0.025);
            String ref1   = getRef(lastVar1, bLabels);
            String ref2   = getRef(lastVar2, bLabels);

            String[] otherValues1 = getNonRef(lastVar1, bLabels);
            String[] otherValues2 = getNonRef(lastVar2, bLabels);
            iorOut = iorOut + "<table><tr><td class=\"stats\" colspan=4 align=\"left\"><strong>Odds Ratios for " + lastVar1 + " * " + lastVar2 + " Interaction</strong></td></tr><tr><td class=\"stats\" align=\"left\"><strong>Label</strong></td><td class=\"stats\" align=\"center\"><strong>Estimate</strong></td><td class=\"stats\" colspan=2 align=\"center\"><strong>95% Confidence Limits</strong></td></tr>";
            for (int i = 0; i < otherValues1.Length / 2; i++)
            {
                double est = -B[Int32.Parse(otherValues1[2 * i])];
                double lcl = est - Z * Math.Sqrt(cm[Int32.Parse(otherValues1[2 * i]), Int32.Parse(otherValues1[2 * i])]);
                double ucl = est + Z * Math.Sqrt(cm[Int32.Parse(otherValues1[2 * i]), Int32.Parse(otherValues1[2 * i])]);
                iorOut = iorOut + "<tr><td class=\"stats\"><strong>" + lastVar1 + " " + ref1 + " vs " + otherValues1[2 * i + 1] +
                         " at " + lastVar2 + "=" + ref2 + "</strong></td>";
                if (Math.Exp(est) < 1000)
                {
                    iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("F4") + "</td>";
                }
                else
                {
                    iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("0.##E+0") + "</td>";
                }
                if (Math.Exp(lcl) < 1000)
                {
                    iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("F4") + "</td>";
                }
                else
                {
                    iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("0.##E+0") + "</td>";
                }
                if (Math.Exp(ucl) < 1000)
                {
                    iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("F4") + "</td></tr>";
                }
                else
                {
                    iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("0.##E+0") + "</td></tr>";
                }
            }
            for (int i = 0; i < otherValues1.Length / 2; i++)
            {
                for (int j = i + 1; j < otherValues1.Length / 2; j++)
                {
                    double est      = B[Int32.Parse(otherValues1[2 * i])] - B[Int32.Parse(otherValues1[2 * j])];
                    double variance = cm[Int32.Parse(otherValues1[2 * i]), Int32.Parse(otherValues1[2 * i])] +
                                      cm[Int32.Parse(otherValues1[2 * j]), Int32.Parse(otherValues1[2 * j])] -
                                      2 * cm[Int32.Parse(otherValues1[2 * i]), Int32.Parse(otherValues1[2 * j])];
                    double lcl = est - Z * Math.Sqrt(variance);
                    double ucl = est + Z * Math.Sqrt(variance);
                    iorOut = iorOut + "<tr><td class=\"stats\"><strong>" + lastVar1 + " " + otherValues1[2 * i + 1] + " vs " +
                             otherValues1[2 * j + 1] + " at " + lastVar2 + "=" + ref2 + "</strong></td>";
                    if (Math.Exp(est) < 1000)
                    {
                        iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("F4") + "</td>";
                    }
                    else
                    {
                        iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("0.##E+0") + "</td>";
                    }
                    if (Math.Exp(lcl) < 1000)
                    {
                        iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("F4") + "</td>";
                    }
                    else
                    {
                        iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("0.##E+0") + "</td>";
                    }
                    if (Math.Exp(ucl) < 1000)
                    {
                        iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("F4") + "</td></tr>";
                    }
                    else
                    {
                        iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("0.##E+0") + "</td></tr>";
                    }
                }
            }
            int[] interactionIndexes = getInteractionIndexes(interactions, iaTerms, bLabels);
            int   multiple           = otherValues2.Length / 2;

            for (int k = 0; k < otherValues2.Length / 2; k++)
            {
                Stack <double> betaStack = new Stack <double>();
                for (int i = 0; i < otherValues1.Length / 2; i++)
                {
                    double est      = -(B[Int32.Parse(otherValues1[2 * i])] + B[interactionIndexes[multiple * i + k]]);
                    double variance = cm[Int32.Parse(otherValues1[2 * i]), Int32.Parse(otherValues1[2 * i])] +
                                      cm[interactionIndexes[multiple * i + k], interactionIndexes[multiple * i + k]] +
                                      2 * cm[Int32.Parse(otherValues1[2 * i]), interactionIndexes[multiple * i + k]];
                    double lcl = est - Z * Math.Sqrt(variance);
                    double ucl = est + Z * Math.Sqrt(variance);
                    betaStack.Push(est);
                    iorOut = iorOut + "<tr><td class=\"stats\"><strong>" + lastVar1 + " " + ref1 + " vs " +
                             otherValues1[2 * i + 1] + " at " + lastVar2 + "=" + otherValues2[2 * k + 1] + "</strong></td>";
                    if (Math.Exp(est) < 1000)
                    {
                        iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("F4") + "</td>";
                    }
                    else
                    {
                        iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("0.##E+0") + "</td>";
                    }
                    if (Math.Exp(lcl) < 1000)
                    {
                        iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("F4") + "</td>";
                    }
                    else
                    {
                        iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("0.##E+0") + "</td>";
                    }
                    if (Math.Exp(ucl) < 1000)
                    {
                        iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("F4") + "</td></tr>";
                    }
                    else
                    {
                        iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("0.##E+0") + "</td></tr>";
                    }
                }
                double[] betas = betaStack.ToArray();
                for (int i = 0; i < otherValues1.Length / 2; i++)
                {
                    for (int j = i + 1; j < otherValues1.Length / 2; j++)
                    {
                        double est = (B[Int32.Parse(otherValues1[2 * i])] + B[interactionIndexes[multiple * i + k]]) -
                                     (B[Int32.Parse(otherValues1[2 * j])] + B[interactionIndexes[multiple * j + k]]);
                        double variance = cm[Int32.Parse(otherValues1[2 * i]), Int32.Parse(otherValues1[2 * i])] +
                                          cm[interactionIndexes[multiple * i + k], interactionIndexes[multiple * i + k]] +
                                          cm[Int32.Parse(otherValues1[2 * j]), Int32.Parse(otherValues1[2 * j])] +
                                          cm[interactionIndexes[multiple * j + k], interactionIndexes[multiple * j + k]] +
                                          2 * cm[Int32.Parse(otherValues1[2 * i]), interactionIndexes[multiple * i + k]] +
                                          -2 * cm[Int32.Parse(otherValues1[2 * i]), Int32.Parse(otherValues1[2 * j])] +
                                          -2 * cm[Int32.Parse(otherValues1[2 * i]), interactionIndexes[multiple * j + k]] +
                                          -2 * cm[interactionIndexes[multiple * i + k], Int32.Parse(otherValues1[2 * j])] +
                                          -2 * cm[interactionIndexes[multiple * i + k], interactionIndexes[multiple * j + k]] +
                                          2 * cm[Int32.Parse(otherValues1[2 * j]), interactionIndexes[multiple * j + k]];
                        double lcl = est - Z * Math.Sqrt(variance);
                        double ucl = est + Z * Math.Sqrt(variance);
                        iorOut = iorOut + "<tr><td class=\"stats\"><strong>" + lastVar1 + " " + otherValues1[2 * i + 1] + " vs " +
                                 otherValues1[2 * j + 1] + " at " + lastVar2 + "=" + otherValues2[2 * k + 1] + "</strong></td>";
                        if (Math.Exp(est) < 1000)
                        {
                            iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("F4") + "</td>";
                        }
                        else
                        {
                            iorOut = iorOut + "<td  class=\"stats\" align=\"center\">" + Math.Exp(est).ToString("0.##E+0") + "</td>";
                        }
                        if (Math.Exp(lcl) < 1000)
                        {
                            iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("F4") + "</td>";
                        }
                        else
                        {
                            iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(lcl).ToString("0.##E+0") + "</td>";
                        }
                        if (Math.Exp(ucl) < 1000)
                        {
                            iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("F4") + "</td></tr>";
                        }
                        else
                        {
                            iorOut = iorOut + "<td class=\"stats\" align=\"center\">" + Math.Exp(ucl).ToString("0.##E+0") + "</td></tr>";
                        }
                    }
                }
            }
            return(iorOut + "</table>");
        }
Beispiel #5
0
        public static double[] MHStats(double a, double b, double c, double d, double P)
        {
            double[] MHStats = new double[15];
            double   z       = 0.0;

            if (P < 0.9500001 && P > 0.95 - 0.00001)
            {
                z = 1.96;
            }
            else if (P < 0.9900001 && P > 0.99 - 0.00001)
            {
                z = 2.58;
            }
            else if (P < 0.900001 && P > 0.9 + 0.00001)
            {
                z = 1.64;
            }
            else
            {
                z = SharedResources.ZFromP(P);
            }

            double n1 = a + b;
            double n0 = c + d;
            double m1 = a + c;
            double m0 = b + d;
            double n  = m1 + m0;
            double re = a / n1;
            double ru = c / n0;
            double r  = m1 / n;
            double pe = n1 / n;

            if (b * c < 0.00000001)
            {
                MHStats[0] = -1.0;
                MHStats[1] = -1.0;
                MHStats[2] = -1.0;
            }
            else
            {
                MHStats[0] = (a * d) / (b * c);
                if (d * a < 0.000001)
                {
                    MHStats[1] = -1;
                    MHStats[2] = -1;
                }
                else
                {
                    MHStats[1] = Math.Exp(Math.Log((a * d) / (b * c)) - z * Math.Sqrt(1 / a + 1 / b + 1 / c + 1 / d));
                    MHStats[2] = Math.Exp(Math.Log((a * d) / (b * c)) + z * Math.Sqrt(1 / a + 1 / b + 1 / c + 1 / d));
                }
            }

            if (ru < 0.00001)
            {
                MHStats[3] = -1.0;
                MHStats[4] = -1.0;
                MHStats[5] = -1.0;
            }
            else
            {
                MHStats[3] = re / ru;
                if (re < 0.00001)
                {
                    MHStats[4] = -1.0;
                    MHStats[5] = -1.0;
                }
                else
                {
                    MHStats[4] = Math.Exp(Math.Log((a / n1) / (c / n0)) - z * Math.Sqrt(d / (c * n0) + b / (n1 * a)));
                    MHStats[5] = Math.Exp(Math.Log((a / n1) / (c / n0)) + z * Math.Sqrt(d / (c * n0) + b / (n1 * a)));
                }
            }

            MHStats[6] = (re - ru) * 100;
            MHStats[7] = (re - ru - z * Math.Sqrt(re * (1 - re) / n1 + ru * (1 - ru) / n0)) * 100;
            MHStats[8] = (re - ru + z * Math.Sqrt(re * (1 - re) / n1 + ru * (1 - ru) / n0)) * 100;

            double h3  = m1 * m0 * n1 * n0;
            double phi = ((a * d) - b * c) / Math.Sqrt(h3);

            MHStats[9]  = n * Math.Pow(phi, 2.0);
            MHStats[10] = SharedResources.PValFromChiSq(MHStats[9], 1);
            MHStats[11] = (n - 1) / h3 * Math.Pow((a * d - b * c), 2.0);
            MHStats[12] = SharedResources.PValFromChiSq(MHStats[11], 1);
            MHStats[13] = (n - 1) / h3 * Math.Pow((Math.Abs(a * d - b * c) - n * 0.5), 2.0);
            MHStats[14] = SharedResources.PValFromChiSq(MHStats[13], 1.0);

            return(MHStats);
        }