net.sf.varscan
Class FishersExact

java.lang.Object
  extended by net.sf.varscan.FishersExact

public class FishersExact
extends java.lang.Object

A statistical class for performing Fisher's exact test. This does a Fisher's Exact test, a statistical test procedure that calculates an exact probability value for the relationship between two dichotomous variables, as found in a two by two crosstable. The program calculates the difference between the data observed and the data expected, considering the given marginal and the assumptions of the model of independence. It works in exactly the same way as the Chi-square test for independence; however, the Chi-square gives only an estimate of the true probability value, an estimate which might not be very accurate if the marginal is very uneven or if there is a small value (less than five) in one of the cells.

Version:
2.2
Author:
Daniel C. Koboldt

Constructor Summary
FishersExact(int maxSize)
          constructor for FisherExact table
 
Method Summary
 double getCumlativeP(int a, int b, int c, int d)
          Calculates the one-tail P-value for the Fisher Exact test.
 double getLeftTailedP(int a, int b, int c, int d)
          Calculates the left-tail P-value for the Fisher Exact test.
 double getP(int a, int b, int c, int d)
          calculates the P-value for this specific state
 double getRightTailedP(int a, int b, int c, int d)
          Calculates the right-tail P-value for the Fisher Exact test.
 double getTwoTailedP(int a, int b, int c, int d)
          Calculates the two-tailed P-value for the Fisher Exact test.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FishersExact

public FishersExact(int maxSize)
constructor for FisherExact table

Parameters:
maxSize - is the maximum sum that will be encountered by the table (a+b+c+d)
Method Detail

getP

public final double getP(int a,
                         int b,
                         int c,
                         int d)
calculates the P-value for this specific state

Parameters:
a - a, b, c, d are the four cells in a 2x2 matrix
b -
c -
d -
Returns:
the P-value

getCumlativeP

public final double getCumlativeP(int a,
                                  int b,
                                  int c,
                                  int d)
Calculates the one-tail P-value for the Fisher Exact test. Determines whether to calculate the right- or left- tail, thereby always returning the smallest p-value.

Parameters:
a - a, b, c, d are the four cells in a 2x2 matrix
b -
c -
d -
Returns:
one-tailed P-value (right or left, whichever is smallest)

getRightTailedP

public final double getRightTailedP(int a,
                                    int b,
                                    int c,
                                    int d)
Calculates the right-tail P-value for the Fisher Exact test.

Parameters:
a - a, b, c, d are the four cells in a 2x2 matrix
b -
c -
d -
Returns:
one-tailed P-value (right-tail)

getLeftTailedP

public final double getLeftTailedP(int a,
                                   int b,
                                   int c,
                                   int d)
Calculates the left-tail P-value for the Fisher Exact test.

Parameters:
a - a, b, c, d are the four cells in a 2x2 matrix
b -
c -
d -
Returns:
one-tailed P-value (left-tail)

getTwoTailedP

public final double getTwoTailedP(int a,
                                  int b,
                                  int c,
                                  int d)
Calculates the two-tailed P-value for the Fisher Exact test. In order for a table under consideration to have its p-value included in the final result, it must have a p-value less than the original table's P-value, i.e. Fisher's exact test computes the probability, given the observed marginal frequencies, of obtaining exactly the frequencies observed and any configuration more extreme. By "more extreme," we mean any configuration (given observed marginals) with a smaller probability of occurrence in the same direction (one-tailed) or in both directions (two-tailed).

Parameters:
a - a, b, c, d are the four cells in a 2x2 matrix
b -
c -
d -
Returns:
two-tailed P-value

main

public static void main(java.lang.String[] args)