Package pal.statistics
Class ContigencyTable
- java.lang.Object
-
- pal.statistics.ContigencyTable
-
public class ContigencyTable extends java.lang.Object
Class for permuting contigency tables and determining the likelihood of the table. If determining of the probability of a 2x2 table use FisherExact as it is much faster.- Version:
- $Id: ContigencyTable.java,v 1
- Author:
- Ed Buckler
-
-
Constructor Summary
Constructors Constructor Description ContigencyTable(int maxSize)
constructor for Contigency table
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
calcContigencyChiSquare(int permutations)
This calculates the probability in the normal approach, using the Chi Square as the test statistic.double
calcMonteCarloExactTest(int permutations)
This calculates the probability in the normal permutation approach, using the method described by Weir, B.double
calcRapidContigencyChiSquare(int maxPermutations)
This calculates the probability in a rapid approach, using the Chi Square as the test statistic.double
calcRapidMonteCarloExactTest(int maxPermutations)
This calculates the probability in the rapid permutational approach, using the method described by Weir, B.void
setMatrix(int[][] tcontig)
sets the data for the contigency table, must be set before other methods are called.
-
-
-
Method Detail
-
setMatrix
public void setMatrix(int[][] tcontig)
sets the data for the contigency table, must be set before other methods are called. If tcontig has a greater count than maxSize, then the contig is set to null- Parameters:
contig
- is the array of integers with observed states
-
calcRapidContigencyChiSquare
public double calcRapidContigencyChiSquare(int maxPermutations)
This calculates the probability in a rapid approach, using the Chi Square as the test statistic. It runs for maxPermutations permutations unless it find 10 values that beat the observed, and then it stops and calculates the p-value. This slighly biases the P-values but makes it much more rapid.- Parameters:
maxPermutations
- Number of permutations used to calculate the probability- Returns:
- P-value (NaN is returned if bad contig was set)
-
calcContigencyChiSquare
public double calcContigencyChiSquare(int permutations)
This calculates the probability in the normal approach, using the Chi Square as the test statistic.- Parameters:
permutations
- Number of permutations used to calculate the probability- Returns:
- P-value (NaN is returned if bad contig was set)
-
calcRapidMonteCarloExactTest
public double calcRapidMonteCarloExactTest(int maxPermutations)
This calculates the probability in the rapid permutational approach, using the method described by Weir, B. S. (1996) Genetic Data Analysis II (Sinauer, Sunderland, MA) It runs for 1000 permutations unless it find 10 values that beat the observed, and then it stops and calculates the p-value. This slighly biases the P-values but makes it much more rapid.- Parameters:
reps
- is the number of permutations used to the probability- Returns:
- P-value (NaN is returned if bad contig was set)
-
calcMonteCarloExactTest
public double calcMonteCarloExactTest(int permutations)
This calculates the probability in the normal permutation approach, using the method described by Weir, B. S. (1996) Genetic Data Analysis II (Sinauer, Sunderland, MA).- Parameters:
permutations
- Number of permutations used to the probability- Returns:
- P-value (NaN is returned if bad contig was set)
-
-