Class GChiSquared2by2


  • public class GChiSquared2by2
    extends java.lang.Object
    Chi-squared for 2-by-2 contingency tables.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double computeLogLikelihoodChiSquared​(int o11, int o12, int o21, int o22)
      Compute the likelihood ratio chi-squared value for the 2-by-2 table [o11 o12] [o21 o22].
      static double computePearsonChiSquared​(int o11, int o12, int o21, int o22)
      Compute the Pearson's chi-squared value for the 2-by-2 table [o11 o12] [o21 o22].
      static double getChiSqValue​(double pvalue)
      Get the chi-squared value corresponding to a p-value (assuming 1 degree of freedom).
      static double getFiniteChiSqValue​(double pvalue, int o11, int o12, int o21, int o22)
      Get the chi-squared value corresponding to a p-value (assuming 1 degree of freedom), but if the p-value is zero compute the chi-squared value directly from the table.
      static double getPValue​(double chisq)
      Get the p-value from a chi-squared value for a 2-by-2 table.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • computePearsonChiSquared

        public static double computePearsonChiSquared​(int o11,
                                                      int o12,
                                                      int o21,
                                                      int o22)
        Compute the Pearson's chi-squared value for the 2-by-2 table [o11 o12] [o21 o22].
        Parameters:
        o11 - entry (1,1)
        o12 - entry (1,2)
        o21 - entry (2,1)
        o22 - entry (2,2)
        Returns:
        the chi squared value
      • computeLogLikelihoodChiSquared

        public static double computeLogLikelihoodChiSquared​(int o11,
                                                            int o12,
                                                            int o21,
                                                            int o22)
        Compute the likelihood ratio chi-squared value for the 2-by-2 table [o11 o12] [o21 o22].
        Parameters:
        o11 - entry (1,1)
        o12 - entry (1,2)
        o21 - entry (2,1)
        o22 - entry (2,2)
        Returns:
        the chi squared value
      • getPValue

        public static double getPValue​(double chisq)
        Get the p-value from a chi-squared value for a 2-by-2 table. That is, get the p-value for a chi-squared distribution with 1 degree of freedom.
        Parameters:
        chisq - the chi-squared value
        Returns:
        the p-value
      • getChiSqValue

        public static double getChiSqValue​(double pvalue)
        Get the chi-squared value corresponding to a p-value (assuming 1 degree of freedom).
        Parameters:
        pvalue - the p-value
        Returns:
        the chi-squared value
      • getFiniteChiSqValue

        public static double getFiniteChiSqValue​(double pvalue,
                                                 int o11,
                                                 int o12,
                                                 int o21,
                                                 int o22)
        Get the chi-squared value corresponding to a p-value (assuming 1 degree of freedom), but if the p-value is zero compute the chi-squared value directly from the table. This is preferable to returning an infinite value, if the chi-squared values are used for correcting the p-values (genomic control).
        Parameters:
        pvalue - the p-value
        o11 - entry (1,1)
        o12 - entry (1,2)
        o21 - entry (2,1)
        o22 - entry (2,2)
        Returns:
        the chi-squared value