This is known in statistical genetics as the McDonald-Kreitman test. The implementation handles both known and unknown distributions.
Two samples tests can be used when the distribution is unknown a priori but provided by one sample, or when the hypothesis under test is that the two samples come from the same underlying distribution.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private double | Returns: Shannon Entropy of the given Matrix2 Dimensional Matrix of long values (for ex. the counts of a
trials) k)Calculates the Shannon entropy for 2 Dimensional Matrix. |
| private double | Returns: Shannon Entropy of the given VectorVector (for ex. Row Sums of a trials) k)Calculates the Shannon entropy for a vector. |
| public double | Returns: G-Test statisticarray of expected frequency counts expected, final long[] array of observed frequency counts observed)Computes the G statistic
for Goodness of Fit comparing |
| public double | Returns: G-Test statisticarray of observed frequency counts of the first data set observed1, final long[] array of observed frequency counts of the second data
set observed2)Computes a G (Log-Likelihood Ratio) two sample test statistic for
independence comparing frequency counts in
|
| public double | Returns: p-valuearray of expected frequency counts expected, final long[] array of observed frequency counts observed)Returns the observed significance level, or p-value,
associated with a G-Test for goodness of fit comparing the
|
| public boolean | Returns: true iff null hypothesis can be rejected with confidence 1 - alphaarray of expected frequency counts expected, final long[] array of observed frequency counts observed, final double significance level of the test alpha)Performs a G-Test (Log-Likelihood Ratio Test) for goodness of fit
evaluating the null hypothesis that the observed counts conform to the
frequency distribution described by the expected counts, with
significance level |
| public double | Returns: p-valuearray of observed frequency counts of the first data set observed1, final long[] array of observed frequency counts of the second data
set observed2)Returns the observed significance level, or
p-value, associated with a G-Value (Log-Likelihood Ratio) for two
sample test comparing bin frequency counts in |
| public boolean | Returns: true iff null hypothesis can be rejected with confidence 1 - alphaarray of observed frequency counts of the first data set observed1, final long[] array of observed frequency counts of the second data
set observed2, final double significance level of the test alpha)Performs a G-Test (Log-Likelihood Ratio Test) comparing two binned data sets. |
| public double | Returns: p-valuearray of expected frequency counts expected, final long[] array of observed frequency counts observed)Returns the intrinsic (Hardy-Weinberg proportions) p-Value, as described in p64-69 of McDonald, J.H. |
| public double | Returns: root log-likelihood rationumber of times the two events occurred together (AB) k11, long number of times the second event occurred WITHOUT the
first event (notA,B) k12, final long number of times the first event occurred WITHOUT the
second event (A, notB) k21, final long number of times something else occurred (i.e. was neither
of these events (notA, notB) k22)Calculates the root log-likelihood ratio for 2 state Datasets. |
| GTest | back to summary |
|---|---|
| public GTest() | |
| entropy | back to summary |
|---|---|
| private double entropy(final long[][] k) Calculates the Shannon
entropy for 2 Dimensional Matrix. The value returned is the entropy
of the vector formed by concatenating the rows (or columns) of
| |
| entropy | back to summary |
|---|---|
| private double entropy(final long[] k) Calculates the
Shannon entropy for a vector. The values of
| |
| g | back to summary |
|---|---|
| public double g(final double[] expected, final long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException Computes the G statistic
for Goodness of Fit comparing This statistic can be used to perform a G test (Log-Likelihood Ratio Test) evaluating the null hypothesis that the observed counts follow the expected distribution. Preconditions:
If any of the preconditions are not met, a
Note This implementation rescales the
| |
| gDataSetsComparison | back to summary |
|---|---|
| public double gDataSetsComparison(final long[] observed1, final long[] observed2) throws DimensionMismatchException, NotPositiveException, ZeroException Computes a G (Log-Likelihood Ratio) two sample test statistic for
independence comparing frequency counts in
where This statistic can be used to perform a G test evaluating the null hypothesis that both observed counts are independent Preconditions:
If any of the preconditions are not met, a
| |
| gTest | back to summary |
|---|---|
| public double gTest(final double[] expected, final long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, MaxCountExceededException Returns the observed significance level, or p-value,
associated with a G-Test for goodness of fit comparing the
The number returned is the smallest significance level at which one can reject the null hypothesis that the observed counts conform to the frequency distribution described by the expected counts. The probability returned is the tail probability beyond
Preconditions:
If any of the preconditions are not met, a
Note This implementation rescales the
| |
| gTest | back to summary |
|---|---|
| public boolean gTest(final double[] expected, final long[] observed, final double alpha) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, OutOfRangeException, MaxCountExceededException Performs a G-Test (Log-Likelihood Ratio Test) for goodness of fit
evaluating the null hypothesis that the observed counts conform to the
frequency distribution described by the expected counts, with
significance level Example:
Returns true iff Preconditions:
If any of the preconditions are not met, a
Note This implementation rescales the
| |
| gTestDataSetsComparison | back to summary |
|---|---|
| public double gTestDataSetsComparison(final long[] observed1, final long[] observed2) throws DimensionMismatchException, NotPositiveException, ZeroException, MaxCountExceededException Returns the observed significance level, or
p-value, associated with a G-Value (Log-Likelihood Ratio) for two
sample test comparing bin frequency counts in The number returned is the smallest significance level at which one can reject the null hypothesis that the observed counts conform to the same distribution. See Preconditions:
If any of the preconditions are not met, a
| |
| gTestDataSetsComparison | back to summary |
|---|---|
| public boolean gTestDataSetsComparison(final long[] observed1, final long[] observed2, final double alpha) throws DimensionMismatchException, NotPositiveException, ZeroException, OutOfRangeException, MaxCountExceededException Performs a G-Test (Log-Likelihood Ratio Test) comparing two binned
data sets. The test evaluates the null hypothesis that the two lists
of observed counts conform to the same frequency distribution, with
significance level See
If any of the preconditions are not met, a
| |
| gTestIntrinsic | back to summary |
|---|---|
| public double gTestIntrinsic(final double[] expected, final long[] observed) throws NotPositiveException, NotStrictlyPositiveException, DimensionMismatchException, MaxCountExceededException Returns the intrinsic (Hardy-Weinberg proportions) p-Value, as described in p64-69 of McDonald, J.H. 2009. Handbook of Biological Statistics (2nd ed.). Sparky House Publishing, Baltimore, Maryland. The probability returned is the tail probability beyond
| |
| rootLogLikelihoodRatio | back to summary |
|---|---|
| public double rootLogLikelihoodRatio(final long k11, long k12, final long k21, final long k22) Calculates the root log-likelihood ratio for 2 state Datasets. See
Given two events A and B, let k11 be the number of times both events occur, k12 the incidence of B without A, k21 the count of A without B, and k22 the number of times neither A nor B occurs. What is returned by this method is
where Signed root LLR has two advantages over the basic LLR: a) it is positive where k11 is bigger than expected, negative where it is lower b) if there is no difference it is asymptotically normally distributed. This allows one to talk about "number of standard deviations" which is a more common frame of reference than the chi^2 distribution.
| |